diff --git a/gapis/api/vulkan/api/renderpass_framebuffer.api b/gapis/api/vulkan/api/renderpass_framebuffer.api index bef93cae1b..dbc002b2e2 100644 --- a/gapis/api/vulkan/api/renderpass_framebuffer.api +++ b/gapis/api/vulkan/api/renderpass_framebuffer.api @@ -280,6 +280,7 @@ sub void dovkCmdBeginRenderPass(ref!vkCmdBeginRenderPassArgs args) { for i in (0 .. n) { loadImageAttachment(as!u32(i)) } + transitionSubpassAttachmentLayouts(ldi.LastSubpass) pushRenderPassMarker(args.RenderPass) } @@ -333,30 +334,35 @@ vkCmdNextSubpassArgs { VkSubpassContents Contents } -sub void dovkCmdNextSubpass(ref!vkCmdNextSubpassArgs Unused) { - useRenderPass() +sub void transitionSubpassAttachmentLayouts(u32 subpass) { ldi := lastDrawInfo() - ldi.LastSubpass += 1 - if ldi.LastSubpass < len(ldi.RenderPass.SubpassDescriptions) { - subpass := ldi.RenderPass.SubpassDescriptions[ldi.LastSubpass] - for _ , _ , a in subpass.InputAttachments { + if subpass < len(ldi.RenderPass.SubpassDescriptions) { + subpassDesc := ldi.RenderPass.SubpassDescriptions[subpass] + for _, _, a in subpassDesc.InputAttachments { attachment := ldi.Framebuffer.ImageAttachments[a.Attachment] transitionImageViewLayout(attachment, VK_IMAGE_LAYOUT_UNDEFINED, a.Layout) } - for _ , _ , a in subpass.ColorAttachments { + for _ , _ , a in subpassDesc.ColorAttachments { attachment := ldi.Framebuffer.ImageAttachments[a.Attachment] transitionImageViewLayout(attachment, VK_IMAGE_LAYOUT_UNDEFINED, a.Layout) } - for _ , _ , a in subpass.ResolveAttachments { + for _ , _ , a in subpassDesc.ResolveAttachments { attachment := ldi.Framebuffer.ImageAttachments[a.Attachment] transitionImageViewLayout(attachment, VK_IMAGE_LAYOUT_UNDEFINED, a.Layout) } - if subpass.DepthStencilAttachment != null { - dsRef := subpass.DepthStencilAttachment + if subpassDesc.DepthStencilAttachment != null { + dsRef := subpassDesc.DepthStencilAttachment attachment := ldi.Framebuffer.ImageAttachments[dsRef.Attachment] transitionImageViewLayout(attachment, VK_IMAGE_LAYOUT_UNDEFINED, dsRef.Layout) } } +} + +sub void dovkCmdNextSubpass(ref!vkCmdNextSubpassArgs Unused) { + useRenderPass() + ldi := lastDrawInfo() + ldi.LastSubpass += 1 + transitionSubpassAttachmentLayouts(ldi.LastSubpass) popAndPushMarkerForNextSubpass(ldi.LastSubpass) } diff --git a/gapis/api/vulkan/image_primer_render.go b/gapis/api/vulkan/image_primer_render.go index 4a28b16dc1..f952e09b7f 100644 --- a/gapis/api/vulkan/image_primer_render.go +++ b/gapis/api/vulkan/image_primer_render.go @@ -321,10 +321,10 @@ func (kit ipRenderKit) BuildRenderCommands(sb *stateBuilder) *queueCommandBatch )) }) if kit.stencil { - for i := uint32(0); i < uint32(8); i++ { - var stencilIndexData bytes.Buffer - binary.Write(&stencilIndexData, binary.LittleEndian, []uint32{i}) - cmdBatch.RecordCommandsOnCommit(func(commandBuffer VkCommandBuffer) { + cmdBatch.RecordCommandsOnCommit(func(commandBuffer VkCommandBuffer) { + for i := uint32(0); i < uint32(8); i++ { + var stencilIndexData bytes.Buffer + binary.Write(&stencilIndexData, binary.LittleEndian, []uint32{i}) sb.write(sb.cb.VkCmdSetStencilWriteMask( commandBuffer, VkStencilFaceFlags(VkStencilFaceFlagBits_VK_STENCIL_FRONT_AND_BACK), @@ -343,8 +343,12 @@ func (kit ipRenderKit) BuildRenderCommands(sb *stateBuilder) *queueCommandBatch 4, NewCharᶜᵖ(sb.MustAllocReadData(stencilIndexData.Bytes()).Ptr()), )) - }) - } + sb.write(sb.cb.VkCmdDraw( + commandBuffer, + 6, 1, 0, 0, + )) + } + }) } else { cmdBatch.RecordCommandsOnCommit(func(commandBuffer VkCommandBuffer) {