From 720a5d9366e0a9fd3806f7d8de7c2fcb60ae77a4 Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Tue, 29 Aug 2017 17:57:27 -0700 Subject: [PATCH] d3d12: add implicit transition for subpass attachments --- src/backend/d3d12/CommandBufferD3D12.cpp | 10 ++++++++++ src/tests/NXTTest.cpp | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/backend/d3d12/CommandBufferD3D12.cpp b/src/backend/d3d12/CommandBufferD3D12.cpp index 976a2646c0..7066b6b806 100644 --- a/src/backend/d3d12/CommandBufferD3D12.cpp +++ b/src/backend/d3d12/CommandBufferD3D12.cpp @@ -277,6 +277,16 @@ namespace d3d12 { uint32_t attachmentSlot = subpass.colorAttachments[location]; const auto& attachmentInfo = currentRenderPass->GetAttachmentInfo(attachmentSlot); + Texture* texture = ToBackend(currentFramebuffer->GetTextureView(attachmentSlot)->GetTexture()); + constexpr auto usage = nxt::TextureUsageBit::OutputAttachment; + if (!texture->IsFrozen()) { + D3D12_RESOURCE_BARRIER barrier; + if (texture->GetResourceTransitionBarrier(texture->GetUsage(), usage, &barrier)) { + commandList->ResourceBarrier(1, &barrier); + } + texture->UpdateUsageInternal(usage); + } + // Only perform load op on first use if (attachmentInfo.firstSubpass == currentSubpass) { // Load op - color diff --git a/src/tests/NXTTest.cpp b/src/tests/NXTTest.cpp index 95227d86c8..4f9d89398c 100644 --- a/src/tests/NXTTest.cpp +++ b/src/tests/NXTTest.cpp @@ -142,7 +142,7 @@ void NXTTest::SetUp() { swapchain = device.CreateSwapChainBuilder() .SetImplementation(binding->GetSwapChainImplementation()) .GetResult(); - swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, 400, 400); + swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, nxt::TextureUsageBit::OutputAttachment, 400, 400); device.SetErrorCallback(DeviceErrorCauseTestFailure, 0); }