D3D11 debug layer does not get warning

Asked 2 years ago, Updated 2 years ago, 103 views

The following warning statement appears in the output window:

D3D11 WARNING:ID3D11DeviceContext::OMSetRenderTargets:Resource being set to OM RenderTarget slot0 is still bound on input![STATE_SETTING WARNING #9:DEVICE_OMSETRENDERTARGETS_HAZARD]
D3D11 WARNING:ID3D11DeviceContext::OMSetRenderTargets [AndUnorderedAccessViews]:Forcing PS shader resource slot0 to NULL. [STATE_SETTING WARNING #7:DEVICE_PSSETSHADERRESOURCES_HAZARD]

It seems that the resources of the view you are trying to set in OMSetRenderTargets() are already allocated as the color resource view of the pixel shader.
The solution was to pass NULL to OMSetRenderTarget() and PSSetShaderResources() and reset the state.

So before calling OMSetRenderTarget(),

ID3D11 RenderTargetView* dummyRTVs [D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT] = {nullptr};
ID3D11ShaderResourceView* dummySRVs [D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT] = {nullptr};

pImmediateContext->OMSetRenderTargets(_countof(dummyRTVs), dummyRTVs, nullptr);
pImmediateContext->PSSetShaderResources(0,_countof(dummySRVs), dummySRVs);

I'm doing this, but I still throw out the same warning.
Is there any other reason?

Thank you for your cooperation.

c++ directx

2022-09-29 22:43

1 Answers

This warning occurs when the same resource is read/write at the same time.
For example, if you bind a render target that you want to draw with a pixel shader to a pixel shader as a texture, you get this warning.
Common examples include backbuffer textured effects and shadow maps using depth buffers.
Even if you set NULL for a resource, it will occur if there is a path that reads and writes at the same time, so you need to carefully investigate the code.
Try commenting out the code path by path to narrow down the cause and see if there's a way to use it.


2022-09-29 22:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.