d3d12: add implicit transition for subpass attachments

This commit is contained in:
Kai Ninomiya 2017-08-29 17:57:27 -07:00 committed by Kai Ninomiya
parent ee7b6b1b62
commit 720a5d9366
2 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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);
}