Hello!
Reading some materials about D3D12 resource barriers, but it is unclear to me how they are working when using resource between different command queues.
Let's say we have a simple scenario of accessing read/write between command queues:
- Graphics Queue perform writeable work to an UAV1
- Compute Queue needs to read from UAV1 and write to UAV2
- Graphics Queue perform read work from UAV2
From the D3D12 documentations about Executing and Synchronizing Command Lists - Win32 apps | Microsoft Docs
When a resource has transitioned to a writeable state on a queue, it is considered exclusively owned by that queue, and must transition to a read or COMMON state (refer to **D3D12\_RESOURCE\_STATES**) before it can be accessed by another queue.
Does it mean that at the end of step 1, we need to transition from write to read/COMMON UAV1 so that step 2 (on compute queue) can safely perform the read on UAV1? Could we do the transition of UAV1 to read/COMMON at the beginning of step 2 instead? In other words, do resource barriers work as expected between command queues?
In the following section “Synchronizing command list execution using command queue fences” of D3D12 MSDN doc, they are implying that fences should be used to synchronize between work on different command queues (e.g if compute is depending on graphics queue). But I don't get it then, if resource barriers are supposed to work between command queues, do we need fences to synchronize between command queues?