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.
0Advanced issues found▲QuoteD3D12 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.