From b71e4f535f028b115ec3105c8d28de75e2c13809 Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 18 Feb 2021 22:08:22 -0800 Subject: D3D12 comamnd context: updated state transitions for RT acceleration structures --- Graphics/GraphicsEngineD3D12/src/CommandContext.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp index 57814d5c..e8617466 100644 --- a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp +++ b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp @@ -251,7 +251,10 @@ void StateTransitionHelper::AddD3D12ResourceBarriers(TopLevelASD3D12Impl& TLAS, { // Acceleration structure is always in D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE, // and requires UAV barrier instead of state transition. - m_RequireUAVBarrier |= (m_OldState == RESOURCE_STATE_BUILD_AS_WRITE); + // If either old or new state is a write state, we need to issue a UAV barrier to complete + // all previous read/write operations. + if (m_OldState == RESOURCE_STATE_BUILD_AS_WRITE || m_Barrier.NewState == RESOURCE_STATE_BUILD_AS_WRITE) + m_RequireUAVBarrier = true; #ifdef DILIGENT_DEVELOPMENT if (m_Barrier.NewState & RESOURCE_STATE_RAY_TRACING) @@ -265,7 +268,10 @@ void StateTransitionHelper::AddD3D12ResourceBarriers(BottomLevelASD3D12Impl& BLA { // Acceleration structure is always in D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE, // and requires UAV barrier instead of state transition. - m_RequireUAVBarrier |= (m_OldState == RESOURCE_STATE_BUILD_AS_WRITE); + // If either old or new state is a write state, we need to issue a UAV barrier to complete + // all previous read/write operations. + if (m_OldState == RESOURCE_STATE_BUILD_AS_WRITE || m_Barrier.NewState == RESOURCE_STATE_BUILD_AS_WRITE) + m_RequireUAVBarrier = true; } template -- cgit v1.2.3