Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan: Fix stencil image data priming #2618

Merged
merged 1 commit into from
Feb 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions gapis/api/vulkan/api/renderpass_framebuffer.api
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down
16 changes: 10 additions & 6 deletions gapis/api/vulkan/image_primer_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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) {
Expand Down