Eva
Eva

Reputation: 33

DirectX: How to unbind ShaderResourceView to use for next render pass?

I'm currently working on a project where I'm trying to draw my scene using a SRV as a texture. The previous render (deferred rendering with multiple g-buffers) works fine, but as soon as I want to render the next pass (using a new render target) I get an error when I try to set the shader resource (x meaning that I've tried to bind it to different spots):

   gDeviceContext->PSSetShaderResources(x, 1, &AASRV); 
   "Resource being set to PS shader resource slot x is still bound on output"

And thus it simply sets this shader resource to NULL. I have tried the following code below to try and release the resource but without luck. The shader resources before this one do not give an error.

ID3D11ShaderResourceView* clr[6]; 
for (int k = 0; k < 6; k++) {
    clr[k] = nullptr; 
}

gDeviceContext->PSSetShaderResources(0, 6, clr);    

Upvotes: 0

Views: 1392

Answers (1)

Chuck Walbourn
Chuck Walbourn

Reputation: 41057

You can't have the same resource bound as a render target view and a shader resource view at the same time. That means sometimes hitting these cases where you are trying to swap them and getting an error. Try change the Render Target View before trying to set it as an SRV:

ID3D11RenderTargetView* nullViews [] = { nullptr };
m_d3dContext->OMSetRenderTargets(_countof(nullViews), nullViews, nullptr);

Upvotes: 3

Related Questions