This project has moved and is read-only. For the latest updates, please go here.

Problem with multiple render targets (SOLVED)

Aug 5, 2012 at 11:18 PM
Edited Aug 5, 2012 at 11:35 PM

I'm getting the following warning:


D3D11 WARNING: ID3D11DeviceContext::OMSetRenderTargets: Resource being set to OM RenderTarget slot 0 is still bound on input! [ STATE_SETTING WARNING #9: DEVICE_OMSETRENDERTARGETS_HAZARD]

D3D11 WARNING: ID3D11DeviceContext::OMSetRenderTargets[AndUnorderedAccessViews]: Forcing PS shader resource slot 0 to NULL. [ STATE_SETTING WARNING #7: DEVICE_PSSETSHADERRESOURCES_HAZARD]

My code looks something like:

// set the render target to be a texture

DX->GetContext()->OMSetRenderTargets(1, &TextureTarget->View, nullptr);
DX->GetContext()->ClearRenderTargetView(TextureTarget->View, Colors::Black);

// draw something

// This is my attempt to solve the problem, but it doesn't work...

ID3D11ShaderResourceView* nullSrv = NULL;
DX->GetContext()->PSSetShaderResources(0, 1, &nullSrv);

// switch to the back buffer

DX->GetContext()->OMSetRenderTargets(1, &BackBuffer->View, nullptr);
DX->GetContext()->ClearRenderTargetView(BackBuffer->View, Colors::White);
RECT r = { 0, 0, 1920, 1080 }; SpriteBatch->Begin();
SpriteBatch->Draw(TextureTarget->GetShaderResourceView(), r, Colors::White); SpriteBatch->End(); DX->Present();

Any suggestions?  I'm kind of just banging my head against the wall at this point. :)  Thanks!


EDIT: Fixed.  I just need to clear the shader resources before the first OMSetRenderTargets, not the second.

Aug 6, 2012 at 12:55 PM

You just need to clear the shader resources at the beginning or at the end of the render loop, unless you have to write on a render target previously used as input for the shader.