vulkan/runtime: Add emulated secondary command buffer support

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14406>
This commit is contained in:
Jason Ekstrand 2022-03-08 17:50:09 -06:00 committed by Marge Bot
parent 25542f12d7
commit df92f56d8d
2 changed files with 27 additions and 1 deletions

View file

@ -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);
}
}

View file

@ -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;