radv: use the base object struct types

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4886>
This commit is contained in:
Samuel Pitoiset 2020-04-29 14:57:20 +02:00
parent 65458528fc
commit 178adfa6a8
12 changed files with 138 additions and 7 deletions

View file

@ -277,7 +277,9 @@ static VkResult radv_create_cmd_buffer(
if (cmd_buffer == NULL) if (cmd_buffer == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
cmd_buffer->_loader_data.loaderMagic = ICD_LOADER_MAGIC; vk_object_base_init(&device->vk, &cmd_buffer->base,
VK_OBJECT_TYPE_COMMAND_BUFFER);
cmd_buffer->device = device; cmd_buffer->device = device;
cmd_buffer->pool = pool; cmd_buffer->pool = pool;
cmd_buffer->level = level; cmd_buffer->level = level;
@ -328,6 +330,8 @@ radv_cmd_buffer_destroy(struct radv_cmd_buffer *cmd_buffer)
for (unsigned i = 0; i < MAX_BIND_POINTS; i++) for (unsigned i = 0; i < MAX_BIND_POINTS; i++)
free(cmd_buffer->descriptors[i].push_set.set.mapped_ptr); free(cmd_buffer->descriptors[i].push_set.set.mapped_ptr);
vk_object_base_finish(&cmd_buffer->base);
vk_free(&cmd_buffer->pool->alloc, cmd_buffer); vk_free(&cmd_buffer->pool->alloc, cmd_buffer);
} }
@ -3318,7 +3322,6 @@ VkResult radv_AllocateCommandBuffers(
list_addtail(&cmd_buffer->pool_link, &pool->cmd_buffers); list_addtail(&cmd_buffer->pool_link, &pool->cmd_buffers);
result = radv_reset_cmd_buffer(cmd_buffer); result = radv_reset_cmd_buffer(cmd_buffer);
cmd_buffer->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
cmd_buffer->level = pAllocateInfo->level; cmd_buffer->level = pAllocateInfo->level;
pCommandBuffers[i] = radv_cmd_buffer_to_handle(cmd_buffer); pCommandBuffers[i] = radv_cmd_buffer_to_handle(cmd_buffer);
@ -4261,6 +4264,9 @@ VkResult radv_CreateCommandPool(
if (pool == NULL) if (pool == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &pool->base,
VK_OBJECT_TYPE_COMMAND_POOL);
if (pAllocator) if (pAllocator)
pool->alloc = *pAllocator; pool->alloc = *pAllocator;
else else
@ -4298,6 +4304,7 @@ void radv_DestroyCommandPool(
radv_cmd_buffer_destroy(cmd_buffer); radv_cmd_buffer_destroy(cmd_buffer);
} }
vk_object_base_finish(&pool->base);
vk_free2(&device->vk.alloc, pAllocator, pool); vk_free2(&device->vk.alloc, pAllocator, pool);
} }

View file

