Reputation: 1641
I have a texture, along with its shaderresourceview, to which I render my scene's original image by using it as a RenderTarget.
Like millions before me, I then use it as an input to my next shader so I can blur, do HDR, all of that.
The simple but "new to me" problem is that when I go to call PSSetShaderResources and put the texture into the shader's texture/constant buffer I get this error:
"Resource being set to PS shader resource slot 0 is still bound on output"
...which makes sense, as it may still well be. My question is how do I unbind the texture from being the render target of the initial pass?
I'm already doing this, which I presume sets it back to the original RenderTargetView that DXUT was using at the beginning, but it doesn't seem to free up the texture:
ID3D11RenderTargetView * renderTargetViewArrayTQ[1] = { DXUTGetD3D11RenderTargetView() };
pd3dImmediateContext->OMSetRenderTargets(1, renderTargetViewArray, nullptr);
Upvotes: 3
Views: 5050
Reputation: 1641
When unbinding the texture from the pixel shader, this does NOT work:
ID3D11ShaderResourceView *const pSRV[1] = { NULL };
pd3dImmediateContext->PSSetShaderResources(0, 0, pSRV);
However, this DOES work:
ID3D11ShaderResourceView *const pSRV[1] = { NULL };
pd3dImmediateContext->PSSetShaderResources(0, 1, pSRV);
Put more simply, when setting the resource back to null, you still have to tell it you're passing in one pointer, albeit a null one. Passing a null alone with a zero count appears to do nothing.
Upvotes: 2
Reputation: 3584
Assuming your render target is in slot 0:
ID3D11RenderTargetView* nullRTV = nullptr; d3dContext->OMSetRenderTargets(1, &nullRTV, nullptr);
You need to pass an array of ID3D11RenderTargetView* of length 1, the first of which needs to be nullptr.
Upvotes: 3