From 4e58eb39ad87f1e6c612420aaeb19cf91b033a58 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 30 Jan 2023 20:11:59 -0600 Subject: [PATCH] nvk: Implement vkCmdExecuteCommands() Part-of: --- src/nouveau/vulkan/nvk_cmd_buffer.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/nouveau/vulkan/nvk_cmd_buffer.c b/src/nouveau/vulkan/nvk_cmd_buffer.c index a11a0545b6a..d7bd55d2418 100644 --- a/src/nouveau/vulkan/nvk_cmd_buffer.c +++ b/src/nouveau/vulkan/nvk_cmd_buffer.c @@ -209,7 +209,29 @@ nvk_CmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers) { - unreachable("Secondary command buffers not yet supported"); + VK_FROM_HANDLE(nvk_cmd_buffer, cmd, commandBuffer); + + nvk_cmd_buffer_flush_push(cmd); + + for (uint32_t i = 0; i < commandBufferCount; i++) { + VK_FROM_HANDLE(nvk_cmd_buffer, other, pCommandBuffers[i]); + + /* We only need to copy the pushes and BO refs. We do not copy the + * nvk_cmd_buffer::bos because that tracks ownership. Instead, we + * depend on the app to not discard secondaries while they are used by a + * primary. The Vulkan 1.3.227 spec for vkFreeCommandBuffers() says: + * + * "Any primary command buffer that is in the recording or executable + * state and has any element of pCommandBuffers recorded into it, + * becomes invalid." + * + * In other words, if the secondary command buffer ever goes away, this + * command buffer is invalid and the only thing the client can validly + * do with it is reset it. vkResetCommandPool() has similar language. + */ + util_dynarray_append_dynarray(&cmd->pushes, &other->pushes); + util_dynarray_append_dynarray(&cmd->bo_refs, &other->bo_refs); + } } VKAPI_ATTR void VKAPI_CALL