@ -114,6 +114,9 @@ VkResult radv_CreateDescriptorSetLayout(
if (!set_layout) if (!set_layout)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &set_layout->base,
VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT);
set_layout->flags = pCreateInfo->flags; set_layout->flags = pCreateInfo->flags;
set_layout->layout_size = size; set_layout->layout_size = size;
@ -132,6 +135,7 @@ VkResult radv_CreateDescriptorSetLayout(
VkDescriptorSetLayoutBinding *bindings = create_sorted_bindings(pCreateInfo->pBindings, VkDescriptorSetLayoutBinding *bindings = create_sorted_bindings(pCreateInfo->pBindings,
pCreateInfo->bindingCount); pCreateInfo->bindingCount);
if (!bindings) { if (!bindings) {
vk_object_base_finish(&set_layout->base);
vk_free2(&device->vk.alloc, pAllocator, set_layout); vk_free2(&device->vk.alloc, pAllocator, set_layout);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
} }
@ -295,6 +299,7 @@ void radv_DestroyDescriptorSetLayout(
if (!set_layout) if (!set_layout)
return; return;
vk_object_base_finish(&set_layout->base);
vk_free2(&device->vk.alloc, pAllocator, set_layout); vk_free2(&device->vk.alloc, pAllocator, set_layout);
} }
@ -413,6 +418,9 @@ VkResult radv_CreatePipelineLayout(
if (layout == NULL) if (layout == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &layout->base,
VK_OBJECT_TYPE_PIPELINE_LAYOUT);
layout->num_sets = pCreateInfo->setLayoutCount; layout->num_sets = pCreateInfo->setLayoutCount;
unsigned dynamic_offset_count = 0; unsigned dynamic_offset_count = 0;
@ -462,6 +470,8 @@ void radv_DestroyPipelineLayout(
if (!pipeline_layout) if (!pipeline_layout)
return; return;
vk_object_base_finish(&pipeline_layout->base);
vk_free2(&device->vk.alloc, pAllocator, pipeline_layout); vk_free2(&device->vk.alloc, pAllocator, pipeline_layout);
} }
@ -505,6 +515,9 @@ radv_descriptor_set_create(struct radv_device *device,
memset(set, 0, mem_size); memset(set, 0, mem_size);
vk_object_base_init(&device->vk, &set->base,
VK_OBJECT_TYPE_DESCRIPTOR_SET);
if (layout->dynamic_offset_count) { if (layout->dynamic_offset_count) {
set->dynamic_descriptors = (struct radv_descriptor_range*)((uint8_t*)set + range_offset); set->dynamic_descriptors = (struct radv_descriptor_range*)((uint8_t*)set + range_offset);
} }
@ -612,6 +625,7 @@ radv_descriptor_set_destroy(struct radv_device *device,
} }
} }
} }
vk_object_base_finish(&set->base);
vk_free2(&device->vk.alloc, NULL, set); vk_free2(&device->vk.alloc, NULL, set);
} }
@ -691,6 +705,9 @@ VkResult radv_CreateDescriptorPool(
memset(pool, 0, sizeof(*pool)); memset(pool, 0, sizeof(*pool));
vk_object_base_init(&device->vk, &pool->base,
VK_OBJECT_TYPE_DESCRIPTOR_POOL);
if (!(pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) { if (!(pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) {
pool->host_memory_base = (uint8_t*)pool + sizeof(struct radv_descriptor_pool); pool->host_memory_base = (uint8_t*)pool + sizeof(struct radv_descriptor_pool);
pool->host_memory_ptr = pool->host_memory_base; pool->host_memory_ptr = pool->host_memory_base;
@ -732,6 +749,8 @@ void radv_DestroyDescriptorPool(
if (pool->bo) if (pool->bo)
device->ws->buffer_destroy(pool->bo); device->ws->buffer_destroy(pool->bo);
vk_object_base_finish(&pool->base);
vk_free2(&device->vk.alloc, pAllocator, pool); vk_free2(&device->vk.alloc, pAllocator, pool);
} }
@ -1183,6 +1202,9 @@ VkResult radv_CreateDescriptorUpdateTemplate(VkDevice _device,
if (!templ) if (!templ)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &templ->base,
VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE);
templ->entry_count = entry_count; templ->entry_count = entry_count;
if (pCreateInfo->templateType == VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR) { if (pCreateInfo->templateType == VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR) {
@ -1266,6 +1288,7 @@ void radv_DestroyDescriptorUpdateTemplate(VkDevice _device,
if (!templ) if (!templ)
return; return;
vk_object_base_finish(&templ->base);
vk_free2(&device->vk.alloc, pAllocator, templ); vk_free2(&device->vk.alloc, pAllocator, templ);
} }
@ -1368,6 +1391,9 @@ VkResult radv_CreateSamplerYcbcrConversion(VkDevice _device,
if (conversion == NULL) if (conversion == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &conversion->base,
VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION);
conversion->format = pCreateInfo->format; conversion->format = pCreateInfo->format;
conversion->ycbcr_model = pCreateInfo->ycbcrModel; conversion->ycbcr_model = pCreateInfo->ycbcrModel;
conversion->ycbcr_range = pCreateInfo->ycbcrRange; conversion->ycbcr_range = pCreateInfo->ycbcrRange;
@ -1388,6 +1414,9 @@ void radv_DestroySamplerYcbcrConversion(VkDevice _device,
RADV_FROM_HANDLE(radv_device, device, _device); RADV_FROM_HANDLE(radv_device, device, _device);
RADV_FROM_HANDLE(radv_sampler_ycbcr_conversion, ycbcr_conversion, ycbcrConversion); RADV_FROM_HANDLE(radv_sampler_ycbcr_conversion, ycbcr_conversion, ycbcrConversion);
if (ycbcr_conversion) if (!ycbcr_conversion)
vk_free2(&device->vk.alloc, pAllocator, ycbcr_conversion); return;
vk_object_base_finish(&ycbcr_conversion->base);
vk_free2(&device->vk.alloc, pAllocator, ycbcr_conversion);
} }

View file

@ -26,6 +26,8 @@
#include "radv_constants.h" #include "radv_constants.h"
#include "vulkan/util/vk_object.h"
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
struct radv_descriptor_set_binding_layout { struct radv_descriptor_set_binding_layout {
@ -49,6 +51,8 @@ struct radv_descriptor_set_binding_layout {
}; };
struct radv_descriptor_set_layout { struct radv_descriptor_set_layout {
struct vk_object_base base;
/* The create flags for this descriptor set layout */ /* The create flags for this descriptor set layout */
VkDescriptorSetLayoutCreateFlags flags; VkDescriptorSetLayoutCreateFlags flags;
@ -81,6 +85,7 @@ struct radv_descriptor_set_layout {
}; };
struct radv_pipeline_layout { struct radv_pipeline_layout {
struct vk_object_base base;
struct { struct {
struct radv_descriptor_set_layout *layout; struct radv_descriptor_set_layout *layout;
uint32_t size; uint32_t size;

View file

@ -606,7 +606,7 @@ VkResult radv_CreateInstance(
if (!instance) if (!instance)
return vk_error(NULL, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(NULL, 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) if (pAllocator)
instance->alloc = *pAllocator; instance->alloc = *pAllocator;
@ -755,6 +755,7 @@ void radv_DestroyInstance(
vk_debug_report_instance_destroy(&instance->debug_report_callbacks); vk_debug_report_instance_destroy(&instance->debug_report_callbacks);
vk_object_base_finish(&instance->base);
vk_free(&instance->alloc, instance); vk_free(&instance->alloc, instance);
} }
@ -5100,6 +5101,7 @@ static void radv_free_memory(struct radv_device *device,
mem->bo = NULL; mem->bo = NULL;
} }
vk_object_base_finish(&mem->base);
vk_free2(&device->vk.alloc, pAllocator, mem); vk_free2(&device->vk.alloc, pAllocator, mem);
} }
@ -5142,6 +5144,9 @@ static VkResult radv_alloc_memory(struct radv_device *device,
if (mem == NULL) if (mem == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &mem->base,
VK_OBJECT_TYPE_DEVICE_MEMORY);
if (wsi_info && wsi_info->implicit_sync) if (wsi_info && wsi_info->implicit_sync)
flags |= RADEON_FLAG_IMPLICIT_SYNC; flags |= RADEON_FLAG_IMPLICIT_SYNC;
@ -5601,6 +5606,8 @@ VkResult radv_CreateFence(
if (!fence) if (!fence)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &fence->base, VK_OBJECT_TYPE_FENCE);
fence->fence_wsi = NULL; fence->fence_wsi = NULL;
fence->temp_syncobj = 0; fence->temp_syncobj = 0;
if (device->always_use_syncobj || handleTypes) { if (device->always_use_syncobj || handleTypes) {
@ -5648,6 +5655,8 @@ void radv_DestroyFence(
device->ws->destroy_fence(fence->fence); device->ws->destroy_fence(fence->fence);
if (fence->fence_wsi) if (fence->fence_wsi)
fence->fence_wsi->destroy(fence->fence_wsi); fence->fence_wsi->destroy(fence->fence_wsi);
vk_object_base_finish(&fence->base);
vk_free2(&device->vk.alloc, pAllocator, fence); vk_free2(&device->vk.alloc, pAllocator, fence);
} }
@ -6066,6 +6075,9 @@ VkResult radv_CreateSemaphore(
if (!sem) if (!sem)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &sem->base,
VK_OBJECT_TYPE_SEMAPHORE);
sem->temporary.kind = RADV_SEMAPHORE_NONE; sem->temporary.kind = RADV_SEMAPHORE_NONE;
sem->permanent.kind = RADV_SEMAPHORE_NONE; sem->permanent.kind = RADV_SEMAPHORE_NONE;
@ -6105,6 +6117,7 @@ void radv_DestroySemaphore(
radv_destroy_semaphore_part(device, &sem->temporary); radv_destroy_semaphore_part(device, &sem->temporary);
radv_destroy_semaphore_part(device, &sem->permanent); radv_destroy_semaphore_part(device, &sem->permanent);
vk_object_base_finish(&sem->base);
vk_free2(&device->vk.alloc, pAllocator, sem); vk_free2(&device->vk.alloc, pAllocator, sem);
} }
@ -6226,6 +6239,8 @@ VkResult radv_CreateEvent(
if (!event) if (!event)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &event->base, VK_OBJECT_TYPE_EVENT);
event->bo = device->ws->buffer_create(device->ws, 8, 8, event->bo = device->ws->buffer_create(device->ws, 8, 8,
RADEON_DOMAIN_GTT, RADEON_DOMAIN_GTT,
RADEON_FLAG_VA_UNCACHED | RADEON_FLAG_CPU_ACCESS | RADEON_FLAG_NO_INTERPROCESS_SHARING, RADEON_FLAG_VA_UNCACHED | RADEON_FLAG_CPU_ACCESS | RADEON_FLAG_NO_INTERPROCESS_SHARING,
@ -6253,6 +6268,7 @@ void radv_DestroyEvent(
if (!event) if (!event)
return; return;
device->ws->buffer_destroy(event->bo); device->ws->buffer_destroy(event->bo);
vk_object_base_finish(&event->base);
vk_free2(&device->vk.alloc, pAllocator, event); vk_free2(&device->vk.alloc, pAllocator, event);
} }
@ -6306,6 +6322,8 @@ VkResult radv_CreateBuffer(
if (buffer == NULL) if (buffer == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &buffer->base, VK_OBJECT_TYPE_BUFFER);
buffer->size = pCreateInfo->size; buffer->size = pCreateInfo->size;
buffer->usage = pCreateInfo->usage; buffer->usage = pCreateInfo->usage;
buffer->bo = NULL; buffer->bo = NULL;
@ -6345,6 +6363,7 @@ void radv_DestroyBuffer(
if (buffer->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) if (buffer->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT)
device->ws->buffer_destroy(buffer->bo); device->ws->buffer_destroy(buffer->bo);
vk_object_base_finish(&buffer->base);
vk_free2(&device->vk.alloc, pAllocator, buffer); vk_free2(&device->vk.alloc, pAllocator, buffer);
} }
@ -6914,6 +6933,9 @@ VkResult radv_CreateFramebuffer(
if (framebuffer == NULL) if (framebuffer == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &framebuffer->base,
VK_OBJECT_TYPE_FRAMEBUFFER);
framebuffer->attachment_count = pCreateInfo->attachmentCount; framebuffer->attachment_count = pCreateInfo->attachmentCount;
framebuffer->width = pCreateInfo->width; framebuffer->width = pCreateInfo->width;
framebuffer->height = pCreateInfo->height; framebuffer->height = pCreateInfo->height;
@ -6951,6 +6973,7 @@ void radv_DestroyFramebuffer(
if (!fb) if (!fb)
return; return;
vk_object_base_finish(&fb->base);
vk_free2(&device->vk.alloc, pAllocator, fb); vk_free2(&device->vk.alloc, pAllocator, fb);
} }
@ -7172,6 +7195,9 @@ VkResult radv_CreateSampler(
if (!sampler) if (!sampler)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &sampler->base,
VK_OBJECT_TYPE_SAMPLER);
radv_init_sampler(device, sampler, pCreateInfo); radv_init_sampler(device, sampler, pCreateInfo);
sampler->ycbcr_sampler = ycbcr_conversion ? radv_sampler_ycbcr_conversion_from_handle(ycbcr_conversion->conversion): NULL; sampler->ycbcr_sampler = ycbcr_conversion ? radv_sampler_ycbcr_conversion_from_handle(ycbcr_conversion->conversion): NULL;
@ -7190,6 +7216,7 @@ void radv_DestroySampler(
if (!sampler) if (!sampler)
return; return;
vk_object_base_finish(&sampler->base);
vk_free2(&device->vk.alloc, pAllocator, sampler); vk_free2(&device->vk.alloc, pAllocator, sampler);
} }

View file

@ -1449,6 +1449,8 @@ radv_image_create(VkDevice _device,
if (!image) if (!image)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &image->base, VK_OBJECT_TYPE_IMAGE);
image->type = pCreateInfo->imageType; image->type = pCreateInfo->imageType;
image->info.width = pCreateInfo->extent.width; image->info.width = pCreateInfo->extent.width;
image->info.height = pCreateInfo->extent.height; image->info.height = pCreateInfo->extent.height;
@ -1844,6 +1846,7 @@ radv_DestroyImage(VkDevice _device, VkImage _image,
if (image->owned_memory != VK_NULL_HANDLE) if (image->owned_memory != VK_NULL_HANDLE)
radv_FreeMemory(_device, image->owned_memory, pAllocator); radv_FreeMemory(_device, image->owned_memory, pAllocator);
vk_object_base_finish(&image->base);
vk_free2(&device->vk.alloc, pAllocator, image); vk_free2(&device->vk.alloc, pAllocator, image);
} }
@ -1913,6 +1916,9 @@ radv_CreateImageView(VkDevice _device,
if (view == NULL) if (view == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &view->base,
VK_OBJECT_TYPE_IMAGE_VIEW);
radv_image_view_init(view, device, pCreateInfo, NULL); radv_image_view_init(view, device, pCreateInfo, NULL);
*pView = radv_image_view_to_handle(view); *pView = radv_image_view_to_handle(view);
@ -1929,6 +1935,8 @@ radv_DestroyImageView(VkDevice _device, VkImageView _iview,
if (!iview) if (!iview)
return; return;
vk_object_base_finish(&iview->base);
vk_free2(&device->vk.alloc, pAllocator, iview); vk_free2(&device->vk.alloc, pAllocator, iview);
} }
@ -1961,6 +1969,9 @@ radv_CreateBufferView(VkDevice _device,
if (!view) if (!view)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &view->base,
VK_OBJECT_TYPE_BUFFER_VIEW);
radv_buffer_view_init(view, device, pCreateInfo); radv_buffer_view_init(view, device, pCreateInfo);
*pView = radv_buffer_view_to_handle(view); *pView = radv_buffer_view_to_handle(view);
@ -1978,5 +1989,6 @@ radv_DestroyBufferView(VkDevice _device, VkBufferView bufferView,
if (!view) if (!view)
return; return;
vk_object_base_finish(&view->base);
vk_free2(&device->vk.alloc, pAllocator, view); vk_free2(&device->vk.alloc, pAllocator, view);
} }

View file

@ -325,6 +325,10 @@ VkResult radv_CreateRenderPass(
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
memset(pass, 0, size); memset(pass, 0, size);
vk_object_base_init(&device->vk, &pass->base,
VK_OBJECT_TYPE_RENDER_PASS);
pass->attachment_count = pCreateInfo->attachmentCount; pass->attachment_count = pCreateInfo->attachmentCount;
pass->subpass_count = pCreateInfo->subpassCount; pass->subpass_count = pCreateInfo->subpassCount;
pass->attachments = (void *) pass + attachments_offset; pass->attachments = (void *) pass + attachments_offset;
@ -507,6 +511,10 @@ VkResult radv_CreateRenderPass2(
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
memset(pass, 0, size); memset(pass, 0, size);
vk_object_base_init(&device->vk, &pass->base,
VK_OBJECT_TYPE_RENDER_PASS);
pass->attachment_count = pCreateInfo->attachmentCount; pass->attachment_count = pCreateInfo->attachmentCount;
pass->subpass_count = pCreateInfo->subpassCount; pass->subpass_count = pCreateInfo->subpassCount;
pass->attachments = (void *) pass + attachments_offset; pass->attachments = (void *) pass + attachments_offset;
@ -681,6 +689,8 @@ void radv_DestroyRenderPass(
if (!_pass) if (!_pass)
return; return;
vk_object_base_finish(&pass->base);
vk_free2(&device->vk.alloc, pAllocator, pass->subpass_attachments); vk_free2(&device->vk.alloc, pAllocator, pass->subpass_attachments);
vk_free2(&device->vk.alloc, pAllocator, pass); vk_free2(&device->vk.alloc, pAllocator, pass);
} }

View file

@ -191,6 +191,8 @@ radv_pipeline_destroy(struct radv_device *device,
if(pipeline->cs.buf) if(pipeline->cs.buf)
free(pipeline->cs.buf); free(pipeline->cs.buf);
vk_object_base_finish(&pipeline->base);
vk_free2(&device->vk.alloc, allocator, pipeline); vk_free2(&device->vk.alloc, allocator, pipeline);
} }
@ -5265,6 +5267,9 @@ radv_graphics_pipeline_create(
if (pipeline == NULL) if (pipeline == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &pipeline->base,
VK_OBJECT_TYPE_PIPELINE);
result = radv_pipeline_init(pipeline, device, cache, result = radv_pipeline_init(pipeline, device, cache,
pCreateInfo, extra); pCreateInfo, extra);
if (result != VK_SUCCESS) { if (result != VK_SUCCESS) {
@ -5403,6 +5408,9 @@ static VkResult radv_compute_pipeline_create(
if (pipeline == NULL) if (pipeline == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &pipeline->base,
VK_OBJECT_TYPE_PIPELINE);
pipeline->device = device; pipeline->device = device;
pipeline->layout = radv_pipeline_layout_from_handle(pCreateInfo->layout); pipeline->layout = radv_pipeline_layout_from_handle(pCreateInfo->layout);
assert(pipeline->layout); assert(pipeline->layout);

View file

@ -578,6 +578,9 @@ VkResult radv_CreatePipelineCache(
if (cache == NULL) if (cache == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &cache->base,
VK_OBJECT_TYPE_PIPELINE_CACHE);
if (pAllocator) if (pAllocator)
cache->alloc = *pAllocator; cache->alloc = *pAllocator;
else else
@ -608,6 +611,7 @@ void radv_DestroyPipelineCache(
return; return;
radv_pipeline_cache_finish(cache); radv_pipeline_cache_finish(cache);
vk_object_base_finish(&cache->base);
vk_free2(&device->vk.alloc, pAllocator, cache); vk_free2(&device->vk.alloc, pAllocator, cache);
} }

View file

@ -341,7 +341,7 @@ struct radv_physical_device {
}; };
struct radv_instance { struct radv_instance {
VK_LOADER_DATA _loader_data; struct vk_object_base base;
VkAllocationCallbacks alloc; VkAllocationCallbacks alloc;
@ -385,6 +385,7 @@ bool radv_physical_device_extension_supported(struct radv_physical_device *dev,
struct cache_entry; struct cache_entry;
struct radv_pipeline_cache { struct radv_pipeline_cache {
struct vk_object_base base;
struct radv_device * device; struct radv_device * device;
pthread_mutex_t mutex; pthread_mutex_t mutex;
@ -871,6 +872,7 @@ struct radv_device {
}; };
struct radv_device_memory { struct radv_device_memory {
struct vk_object_base base;
struct radeon_winsys_bo *bo; struct radeon_winsys_bo *bo;
/* for dedicated allocations */ /* for dedicated allocations */
struct radv_image *image; struct radv_image *image;
@ -892,6 +894,7 @@ struct radv_descriptor_range {
}; };
struct radv_descriptor_set { struct radv_descriptor_set {
struct vk_object_base base;
const struct radv_descriptor_set_layout *layout; const struct radv_descriptor_set_layout *layout;
uint32_t size; uint32_t size;
uint32_t buffer_count; uint32_t buffer_count;
@ -917,6 +920,7 @@ struct radv_descriptor_pool_entry {
}; };
struct radv_descriptor_pool { struct radv_descriptor_pool {
struct vk_object_base base;
struct radeon_winsys_bo *bo; struct radeon_winsys_bo *bo;
uint8_t *mapped_ptr; uint8_t *mapped_ptr;
uint64_t current_offset; uint64_t current_offset;
@ -958,12 +962,14 @@ struct radv_descriptor_update_template_entry {
}; };
struct radv_descriptor_update_template { struct radv_descriptor_update_template {
struct vk_object_base base;
uint32_t entry_count; uint32_t entry_count;
VkPipelineBindPoint bind_point; VkPipelineBindPoint bind_point;
struct radv_descriptor_update_template_entry entry[0]; struct radv_descriptor_update_template_entry entry[0];
}; };
struct radv_buffer { struct radv_buffer {
struct vk_object_base base;
VkDeviceSize size; VkDeviceSize size;
VkBufferUsageFlags usage; VkBufferUsageFlags usage;
@ -1316,6 +1322,7 @@ struct radv_cmd_state {
}; };
struct radv_cmd_pool { struct radv_cmd_pool {
struct vk_object_base base;
VkAllocationCallbacks alloc; VkAllocationCallbacks alloc;
struct list_head cmd_buffers; struct list_head cmd_buffers;
struct list_head free_cmd_buffers; struct list_head free_cmd_buffers;
@ -1339,7 +1346,7 @@ enum radv_cmd_buffer_status {
}; };
struct radv_cmd_buffer { struct radv_cmd_buffer {
VK_LOADER_DATA _loader_data; struct vk_object_base base;
struct radv_device * device; struct radv_device * device;
@ -1553,6 +1560,7 @@ void radv_unaligned_dispatch(
uint32_t z); uint32_t z);
struct radv_event { struct radv_event {
struct vk_object_base base;
struct radeon_winsys_bo *bo; struct radeon_winsys_bo *bo;
uint64_t *map; uint64_t *map;
}; };
@ -1632,6 +1640,7 @@ struct radv_binning_state {
#define SI_GS_PER_ES 128 #define SI_GS_PER_ES 128
struct radv_pipeline { struct radv_pipeline {
struct vk_object_base base;
struct radv_device * device; struct radv_device * device;
struct radv_dynamic_state dynamic_state; struct radv_dynamic_state dynamic_state;
@ -1768,6 +1777,7 @@ struct radv_image_plane {
}; };
struct radv_image { struct radv_image {
struct vk_object_base base;
VkImageType type; VkImageType type;
/* The original VkFormat provided by the client. This may not match any /* The original VkFormat provided by the client. This may not match any
* of the actual surface formats. * of the actual surface formats.
@ -2006,6 +2016,7 @@ union radv_descriptor {
}; };
struct radv_image_view { struct radv_image_view {
struct vk_object_base base;
struct radv_image *image; /**< VkImageViewCreateInfo::image */ struct radv_image *image; /**< VkImageViewCreateInfo::image */
struct radeon_winsys_bo *bo; struct radeon_winsys_bo *bo;
@ -2084,6 +2095,7 @@ void radv_image_view_init(struct radv_image_view *view,
VkFormat radv_get_aspect_format(struct radv_image *image, VkImageAspectFlags mask); VkFormat radv_get_aspect_format(struct radv_image *image, VkImageAspectFlags mask);
struct radv_sampler_ycbcr_conversion { struct radv_sampler_ycbcr_conversion {
struct vk_object_base base;
VkFormat format; VkFormat format;
VkSamplerYcbcrModelConversion ycbcr_model; VkSamplerYcbcrModelConversion ycbcr_model;
VkSamplerYcbcrRange ycbcr_range; VkSamplerYcbcrRange ycbcr_range;
@ -2093,6 +2105,7 @@ struct radv_sampler_ycbcr_conversion {
}; };
struct radv_buffer_view { struct radv_buffer_view {
struct vk_object_base base;
struct radeon_winsys_bo *bo; struct radeon_winsys_bo *bo;
VkFormat vk_format; VkFormat vk_format;
uint64_t range; /**< VkBufferViewCreateInfo::range */ uint64_t range; /**< VkBufferViewCreateInfo::range */
@ -2146,11 +2159,13 @@ radv_image_extent_compare(const struct radv_image *image,
} }
struct radv_sampler { struct radv_sampler {
struct vk_object_base base;
uint32_t state[4]; uint32_t state[4];
struct radv_sampler_ycbcr_conversion *ycbcr_sampler; struct radv_sampler_ycbcr_conversion *ycbcr_sampler;
}; };
struct radv_framebuffer { struct radv_framebuffer {
struct vk_object_base base;
uint32_t width; uint32_t width;
uint32_t height; uint32_t height;
uint32_t layers; uint32_t layers;
@ -2223,6 +2238,7 @@ struct radv_render_pass_attachment {
}; };
struct radv_render_pass { struct radv_render_pass {
struct vk_object_base base;
uint32_t attachment_count; uint32_t attachment_count;
uint32_t subpass_count; uint32_t subpass_count;
struct radv_subpass_attachment * subpass_attachments; struct radv_subpass_attachment * subpass_attachments;
@ -2235,6 +2251,7 @@ VkResult radv_device_init_meta(struct radv_device *device);
void radv_device_finish_meta(struct radv_device *device); void radv_device_finish_meta(struct radv_device *device);
struct radv_query_pool { struct radv_query_pool {
struct vk_object_base base;
struct radeon_winsys_bo *bo; struct radeon_winsys_bo *bo;
uint32_t stride; uint32_t stride;
uint32_t availability_offset; uint32_t availability_offset;
@ -2298,6 +2315,7 @@ struct radv_semaphore_part {
}; };
struct radv_semaphore { struct radv_semaphore {
struct vk_object_base base;
struct radv_semaphore_part permanent; struct radv_semaphore_part permanent;
struct radv_semaphore_part temporary; struct radv_semaphore_part temporary;
}; };
@ -2342,6 +2360,7 @@ void radv_initialize_fmask(struct radv_cmd_buffer *cmd_buffer,
const VkImageSubresourceRange *range); const VkImageSubresourceRange *range);
struct radv_fence { struct radv_fence {
struct vk_object_base base;
struct radeon_winsys_fence *fence; struct radeon_winsys_fence *fence;
struct wsi_fence *fence_wsi; struct wsi_fence *fence_wsi;

View file

@ -1283,6 +1283,8 @@ VkResult radv_CreateQueryPool(
if (!pool) if (!pool)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &pool->base,
VK_OBJECT_TYPE_QUERY_POOL);
switch(pCreateInfo->queryType) { switch(pCreateInfo->queryType) {
case VK_QUERY_TYPE_OCCLUSION: case VK_QUERY_TYPE_OCCLUSION:
@ -1341,6 +1343,8 @@ void radv_DestroyQueryPool(
return; return;
device->ws->buffer_destroy(pool->bo); device->ws->buffer_destroy(pool->bo);
vk_object_base_finish(&pool->base);
vk_free2(&device->vk.alloc, pAllocator, pool); vk_free2(&device->vk.alloc, pAllocator, pool);
} }

View file

@ -166,6 +166,9 @@ VkResult radv_CreateShaderModule(
if (module == NULL) if (module == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(&device->vk, &module->base,
VK_OBJECT_TYPE_SHADER_MODULE);
module->nir = NULL; module->nir = NULL;
module->size = pCreateInfo->codeSize; module->size = pCreateInfo->codeSize;
memcpy(module->data, pCreateInfo->pCode, module->size); memcpy(module->data, pCreateInfo->pCode, module->size);
@ -188,6 +191,7 @@ void radv_DestroyShaderModule(
if (!module) if (!module)
return; return;
vk_object_base_finish(&module->base);
vk_free2(&device->vk.alloc, pAllocator, module); vk_free2(&device->vk.alloc, pAllocator, module);
} }

View file

@ -34,10 +34,12 @@
#include "nir/nir.h" #include "nir/nir.h"
#include "vulkan/vulkan.h" #include "vulkan/vulkan.h"
#include "vulkan/util/vk_object.h"
struct radv_device; struct radv_device;
struct radv_shader_module { struct radv_shader_module {
struct vk_object_base base;
struct nir_shader *nir; struct nir_shader *nir;
unsigned char sha1[20]; unsigned char sha1[20];
uint32_t size; uint32_t size;