mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 07:36:15 +00:00
Freeze texture transitions while attached; consolidate OutputAttachment usage (#67)
* lock usages for attachments during subpasses * refactor IsTextureTransitionPossible * change attachment usages to OutputAttachment * make SetBindGroup validation lazier
This commit is contained in:
@@ -59,8 +59,8 @@ void initTextures() {
|
||||
.SetExtent(640, 480, 1)
|
||||
.SetFormat(nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetMipLevels(1)
|
||||
.SetAllowedUsage(nxt::TextureUsageBit::ColorAttachment | nxt::TextureUsageBit::Sampled)
|
||||
.SetInitialUsage(nxt::TextureUsageBit::ColorAttachment)
|
||||
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment | nxt::TextureUsageBit::Sampled)
|
||||
.SetInitialUsage(nxt::TextureUsageBit::OutputAttachment)
|
||||
.GetResult();
|
||||
renderTargetView = renderTarget.CreateTextureViewBuilder().GetResult();
|
||||
|
||||
@@ -185,20 +185,18 @@ void frame() {
|
||||
static const uint32_t vertexBufferOffsets[1] = {0};
|
||||
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
||||
.BeginRenderPass(renderpass, framebuffer)
|
||||
// renderTarget is not transitioned here because it's implicit in
|
||||
// BeginRenderPass or AdvanceSubpass.
|
||||
.BeginRenderSubpass()
|
||||
// renderTarget implicitly locked to to Attachment usage (if not already frozen)
|
||||
.SetPipeline(pipeline)
|
||||
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
||||
.DrawArrays(3, 1, 0, 0)
|
||||
.EndRenderSubpass()
|
||||
// renderTarget must be transitioned here because it's Sampled, not
|
||||
// ColorAttachment or InputAttachment.
|
||||
.TransitionTextureUsage(renderTarget, nxt::TextureUsageBit::Sampled)
|
||||
// renderTarget usage unlocked, but left in Attachment usage
|
||||
.BeginRenderSubpass()
|
||||
.SetPipeline(pipelinePost)
|
||||
.SetBindGroup(0, bindGroup)
|
||||
.SetVertexBuffers(0, 1, &vertexBufferQuad, vertexBufferOffsets)
|
||||
.TransitionTextureUsage(renderTarget, nxt::TextureUsageBit::Sampled)
|
||||
.SetBindGroup(0, bindGroup)
|
||||
.DrawArrays(6, 1, 0, 0)
|
||||
.EndRenderSubpass()
|
||||
.EndRenderPass()
|
||||
|
||||
Reference in New Issue
Block a user