error using resource barrier from multiple commandlists for same resource

Started by
1 comment, last by Mr_Fox 8 years, 5 months ago

In dx12 we have to manage resource before/after state ourselves, but all the dx12 docs sample code uses the same commandlist to call resourcebarrier. in my program, I use a computeCommandList to update a volume buffer and then use graphicCommandList to visualize the volume every frame. So for the volume buffer resource state I have the following state change flow:


void CreateResource(...){
   ...
   UpdateSubresources( m_graphicCmdList.Get(), m_volumeBuffer.Get(), volumeBufferUploadHeap.Get(), 0, 0, 1, &volumeBufferData );
   m_graphicCmdList->ResourceBarrier( 1, &CD3DX12_RESOURCE_BARRIER::Transition( m_volumeBuffer.Get(),
                                                                                  D3D12_RESOURCE_STATE_COPY_DEST,
                                                                                  D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ) );
   VRET( m_graphicCmdList->Close() );
   ID3D12CommandList* ppCommandLists[] = { m_graphicCmdList.Get() };
   m_graphicCmdQueue->ExecuteCommandLists( _countof( ppCommandLists), ppCommandLists);
   ...
}
void Update(...){
   ...
!! m_computeCmdList->ResourceBarrier( 1, &CD3DX12_RESOURCE_BARRIER::Transition( m_volumeBuffer.Get(),
                                                                                  D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
                                                                                  D3D12_RESOURCE_STATE_UNORDERED_ACCESS ) );
   ...  
   m_computeCmdList->Dispatch(...);
   ...
   m_computeCmdList->ResourceBarrier( 1, &CD3DX12_RESOURCE_BARRIER::Transition( m_volumeBuffer.Get(),
                                                                                  D3D12_RESOURCE_STATE_UNORDERED_ACCESS,
                                                                                  D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE) );
   ...
}

However I got error msg @ !! line:
D3D12 ERROR: ID3D12CommandList::ResourceBarrier: D3D12_RESOURCE_STATES has invalid flags for compute command list. [ RESOURCE_MANIPULATION ERROR #537: RESOURCE_BARRIER_INVALID_COMMAND_LIST_TYPE]

Any idea? Thanks

Advertisement
As I understand it, the different command list types (graphics/direct, compute, and copy) can only deal with resource states that they can understand. So In order to transition to or from a pixel shader resource, you need to use a graphics command list. So you'll need to transition to and from the UAV state on your graphics command list, rather than on your compute command list.

As I understand it, the different command list types (graphics/direct, compute, and copy) can only deal with resource states that they can understand. So In order to transition to or from a pixel shader resource, you need to use a graphics command list. So you'll need to transition to and from the UAV state on your graphics command list, rather than on your compute command list.

Thanks, but the dx12 doc doesn't mention anything that different command list types have this kind of restrictions.... sign....

However it did mention that

"The debug layer normally issues errors where runtime validation fails:

  • If a subresource transition in a command list is inconsistent with previous transitions in the same command list.

"

So I guess maybe in my case from m_compoutCmdList point of view, the first call to ResourceBarrier have before state not matching the previous transition in this commandlist (since the initial resource state set is in m_graphicsCommandLIst)?

And if that is the case, it will be a headache to sync resource state for multiple commandlist if we want to use multiple commandlist to call resourcebarrier?

This topic is closed to new replies.

Advertisement