diff --git a/src/vulkan/runtime/vk_command_buffer.c b/src/vulkan/runtime/vk_command_buffer.c index 90c40b88f75..5675b73440b 100644 --- a/src/vulkan/runtime/vk_command_buffer.c +++ b/src/vulkan/runtime/vk_command_buffer.c @@ -24,6 +24,8 @@ #include "vk_command_buffer.h" #include "vk_command_pool.h" +#include "vk_common_entrypoints.h" +#include "vk_device.h" VkResult vk_command_buffer_init(struct vk_command_buffer *command_buffer, @@ -63,3 +65,19 @@ vk_command_buffer_finish(struct vk_command_buffer *command_buffer) util_dynarray_fini(&command_buffer->labels); vk_object_base_finish(&command_buffer->base); } + +VKAPI_ATTR void VKAPI_CALL +vk_common_CmdExecuteCommands(VkCommandBuffer commandBuffer, + uint32_t commandBufferCount, + const VkCommandBuffer *pCommandBuffers) +{ + VK_FROM_HANDLE(vk_command_buffer, primary, commandBuffer); + const struct vk_device_dispatch_table *disp = + primary->base.device->command_dispatch_table; + + for (uint32_t i = 0; i < commandBufferCount; i++) { + VK_FROM_HANDLE(vk_command_buffer, secondary, pCommandBuffers[i]); + + vk_cmd_queue_execute(&secondary->cmd_queue, commandBuffer, disp); + } +} diff --git a/src/vulkan/runtime/vk_device.h b/src/vulkan/runtime/vk_device.h index b649e2e195d..d40f195c74a 100644 --- a/src/vulkan/runtime/vk_device.h +++ b/src/vulkan/runtime/vk_device.h @@ -47,7 +47,15 @@ struct vk_device { /** Command dispatch table * - * This is used for emulated secondary command buffer support. + * This is used for emulated secondary command buffer support. To use + * emulated (trace/replay) secondary command buffers: + * + * 1. Provide your "real" command buffer dispatch table here. Because + * this doesn't get populated by vk_device_init(), the driver will have + * to add the vk_common entrypoints to this table itself. + * + * 2. Add vk_enqueue_unless_primary_device_entrypoint_table to your device + * level dispatch table. */ const struct vk_device_dispatch_table *command_dispatch_table;