From adb152bff108b40686d98288c8e2bb70d8045c8f Mon Sep 17 00:00:00 2001 From: msiglreith Date: Thu, 8 Feb 2018 14:23:28 +0100 Subject: [PATCH] dx12: Handle present texture in a specially PRESENT is an exclusive flag in NXT and can't be combined with other flags. The existing implementation treats the D3D12_RESOURCE_STATE_PRESENT as flag which is confusing due to being 0. --- src/backend/d3d12/TextureD3D12.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/backend/d3d12/TextureD3D12.cpp b/src/backend/d3d12/TextureD3D12.cpp index b608f95b83..5cc700a4d6 100644 --- a/src/backend/d3d12/TextureD3D12.cpp +++ b/src/backend/d3d12/TextureD3D12.cpp @@ -24,6 +24,11 @@ namespace backend { namespace d3d12 { nxt::TextureFormat format) { D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON; + // Present is an exclusive flag. + if (usage & nxt::TextureUsageBit::Present) { + return D3D12_RESOURCE_STATE_PRESENT; + } + if (usage & nxt::TextureUsageBit::TransferSrc) { resourceState |= D3D12_RESOURCE_STATE_COPY_SOURCE; } @@ -44,9 +49,6 @@ namespace backend { namespace d3d12 { resourceState |= D3D12_RESOURCE_STATE_RENDER_TARGET; } } - if (usage & nxt::TextureUsageBit::Present) { - resourceState |= D3D12_RESOURCE_STATE_PRESENT; - } return resourceState; }