Jump to content
  • Advertisement
Sign in to follow this  
GraphicsDude

DX11 How to disable color write DX11/10

This topic is 3164 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to do a depth only pass and I'm trying to turn off color writing. It seems like such a trivial thing. In dx9 it was done through SetRS(). But I've been on the net for hours and can't find any documentation on how to do it. I tried just setting the first parameter to OMSetRenderTargets() to 0 and that works (as far as I can tell), but I get an error at runtime: D3D11: WARNING: ID3D11DeviceContext::OMSetRenderTargets: Resource being set to OM DepthStencil 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 ]. Passing NULL to the OMSetRenderTarget() as the render target view parameter failed. Creating a NULL render target view also didn't work.

Share this post


Link to post
Share on other sites
Advertisement
It's part of ID3D10BlendState/ID3D11BlendState. Have a look at D3D11_BLEND_DESC, and D3D11_RENDER_TARGET_BLEND_DESC.

Share this post


Link to post
Share on other sites
Those errors look to be due to you trying to render to your depth buffer while it is still bound (as a shader resource, probably from a previous pass or frame) to the pipeline. After doing a rendering "pass" it's good to zero-out the resources that you had bound, which will prevent these issues (where the runtime detects a potential R/W hazard). You can do that via something like:

// Unbind render targets
d3dDeviceContext->OMSetRenderTargets(0, 0, 0);

// Unbind shader resources
ID3D11ShaderResourceView* nullViews[8] = {0, 0, 0, 0, 0, 0, 0, 0};
d3dDeviceContext->PSSetShaderResources(0, 8, nullViews);

...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!