anv/allocator: Add a size field to bo_pool_alloc
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 18 Mar 2016 18:50:53 +0000 (11:50 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 18 Mar 2016 18:50:53 +0000 (11:50 -0700)
src/intel/vulkan/anv_allocator.c
src/intel/vulkan/anv_batch_chain.c
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_private.h

index 4fc83386a71c0c6c4aeb549ca371752182ef2520..1928b9bb157394cc999d7f7645a76cc3154534c9 100644 (file)
@@ -820,10 +820,12 @@ anv_bo_pool_finish(struct anv_bo_pool *pool)
 }
 
 VkResult
-anv_bo_pool_alloc(struct anv_bo_pool *pool, struct anv_bo *bo)
+anv_bo_pool_alloc(struct anv_bo_pool *pool, struct anv_bo *bo, uint32_t size)
 {
    VkResult result;
 
+   assert(pool->bo_size <= size);
+
    void *next_free_void;
    if (anv_ptr_free_list_pop(&pool->free_list, &next_free_void)) {
       struct bo_pool_bo_link *next_free = next_free_void;
index d24dd06d7eb4014635fc298ac41ac5b77da60cda..eab050f066b6bb35cd29b8bcdacca22a330e53dc 100644 (file)
@@ -251,7 +251,8 @@ anv_batch_bo_create(struct anv_cmd_buffer *cmd_buffer,
    if (bbo == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
-   result = anv_bo_pool_alloc(&cmd_buffer->device->batch_bo_pool, &bbo->bo);
+   result = anv_bo_pool_alloc(&cmd_buffer->device->batch_bo_pool, &bbo->bo,
+                              ANV_CMD_BUFFER_BATCH_SIZE);
    if (result != VK_SUCCESS)
       goto fail_alloc;
 
@@ -283,7 +284,8 @@ anv_batch_bo_clone(struct anv_cmd_buffer *cmd_buffer,
    if (bbo == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
-   result = anv_bo_pool_alloc(&cmd_buffer->device->batch_bo_pool, &bbo->bo);
+   result = anv_bo_pool_alloc(&cmd_buffer->device->batch_bo_pool, &bbo->bo,
+                              other_bbo->bo.size);
    if (result != VK_SUCCESS)
       goto fail_alloc;
 
index bcd7a9e3c0d6d9cb020b751c07c09cc9cd45cf4a..77fd72c42e14b35e6a37fd0ec8b68b6f8362dcc1 100644 (file)
@@ -717,7 +717,7 @@ anv_device_submit_simple_batch(struct anv_device *device,
    /* Kernel driver requires 8 byte aligned batch length */
    size = align_u32(batch->next - batch->start, 8);
    assert(size < device->batch_bo_pool.bo_size);
-   result = anv_bo_pool_alloc(&device->batch_bo_pool, &bo);
+   result = anv_bo_pool_alloc(&device->batch_bo_pool, &bo, 4096);
    if (result != VK_SUCCESS)
       return result;
 
@@ -1390,7 +1390,7 @@ VkResult anv_CreateFence(
 
    assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_FENCE_CREATE_INFO);
 
-   result = anv_bo_pool_alloc(&device->batch_bo_pool, &fence_bo);
+   result = anv_bo_pool_alloc(&device->batch_bo_pool, &fence_bo, 4096);
    if (result != VK_SUCCESS)
       return result;
 
index 939cd087377c5f02434d2dc0dd948d521214e8aa..46e377c04901d9d2a3568cb4fd869d42d7dee586 100644 (file)
@@ -476,7 +476,8 @@ struct anv_bo_pool {
 void anv_bo_pool_init(struct anv_bo_pool *pool,
                       struct anv_device *device, uint32_t block_size);
 void anv_bo_pool_finish(struct anv_bo_pool *pool);
-VkResult anv_bo_pool_alloc(struct anv_bo_pool *pool, struct anv_bo *bo);
+VkResult anv_bo_pool_alloc(struct anv_bo_pool *pool, struct anv_bo *bo,
+                           uint32_t size);
 void anv_bo_pool_free(struct anv_bo_pool *pool, const struct anv_bo *bo);