vk/0.132: Add vkDestroyCommandBuffer()
authorChad Versace <chad.versace@intel.com>
Tue, 14 Jul 2015 18:06:14 +0000 (11:06 -0700)
committerChad Versace <chad.versace@intel.com>
Tue, 14 Jul 2015 18:11:41 +0000 (11:11 -0700)
include/vulkan/vulkan.h
src/vulkan/device.c

index cbb42b2c7075443f661d6c2f36ed4e02e3735803..c8b5cd8daeabbc625494e119e405a6c22ca759b4 100644 (file)
@@ -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);
index a632a4f7e37faa76ffec1fcee0991a7c8a73a46f..7d764f336434d3fa8fd79552d247b206867c1313 100644 (file)
@@ -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)
 {