From 1ca611cbad697cab2ece9c101ec25c212e19cdc2 Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Tue, 14 Jul 2015 11:06:14 -0700 Subject: [PATCH] vk/0.132: Add vkDestroyCommandBuffer() --- include/vulkan/vulkan.h | 5 ++++ src/vulkan/device.c | 62 ++++++++++++++++++++++++----------------- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/include/vulkan/vulkan.h b/include/vulkan/vulkan.h index cbb42b2c707..c8b5cd8daea 100644 --- a/include/vulkan/vulkan.h +++ b/include/vulkan/vulkan.h @@ -2073,6 +2073,7 @@ typedef VkResult (VKAPI *PFN_vkDestroyFramebuffer)(VkDevice device, VkFramebuffe typedef VkResult (VKAPI *PFN_vkCreateRenderPass)(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, VkRenderPass* pRenderPass); typedef VkResult (VKAPI *PFN_vkGetRenderAreaGranularity)(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity); typedef VkResult (VKAPI *PFN_vkCreateCommandBuffer)(VkDevice device, const VkCmdBufferCreateInfo* pCreateInfo, VkCmdBuffer* pCmdBuffer); +typedef VkResult (VKAPI *PFN_vkDestroyCommandBuffer)(VkDevice device, VkCmdBuffer commandBuffer); typedef VkResult (VKAPI *PFN_vkBeginCommandBuffer)(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo); typedef VkResult (VKAPI *PFN_vkEndCommandBuffer)(VkCmdBuffer cmdBuffer); typedef VkResult (VKAPI *PFN_vkResetCommandBuffer)(VkCmdBuffer cmdBuffer); @@ -2588,6 +2589,10 @@ VkResult VKAPI vkCreateCommandBuffer( const VkCmdBufferCreateInfo* pCreateInfo, VkCmdBuffer* pCmdBuffer); +VkResult VKAPI vkDestroyCommandBuffer( + VkDevice device, + VkCmdBuffer commandBuffer); + VkResult VKAPI vkBeginCommandBuffer( VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo); diff --git a/src/vulkan/device.c b/src/vulkan/device.c index a632a4f7e37..7d764f33643 100644 --- a/src/vulkan/device.c +++ b/src/vulkan/device.c @@ -1181,7 +1181,6 @@ VkResult anv_DestroyObject( VkObject _object) { ANV_FROM_HANDLE(anv_device, device, _device); - struct anv_object *object = (struct anv_object *) _object; switch (objType) { case VK_OBJECT_TYPE_FENCE: @@ -1266,7 +1265,7 @@ VkResult anv_DestroyObject( return anv_DestroyFramebuffer(_device, (VkFramebuffer) _object); case VK_OBJECT_TYPE_COMMAND_BUFFER: - (object->destructor)(device, object, objType); + return anv_DestroyCommandBuffer(_device, (VkCmdBuffer) _object); return VK_SUCCESS; case VK_OBJECT_TYPE_PIPELINE: @@ -2423,29 +2422,8 @@ anv_cmd_buffer_destroy(struct anv_device *device, assert(obj_type == VK_OBJECT_TYPE_COMMAND_BUFFER); - /* Destroy all of the batch buffers */ - struct anv_batch_bo *bbo = cmd_buffer->last_batch_bo; - while (bbo) { - struct anv_batch_bo *prev = bbo->prev_batch_bo; - anv_batch_bo_destroy(bbo, device); - bbo = prev; - } - anv_reloc_list_finish(&cmd_buffer->batch.relocs, device); - - /* Destroy all of the surface state buffers */ - bbo = cmd_buffer->surface_batch_bo; - while (bbo) { - struct anv_batch_bo *prev = bbo->prev_batch_bo; - anv_batch_bo_destroy(bbo, device); - bbo = prev; - } - anv_reloc_list_finish(&cmd_buffer->surface_relocs, device); - - anv_state_stream_finish(&cmd_buffer->surface_state_stream); - anv_state_stream_finish(&cmd_buffer->dynamic_state_stream); - anv_device_free(device, cmd_buffer->exec2_objects); - anv_device_free(device, cmd_buffer->exec2_bos); - anv_device_free(device, cmd_buffer); + anv_DestroyCommandBuffer(anv_device_to_handle(device), + anv_cmd_buffer_to_handle(cmd_buffer)); } static VkResult @@ -2575,6 +2553,40 @@ VkResult anv_CreateCommandBuffer( return result; } +VkResult anv_DestroyCommandBuffer( + VkDevice _device, + VkCmdBuffer _cmd_buffer) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, _cmd_buffer); + + /* Destroy all of the batch buffers */ + struct anv_batch_bo *bbo = cmd_buffer->last_batch_bo; + while (bbo) { + struct anv_batch_bo *prev = bbo->prev_batch_bo; + anv_batch_bo_destroy(bbo, device); + bbo = prev; + } + anv_reloc_list_finish(&cmd_buffer->batch.relocs, device); + + /* Destroy all of the surface state buffers */ + bbo = cmd_buffer->surface_batch_bo; + while (bbo) { + struct anv_batch_bo *prev = bbo->prev_batch_bo; + anv_batch_bo_destroy(bbo, device); + bbo = prev; + } + anv_reloc_list_finish(&cmd_buffer->surface_relocs, device); + + anv_state_stream_finish(&cmd_buffer->surface_state_stream); + anv_state_stream_finish(&cmd_buffer->dynamic_state_stream); + anv_device_free(device, cmd_buffer->exec2_objects); + anv_device_free(device, cmd_buffer->exec2_bos); + anv_device_free(device, cmd_buffer); + + return VK_SUCCESS; +} + static void anv_cmd_buffer_emit_state_base_address(struct anv_cmd_buffer *cmd_buffer) { -- 2.30.2