vulkan,anv: Add a base object struct type
authorJason Ekstrand <jason@jlekstrand.net>
Tue, 21 Apr 2020 17:33:16 +0000 (12:33 -0500)
committerMarge Bot <eric+marge@anholt.net>
Mon, 4 May 2020 14:06:27 +0000 (14:06 +0000)
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Kristian H. Kristensen <hoegsberg@google.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4690>

15 files changed:
src/intel/vulkan/anv_cmd_buffer.c
src/intel/vulkan/anv_descriptor_set.c
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_formats.c
src/intel/vulkan/anv_image.c
src/intel/vulkan/anv_pass.c
src/intel/vulkan/anv_pipeline.c
src/intel/vulkan/anv_pipeline_cache.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/anv_queue.c
src/intel/vulkan/genX_pipeline.c
src/intel/vulkan/genX_query.c
src/intel/vulkan/genX_state.c
src/vulkan/util/vk_object.c
src/vulkan/util/vk_object.h

index 03af604de4c9b3b8e06d58205e4e4f7a0355d0e4..49c7334567f1398c120e8c89af35863912a8babf 100644 (file)
@@ -203,9 +203,11 @@ static VkResult anv_create_cmd_buffer(
    if (cmd_buffer == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
+   vk_object_base_init(&device->vk, &cmd_buffer->base,
+                       VK_OBJECT_TYPE_COMMAND_BUFFER);
+
    cmd_buffer->batch.status = VK_SUCCESS;
 
-   cmd_buffer->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
    cmd_buffer->device = device;
    cmd_buffer->pool = pool;
    cmd_buffer->level = level;
@@ -280,6 +282,7 @@ anv_cmd_buffer_destroy(struct anv_cmd_buffer *cmd_buffer)
 
    anv_cmd_state_finish(cmd_buffer);
 
+   vk_object_base_finish(&cmd_buffer->base);
    vk_free(&cmd_buffer->pool->alloc, cmd_buffer);
 }
 
@@ -906,6 +909,8 @@ VkResult anv_CreateCommandPool(
    if (pool == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
+   vk_object_base_init(&device->vk, &pool->base, VK_OBJECT_TYPE_COMMAND_POOL);
+
    if (pAllocator)
       pool->alloc = *pAllocator;
    else
@@ -934,6 +939,7 @@ void anv_DestroyCommandPool(
       anv_cmd_buffer_destroy(cmd_buffer);
    }
 
+   vk_object_base_finish(&pool->base);
    vk_free2(&device->vk.alloc, pAllocator, pool);
 }
 
index ce6caafcf7a27297222ef845d97678efa8157f1d..d4676b234163c3f90ca2f13862345c312a836f5d 100644 (file)
@@ -363,6 +363,8 @@ VkResult anv_CreateDescriptorSetLayout(
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
    memset(set_layout, 0, sizeof(*set_layout));
+   vk_object_base_init(&device->vk, &set_layout->base,
+                       VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT);
    set_layout->ref_cnt = 1;
    set_layout->binding_count = max_binding + 1;
 
@@ -509,6 +511,15 @@ VkResult anv_CreateDescriptorSetLayout(
    return VK_SUCCESS;
 }
 
+void
+anv_descriptor_set_layout_destroy(struct anv_device *device,
+                                  struct anv_descriptor_set_layout *layout)
+{
+   assert(layout->ref_cnt == 0);
+   vk_object_base_finish(&layout->base);
+   vk_free(&device->vk.alloc, layout);
+}
+
 void anv_DestroyDescriptorSetLayout(
     VkDevice                                    _device,
     VkDescriptorSetLayout                       _set_layout,
@@ -592,6 +603,8 @@ VkResult anv_CreatePipelineLayout(
    if (layout == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
+   vk_object_base_init(&device->vk, &layout->base,
+                       VK_OBJECT_TYPE_PIPELINE_LAYOUT);
    layout->num_sets = pCreateInfo->setLayoutCount;
 
    unsigned dynamic_offset_count = 0;
@@ -641,6 +654,7 @@ void anv_DestroyPipelineLayout(
    for (uint32_t i = 0; i < pipeline_layout->num_sets; i++)
       anv_descriptor_set_layout_unref(device, pipeline_layout->set[i].layout);
 
+   vk_object_base_finish(&pipeline_layout->base);
    vk_free2(&device->vk.alloc, pAllocator, pipeline_layout);
 }
 
@@ -736,6 +750,8 @@ VkResult anv_CreateDescriptorPool(
    if (!pool)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
+   vk_object_base_init(&device->vk, &pool->base,
+                       VK_OBJECT_TYPE_DESCRIPTOR_POOL);
    pool->size = pool_size;
    pool->next = 0;
    pool->free_list = EMPTY;
@@ -788,6 +804,7 @@ void anv_DestroyDescriptorPool(
       anv_device_release_bo(device, pool->bo);
    anv_state_stream_finish(&pool->surface_state_stream);
 
+   vk_object_base_finish(&pool->base);
    vk_free2(&device->vk.alloc, pAllocator, pool);
 }
 
@@ -934,7 +951,7 @@ anv_descriptor_set_create(struct anv_device *device,
       uint64_t pool_vma_offset =
          util_vma_heap_alloc(&pool->bo_heap, set_buffer_size, 32);
       if (pool_vma_offset == 0) {
-         anv_descriptor_pool_free_set(pool, set);
+         vk_object_base_finish(&set->base);
          return vk_error(VK_ERROR_FRAGMENTED_POOL);
       }
       assert(pool_vma_offset >= POOL_HEAP_OFFSET &&
@@ -956,6 +973,8 @@ anv_descriptor_set_create(struct anv_device *device,
       set->desc_surface_state = ANV_STATE_NULL;
    }
 
+   vk_object_base_init(&device->vk, &set->base,
+                       VK_OBJECT_TYPE_DESCRIPTOR_SET);
    set->pool = pool;
    set->layout = layout;
    anv_descriptor_set_layout_ref(layout);
@@ -1025,6 +1044,7 @@ anv_descriptor_set_destroy(struct anv_device *device,
 
    list_del(&set->pool_link);
 
+   vk_object_base_finish(&set->base);
    anv_descriptor_pool_free_set(pool, set);
 }
 
@@ -1604,6 +1624,8 @@ VkResult anv_CreateDescriptorUpdateTemplate(
    if (template == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
+   vk_object_base_init(&device->vk, &template->base,
+                       VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE);
    template->bind_point = pCreateInfo->pipelineBindPoint;
 
    if (pCreateInfo->templateType == VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET)
@@ -1639,6 +1661,7 @@ void anv_DestroyDescriptorUpdateTemplate(
    ANV_FROM_HANDLE(anv_descriptor_update_template, template,
                    descriptorUpdateTemplate);
 
+   vk_object_base_finish(&template->base);
    vk_free2(&device->vk.alloc, pAllocator, template);
 }
 
index fd3b292dbbd2b983e80aaaacce40acd4d6ea2d41..8b54408eff014c51db0d22fbb5ccfba7408cbd28 100644 (file)
@@ -377,7 +377,7 @@ anv_physical_device_try_create(struct anv_instance *instance,
       goto fail_fd;
    }
 
-   device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
+   vk_object_base_init(NULL, &device->base, VK_OBJECT_TYPE_PHYSICAL_DEVICE);
    device->instance = instance;
 
    assert(strlen(path) < ARRAY_SIZE(device->path));
@@ -595,6 +595,7 @@ anv_physical_device_destroy(struct anv_physical_device *device)
    close(device->local_fd);
    if (device->master_fd >= 0)
       close(device->master_fd);
+   vk_object_base_finish(&device->base);
    vk_free(&device->instance->alloc, device);
 }
 
@@ -676,7 +677,7 @@ VkResult anv_CreateInstance(
    if (!instance)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
-   instance->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
+   vk_object_base_init(NULL, &instance->base, VK_OBJECT_TYPE_INSTANCE);
 
    if (pAllocator)
       instance->alloc = *pAllocator;
@@ -796,6 +797,7 @@ void anv_DestroyInstance(
    driDestroyOptionCache(&instance->dri_options);
    driDestroyOptionInfo(&instance->available_dri_options);
 
+   vk_object_base_finish(&instance->base);
    vk_free(&instance->alloc, instance);
 }
 
@@ -3360,6 +3362,7 @@ VkResult anv_AllocateMemory(
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
    assert(pAllocateInfo->memoryTypeIndex < pdevice->memory.type_count);
+   vk_object_base_init(&device->vk, &mem->base, VK_OBJECT_TYPE_DEVICE_MEMORY);
    mem->type = mem_type;
    mem->map = NULL;
    mem->map_size = 0;
@@ -3683,6 +3686,7 @@ void anv_FreeMemory(
       AHardwareBuffer_release(mem->ahw);
 #endif
 
+   vk_object_base_finish(&mem->base);
    vk_free2(&device->vk.alloc, pAllocator, mem);
 }
 
@@ -4087,6 +4091,7 @@ VkResult anv_CreateEvent(
    if (event == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
+   vk_object_base_init(&device->vk, &event->base, VK_OBJECT_TYPE_EVENT);
    event->state = anv_state_pool_alloc(&device->dynamic_state_pool,
                                        sizeof(uint64_t), 8);
    *(uint64_t *)event->state.map = VK_EVENT_RESET;
@@ -4108,6 +4113,8 @@ void anv_DestroyEvent(
       return;
 
    anv_state_pool_free(&device->dynamic_state_pool, event->state);
+
+   vk_object_base_finish(&event->base);
    vk_free2(&device->vk.alloc, pAllocator, event);
 }
 
@@ -4172,6 +4179,7 @@ VkResult anv_CreateBuffer(
    if (buffer == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
+   vk_object_base_init(&device->vk, &buffer->base, VK_OBJECT_TYPE_BUFFER);
    buffer->size = pCreateInfo->size;
    buffer->usage = pCreateInfo->usage;
    buffer->address = ANV_NULL_ADDRESS;
@@ -4192,6 +4200,7 @@ void anv_DestroyBuffer(
    if (!buffer)
       return;
 
+   vk_object_base_finish(&buffer->base);
    vk_free2(&device->vk.alloc, pAllocator, buffer);
 }
 
@@ -4257,6 +4266,7 @@ void anv_DestroySampler(
                           sampler->bindless_state);
    }
 
+   vk_object_base_finish(&sampler->base);
    vk_free2(&device->vk.alloc, pAllocator, sampler);
 }
 
@@ -4299,6 +4309,9 @@ VkResult anv_CreateFramebuffer(
       framebuffer->attachment_count = 0;
    }
 
+   vk_object_base_init(&device->vk, &framebuffer->base,
+                       VK_OBJECT_TYPE_FRAMEBUFFER);
+
    framebuffer->width = pCreateInfo->width;
    framebuffer->height = pCreateInfo->height;
    framebuffer->layers = pCreateInfo->layers;
@@ -4319,6 +4332,7 @@ void anv_DestroyFramebuffer(
    if (!fb)
       return;
 
+   vk_object_base_finish(&fb->base);
    vk_free2(&device->vk.alloc, pAllocator, fb);
 }
 
index db1ea3f1818024c6d8d6b742ca6a96e0cda0df2a..a3d25ebc3e6475e2a1c8fea6138ed734129ada64 100644 (file)
@@ -1293,6 +1293,8 @@ VkResult anv_CreateSamplerYcbcrConversion(
 
    memset(conversion, 0, sizeof(*conversion));
 
+   vk_object_base_init(&device->vk, &conversion->base,
+                       VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION);
    conversion->format = anv_get_format(pCreateInfo->format);
    conversion->ycbcr_model = pCreateInfo->ycbcrModel;
    conversion->ycbcr_range = pCreateInfo->ycbcrRange;
@@ -1342,5 +1344,6 @@ void anv_DestroySamplerYcbcrConversion(
    if (!conversion)
       return;
 
+   vk_object_base_finish(&conversion->base);
    vk_free2(&device->vk.alloc, pAllocator, conversion);
 }
index 1f30ee128190de4fa47b2ac2103af68bf1673170..05b38f226616f3c7106cd05809c415bd1e73d0fa 100644 (file)
@@ -695,6 +695,7 @@ anv_image_create(VkDevice _device,
    if (!image)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
+   vk_object_base_init(&device->vk, &image->base, VK_OBJECT_TYPE_IMAGE);
    image->type = pCreateInfo->imageType;
    image->extent = pCreateInfo->extent;
    image->vk_format = pCreateInfo->format;
@@ -889,6 +890,7 @@ anv_DestroyImage(VkDevice _device, VkImage _image,
       }
    }
 
+   vk_object_base_finish(&image->base);
    vk_free2(&device->vk.alloc, pAllocator, image);
 }
 
@@ -1916,6 +1918,8 @@ anv_CreateImageView(VkDevice _device,
    if (iview == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
+   vk_object_base_init(&device->vk, &iview->base, VK_OBJECT_TYPE_IMAGE_VIEW);
+
    const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange;
 
    assert(range->layerCount > 0);
@@ -2190,6 +2194,7 @@ anv_CreateBufferView(VkDevice _device,
 
    /* TODO: Handle the format swizzle? */
 
+   vk_object_base_init(&device->vk, &view->base, VK_OBJECT_TYPE_BUFFER_VIEW);
    view->format = anv_get_isl_format(&device->info, pCreateInfo->format,
                                      VK_IMAGE_ASPECT_COLOR_BIT,
                                      VK_IMAGE_TILING_LINEAR);
@@ -2267,5 +2272,6 @@ anv_DestroyBufferView(VkDevice _device, VkBufferView bufferView,
       anv_state_pool_free(&device->surface_state_pool,
                           view->writeonly_storage_surface_state);
 
+   vk_object_base_finish(&view->base);
    vk_free2(&device->vk.alloc, pAllocator, view);
 }
index b100bec929d850c4d0fc9af475ef98801baf2678..3820cbfe5dd09496e8952b0514f2c0a1b0878d0e 100644 (file)
@@ -267,6 +267,7 @@ VkResult anv_CreateRenderPass(
     * each array member of anv_subpass must be a valid pointer if not NULL.
     */
    memset(pass, 0, ma.size);
+   vk_object_base_init(&device->vk, &pass->base, VK_OBJECT_TYPE_RENDER_PASS);
    pass->attachment_count = pCreateInfo->attachmentCount;
    pass->subpass_count = pCreateInfo->subpassCount;
    pass->attachments = attachments;
@@ -441,6 +442,7 @@ VkResult anv_CreateRenderPass2(
     * each array member of anv_subpass must be a valid pointer if not NULL.
     */
    memset(pass, 0, ma.size);
+   vk_object_base_init(&device->vk, &pass->base, VK_OBJECT_TYPE_RENDER_PASS);
    pass->attachment_count = pCreateInfo->attachmentCount;
    pass->subpass_count = pCreateInfo->subpassCount;
    pass->attachments = attachments;
@@ -591,6 +593,7 @@ void anv_DestroyRenderPass(
    ANV_FROM_HANDLE(anv_device, device, _device);
    ANV_FROM_HANDLE(anv_render_pass, pass, _pass);
 
+   vk_object_base_finish(&pass->base);
    vk_free2(&device->vk.alloc, pAllocator, pass);
 }
 
index d3bbd06e06142ed80f2061a7920fcd68bc31f501..88bc58f3771ce0b5feb591411f5a02e8109918e9 100644 (file)
@@ -61,6 +61,8 @@ VkResult anv_CreateShaderModule(
    if (module == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
+   vk_object_base_init(&device->vk, &module->base,
+                       VK_OBJECT_TYPE_SHADER_MODULE);
    module->size = pCreateInfo->codeSize;
    memcpy(module->data, pCreateInfo->pCode, module->size);
 
@@ -82,6 +84,7 @@ void anv_DestroyShaderModule(
    if (!module)
       return;
 
+   vk_object_base_finish(&module->base);
    vk_free2(&device->vk.alloc, pAllocator, module);
 }
 
@@ -340,6 +343,7 @@ void anv_DestroyPipeline(
       unreachable("invalid pipeline type");
    }
 
+   vk_object_base_finish(&pipeline->base);
    vk_free2(&device->vk.alloc, pAllocator, pipeline);
 }
 
@@ -1981,6 +1985,8 @@ anv_pipeline_init(struct anv_graphics_pipeline *pipeline,
    if (alloc == NULL)
       alloc = &device->vk.alloc;
 
+   vk_object_base_init(&device->vk, &pipeline->base.base,
+                       VK_OBJECT_TYPE_PIPELINE);
    pipeline->base.device = device;
    pipeline->base.type = ANV_PIPELINE_GRAPHICS;
 
index 39df5f1ded5add7fc0a822f8280ebab8bfecc81d..bdbca77bc0833a1c5fba508ae040518b5d902bc9 100644 (file)
@@ -282,6 +282,8 @@ anv_pipeline_cache_init(struct anv_pipeline_cache *cache,
                         struct anv_device *device,
                         bool cache_enabled)
 {
+   vk_object_base_init(&device->vk, &cache->base,
+                       VK_OBJECT_TYPE_PIPELINE_CACHE);
    cache->device = device;
    pthread_mutex_init(&cache->mutex, NULL);
 
@@ -318,6 +320,8 @@ anv_pipeline_cache_finish(struct anv_pipeline_cache *cache)
 
       _mesa_hash_table_destroy(cache->nir_cache, NULL);
    }
+
+   vk_object_base_finish(&cache->base);
 }
 
 static struct anv_shader_bin *
index e39b328cca3c3292a615cb606c011b3f09a75594..b778121951a19bef0a1b82d6a39313e86ba54f5b 100644 (file)
@@ -1007,7 +1007,7 @@ struct anv_memory_heap {
 };
 
 struct anv_physical_device {
-    VK_LOADER_DATA                              _loader_data;
+    struct vk_object_base                       base;
 
     /* Link in anv_instance::physical_devices */
     struct list_head                            link;
@@ -1100,7 +1100,7 @@ struct anv_app_info {
 };
 
 struct anv_instance {
-    VK_LOADER_DATA                              _loader_data;
+    struct vk_object_base                       base;
 
     VkAllocationCallbacks                       alloc;
 
@@ -1177,7 +1177,7 @@ struct anv_queue_submit {
 };
 
 struct anv_queue {
-    VK_LOADER_DATA                              _loader_data;
+    struct vk_object_base                       base;
 
     struct anv_device *                         device;
 
@@ -1190,6 +1190,7 @@ struct anv_queue {
 };
 
 struct anv_pipeline_cache {
+   struct vk_object_base                        base;
    struct anv_device *                          device;
    pthread_mutex_t                              mutex;
 
@@ -1727,6 +1728,8 @@ _anv_combine_address(struct anv_batch *batch, void *location,
          }))
 
 struct anv_device_memory {
+   struct vk_object_base                        base;
+
    struct list_head                             link;
 
    struct anv_bo *                              bo;
@@ -1880,6 +1883,8 @@ bool anv_descriptor_requires_bindless(const struct anv_physical_device *pdevice,
                                       bool sampler);
 
 struct anv_descriptor_set_layout {
+   struct vk_object_base base;
+
    /* Descriptor set layouts can be destroyed at almost any time */
    uint32_t ref_cnt;
 
@@ -1908,6 +1913,9 @@ struct anv_descriptor_set_layout {
    struct anv_descriptor_set_binding_layout binding[0];
 };
 
+void anv_descriptor_set_layout_destroy(struct anv_device *device,
+                                       struct anv_descriptor_set_layout *layout);
+
 static inline void
 anv_descriptor_set_layout_ref(struct anv_descriptor_set_layout *layout)
 {
@@ -1921,7 +1929,7 @@ anv_descriptor_set_layout_unref(struct anv_device *device,
 {
    assert(layout && layout->ref_cnt >= 1);
    if (p_atomic_dec_zero(&layout->ref_cnt))
-      vk_free(&device->vk.alloc, layout);
+      anv_descriptor_set_layout_destroy(device, layout);
 }
 
 struct anv_descriptor {
@@ -1945,6 +1953,8 @@ struct anv_descriptor {
 };
 
 struct anv_descriptor_set {
+   struct vk_object_base base;
+
    struct anv_descriptor_pool *pool;
    struct anv_descriptor_set_layout *layout;
    uint32_t size;
@@ -1964,6 +1974,8 @@ struct anv_descriptor_set {
 };
 
 struct anv_buffer_view {
+   struct vk_object_base base;
+
    enum isl_format format; /**< VkBufferViewCreateInfo::format */
    uint64_t range; /**< VkBufferViewCreateInfo::range */
 
@@ -1992,6 +2004,8 @@ struct anv_push_descriptor_set {
 };
 
 struct anv_descriptor_pool {
+   struct vk_object_base base;
+
    uint32_t size;
    uint32_t next;
    uint32_t free_list;
@@ -2034,6 +2048,8 @@ struct anv_descriptor_template_entry {
 };
 
 struct anv_descriptor_update_template {
+    struct vk_object_base base;
+
     VkPipelineBindPoint bind_point;
 
    /* The descriptor set this template corresponds to. This value is only
@@ -2164,6 +2180,8 @@ struct anv_push_range {
 };
 
 struct anv_pipeline_layout {
+   struct vk_object_base base;
+
    struct {
       struct anv_descriptor_set_layout *layout;
       uint32_t dynamic_offset_start;
@@ -2175,6 +2193,8 @@ struct anv_pipeline_layout {
 };
 
 struct anv_buffer {
+   struct vk_object_base                        base;
+
    struct anv_device *                          device;
    VkDeviceSize                                 size;
 
@@ -2764,6 +2784,7 @@ struct anv_cmd_state {
 };
 
 struct anv_cmd_pool {
+   struct vk_object_base                        base;
    VkAllocationCallbacks                        alloc;
    struct list_head                             cmd_buffers;
 };
@@ -2779,7 +2800,7 @@ enum anv_cmd_buffer_exec_mode {
 };
 
 struct anv_cmd_buffer {
-   VK_LOADER_DATA                               _loader_data;
+   struct vk_object_base                        base;
 
    struct anv_device *                          device;
 
@@ -2946,6 +2967,8 @@ struct anv_fence_impl {
 };
 
 struct anv_fence {
+   struct vk_object_base base;
+
    /* Permanent fence state.  Every fence has some form of permanent state
     * (type != ANV_SEMAPHORE_TYPE_NONE).  This may be a BO to fence on (for
     * cross-process fences) or it could just be a dummy for use internally.
@@ -2966,6 +2989,7 @@ void anv_fence_reset_temporary(struct anv_device *device,
                                struct anv_fence *fence);
 
 struct anv_event {
+   struct vk_object_base                        base;
    uint64_t                                     semaphore;
    struct anv_state                             state;
 };
@@ -3038,6 +3062,8 @@ struct anv_semaphore_impl {
 };
 
 struct anv_semaphore {
+   struct vk_object_base base;
+
    uint32_t refcount;
 
    /* Permanent semaphore state.  Every semaphore has some form of permanent
@@ -3061,6 +3087,8 @@ void anv_semaphore_reset_temporary(struct anv_device *device,
                                    struct anv_semaphore *semaphore);
 
 struct anv_shader_module {
+   struct vk_object_base                        base;
+
    unsigned char                                sha1[20];
    uint32_t                                     size;
    char                                         data[0];
@@ -3175,6 +3203,8 @@ enum anv_pipeline_type {
 };
 
 struct anv_pipeline {
+   struct vk_object_base                        base;
+
    struct anv_device *                          device;
 
    struct anv_batch                             batch;
@@ -3462,6 +3492,8 @@ struct anv_surface {
 };
 
 struct anv_image {
+   struct vk_object_base base;
+
    VkImageType type; /**< VkImageCreateInfo::imageType */
    /* The original VkFormat provided by the client.  This may not match any
     * of the actual surface formats.
@@ -3878,6 +3910,8 @@ anv_image_aspects_compatible(VkImageAspectFlags aspects1,
 }
 
 struct anv_image_view {
+   struct vk_object_base base;
+
    const struct anv_image *image; /**< VkImageViewCreateInfo::image */
 
    VkImageAspectFlags aspect_mask;
@@ -4018,6 +4052,8 @@ anv_clear_color_from_att_state(union isl_color_value *clear_color,
 
 
 struct anv_ycbcr_conversion {
+   struct vk_object_base base;
+
    const struct anv_format *        format;
    VkSamplerYcbcrModelConversion    ycbcr_model;
    VkSamplerYcbcrRange              ycbcr_range;
@@ -4028,6 +4064,8 @@ struct anv_ycbcr_conversion {
 };
 
 struct anv_sampler {
+   struct vk_object_base        base;
+
    uint32_t                     state[3][4];
    uint32_t                     n_planes;
    struct anv_ycbcr_conversion *conversion;
@@ -4039,6 +4077,8 @@ struct anv_sampler {
 };
 
 struct anv_framebuffer {
+   struct vk_object_base                        base;
+
    uint32_t                                     width;
    uint32_t                                     height;
    uint32_t                                     layers;
@@ -4112,6 +4152,8 @@ struct anv_render_pass_attachment {
 };
 
 struct anv_render_pass {
+   struct vk_object_base                        base;
+
    uint32_t                                     attachment_count;
    uint32_t                                     subpass_count;
    /* An array of subpass_count+1 flushes, one per subpass boundary */
@@ -4123,6 +4165,8 @@ struct anv_render_pass {
 #define ANV_PIPELINE_STATISTICS_MASK 0x000007ff
 
 struct anv_query_pool {
+   struct vk_object_base                        base;
+
    VkQueryType                                  type;
    VkQueryPipelineStatisticFlags                pipeline_statistics;
    /** Stride between slots, in bytes */
@@ -4244,7 +4288,6 @@ ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_render_pass, VkRenderPass)
 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_sampler, VkSampler)
 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_semaphore, VkSemaphore)
 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_shader_module, VkShaderModule)
-ANV_DEFINE_NONDISP_HANDLE_CASTS(vk_debug_report_callback, VkDebugReportCallbackEXT)
 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_ycbcr_conversion, VkSamplerYcbcrConversion)
 
 /* Gen-specific function declarations */
index c2229e9fd0a2d294a79a10435bca0afd13694072..ebe3216dd020135586a0b9c347ab7f54db04716b 100644 (file)
@@ -381,7 +381,7 @@ _anv_queue_submit(struct anv_queue *queue, struct anv_queue_submit **_submit,
 VkResult
 anv_queue_init(struct anv_device *device, struct anv_queue *queue)
 {
-   queue->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
+   vk_object_base_init(&device->vk, &queue->base, VK_OBJECT_TYPE_QUEUE);
    queue->device = device;
    queue->flags = 0;
 
@@ -393,6 +393,7 @@ anv_queue_init(struct anv_device *device, struct anv_queue *queue)
 void
 anv_queue_finish(struct anv_queue *queue)
 {
+   vk_object_base_finish(&queue->base);
 }
 
 static VkResult
@@ -1105,6 +1106,8 @@ VkResult anv_CreateFence(
    if (fence == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
+   vk_object_base_init(&device->vk, &fence->base, VK_OBJECT_TYPE_FENCE);
+
    if (device->physical->has_syncobj_wait) {
       fence->permanent.type = ANV_FENCE_TYPE_SYNCOBJ;
 
@@ -1191,6 +1194,7 @@ void anv_DestroyFence(
    anv_fence_impl_cleanup(device, &fence->temporary);
    anv_fence_impl_cleanup(device, &fence->permanent);
 
+   vk_object_base_finish(&fence->base);
    vk_free2(&device->vk.alloc, pAllocator, fence);
 }
 
@@ -1787,6 +1791,8 @@ VkResult anv_CreateSemaphore(
    if (semaphore == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
+   vk_object_base_init(&device->vk, &semaphore->base, VK_OBJECT_TYPE_SEMAPHORE);
+
    p_atomic_set(&semaphore->refcount, 1);
 
    const VkExportSemaphoreCreateInfo *export =
@@ -1900,6 +1906,8 @@ anv_semaphore_unref(struct anv_device *device, struct anv_semaphore *semaphore)
 
    anv_semaphore_impl_cleanup(device, &semaphore->temporary);
    anv_semaphore_impl_cleanup(device, &semaphore->permanent);
+
+   vk_object_base_finish(&semaphore->base);
    vk_free(&device->vk.alloc, semaphore);
 }
 
index 82d6793e66a8f7b36e33ab56d7a2ab642c68b3c6..f3f9333cc76a2f105afcc791c4e913b86af67492 100644 (file)
@@ -2279,6 +2279,8 @@ compute_pipeline_create(
    if (pipeline == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
+   vk_object_base_init(&device->vk, &pipeline->base.base,
+                       VK_OBJECT_TYPE_PIPELINE);
    pipeline->base.device = device;
    pipeline->base.type = ANV_PIPELINE_COMPUTE;
 
index d5d6d6e2f910585d144d1830aa0c0442218726cb..c5009445d38dbeeacfd3e195918a31fbf4e03716 100644 (file)
@@ -106,6 +106,7 @@ VkResult genX(CreateQueryPool)(
    if (pool == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
+   vk_object_base_init(&device->vk, &pool->base, VK_OBJECT_TYPE_QUERY_POOL);
    pool->type = pCreateInfo->queryType;
    pool->pipeline_statistics = pipeline_statistics;
    pool->stride = uint64s_per_slot * sizeof(uint64_t);
@@ -152,6 +153,7 @@ void genX(DestroyQueryPool)(
       return;
 
    anv_device_release_bo(device, pool->bo);
+   vk_object_base_finish(&pool->base);
    vk_free2(&device->vk.alloc, pAllocator, pool);
 }
 
index fd87954d1003b648234f3b2ff97c5db6161b285a..ea953b7842b1f5005a94083a08bddf82ec125ae6 100644 (file)
@@ -363,6 +363,7 @@ VkResult genX(CreateSampler)(
    if (!sampler)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
+   vk_object_base_init(&device->vk, &sampler->base, VK_OBJECT_TYPE_SAMPLER);
    sampler->n_planes = 1;
 
    uint32_t border_color_stride = GEN_IS_HASWELL ? 512 : 64;
index 77258ab6879564ab130041edcc0258dc314ce58f..d696515891421a538552dbf6f9ba4c5b92002d86 100644 (file)
 
 #include "vk_object.h"
 
+void
+vk_object_base_init(UNUSED struct vk_device *device,
+                    struct vk_object_base *base,
+                    UNUSED VkObjectType obj_type)
+{
+   base->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
+}
+
+void
+vk_object_base_finish(UNUSED struct vk_object_base *base)
+{
+}
+
 void
 vk_device_init(struct vk_device *device,
                UNUSED const VkDeviceCreateInfo *pCreateInfo,
                const VkAllocationCallbacks *instance_alloc,
                const VkAllocationCallbacks *device_alloc)
 {
-   device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
+   vk_object_base_init(device, &device->base, VK_OBJECT_TYPE_DEVICE);
    if (device_alloc)
       device->alloc = *device_alloc;
    else
@@ -39,4 +52,5 @@ vk_device_init(struct vk_device *device,
 void
 vk_device_finish(UNUSED struct vk_device *device)
 {
+   vk_object_base_finish(&device->base);
 }
index 8fc42b862da08a08e0834b53a30ae12f578410cb..c2b3926133e61cc4d2a01a0f98d1f64e36d3f96e 100644 (file)
 extern "C" {
 #endif
 
-struct vk_device {
+struct vk_device;
+
+struct vk_object_base {
    VK_LOADER_DATA _loader_data;
+};
+
+void vk_object_base_init(UNUSED struct vk_device *device,
+                         struct vk_object_base *base,
+                         UNUSED VkObjectType obj_type);
+void vk_object_base_finish(UNUSED struct vk_object_base *base);
+
+
+struct vk_device {
+   struct vk_object_base base;
    VkAllocationCallbacks alloc;
 };