From f2288cca47c980097089774a7e6e9cbd05ab67c9 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 30 Aug 2022 11:30:10 -0500 Subject: [PATCH] vulkan: Add a common vkResetCommandBuffer() implementation This is little more than a wrapper around a function pointer at present so it doesn't really gain the driver much to use it. The new callback will, however, be put to good use in the next commit. Reviewed-by: Dave Airlie Reviewed-by: Samuel Pitoiset Part-of: --- src/vulkan/runtime/vk_command_buffer.c | 11 +++++++++++ src/vulkan/runtime/vk_command_buffer.h | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/src/vulkan/runtime/vk_command_buffer.c b/src/vulkan/runtime/vk_command_buffer.c index 9d291f9f723..2bccf6c63da 100644 --- a/src/vulkan/runtime/vk_command_buffer.c +++ b/src/vulkan/runtime/vk_command_buffer.c @@ -72,6 +72,17 @@ vk_command_buffer_finish(struct vk_command_buffer *command_buffer) vk_object_base_finish(&command_buffer->base); } +VKAPI_ATTR VkResult VKAPI_CALL +vk_common_ResetCommandBuffer(VkCommandBuffer commandBuffer, + VkCommandBufferResetFlags flags) +{ + VK_FROM_HANDLE(vk_command_buffer, cmd_buffer, commandBuffer); + + cmd_buffer->ops->reset(cmd_buffer, flags); + + return VK_SUCCESS; +} + VKAPI_ATTR void VKAPI_CALL vk_common_CmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, diff --git a/src/vulkan/runtime/vk_command_buffer.h b/src/vulkan/runtime/vk_command_buffer.h index afda24b4084..95c02593a42 100644 --- a/src/vulkan/runtime/vk_command_buffer.h +++ b/src/vulkan/runtime/vk_command_buffer.h @@ -60,6 +60,15 @@ struct vk_attachment_state { }; struct vk_command_buffer_ops { + /** Resets the command buffer + * + * Used by the common command pool implementation. This function MUST + * call `vk_command_buffer_reset()`. Unlike `vkResetCommandBuffer()`, + * this function does not have a return value because it may be called on + * destruction paths. + */ + void (*reset)(struct vk_command_buffer *, VkCommandBufferResetFlags); + /** Destroys the command buffer * * Used by the common command pool implementation. This function MUST