venus: ignore framebuffer for VkCommandBuffer executed outside of render pass

The vulkan spec states[1]:
> If the VkCommandBuffer will not be executed within a render pass instance,
> or if the render pass instance was begun with vkCmdBeginRenderingKHR,
> renderPass, subpass, and framebuffer are ignored.

but venus will still try to encode them, resulting in a guest-side
assert or host-side command stream error.

[1]: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkCommandBufferInheritanceInfo.html#_description

Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13988>
This commit is contained in:
Ryan Neph
2021-11-30 15:39:17 -08:00
parent 06fe04b4d7
commit 996e855e66

View File

@@ -629,12 +629,24 @@ vn_BeginCommandBuffer(VkCommandBuffer commandBuffer,
vn_cs_encoder_reset(&cmd->cs);
/* TODO: add support for VK_KHR_dynamic_rendering */
VkCommandBufferBeginInfo local_begin_info;
if (pBeginInfo->pInheritanceInfo &&
cmd->level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) {
local_begin_info = *pBeginInfo;
local_begin_info.pInheritanceInfo = NULL;
pBeginInfo = &local_begin_info;
VkCommandBufferInheritanceInfo local_inheritance_info;
if (pBeginInfo->pInheritanceInfo) {
if (cmd->level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) {
local_begin_info = *pBeginInfo;
local_begin_info.pInheritanceInfo = NULL;
pBeginInfo = &local_begin_info;
} else if (!(pBeginInfo->flags &
VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT)) {
local_inheritance_info = *pBeginInfo->pInheritanceInfo;
local_inheritance_info.framebuffer = VK_NULL_HANDLE;
local_inheritance_info.renderPass = VK_NULL_HANDLE;
local_inheritance_info.subpass = 0;
local_begin_info = *pBeginInfo;
local_begin_info.pInheritanceInfo = &local_inheritance_info;
pBeginInfo = &local_begin_info;
}
}
cmd_size = vn_sizeof_vkBeginCommandBuffer(commandBuffer, pBeginInfo);