Advertisement

Does CopyDescriptors implicitly change resource state?

Started by July 22, 2019 10:01 AM
1 comment, last by MJP 5 years, 1 month ago

Hello,

I have come across a strange problem in D3D12. I am creating a render target with the start state in CreateCommittedResource as D3D12_RESOURCE_STATE_RENDER_TARGET. After that, I create an SRV for the render target and use that as the source handle in a CopyDescriptors call. This is all done during initialization.

When doing the first draw call, I get this validation error. This happens only during the first frame.

 
 
0
 Advanced issues found
 
 
 
Quote

D3D12 ERROR: ID3D12CommandList::DrawInstanced: Resource state (0x80: D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE) (assumed at first use) of resource (0x000001BD58427630:'shadow rt') (subresource: 0) is invalid for use as a render target.  Expected State Bits (all): 0x4: D3D12_RESOURCE_STATE_RENDER_TARGET, Assumed Actual State: 0x80: D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, Missing State: 0x4: D3D12_RESOURCE_STATE_RENDER_TARGET. [ EXECUTION ERROR #538: INVALID_SUBRESOURCE_STATE]
 

This makes me think, CopyDescriptors is doing an implicit state transition because I create the resource in D3D12_RESOURCE_STATE_RENDER_TARGET and after that, the only time it is used before the draw call is in the CopyDescriptors call.

It sounds like the validation layer is assuming that state decay and implicit promotion occurred for your texture. In this case it looks like it saw that your texture was referenced by an SRV descriptor table and then assumed that it was in the PIXEL_SHADER_RESOURCE state. Do you have the D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS flag set for the texture resource? Implicit state decay/promotion should only happen for textures if that flag was set when the resource was created.

This topic is closed to new replies.

Advertisement