Jump to content
  • Advertisement
Sign in to follow this  
Reitano

Warning with depth only and alpha testing

This topic is 603 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 render shadowmaps the standard way, that is by binding a depth/stencil buffer and by setting a null render target and a null pixel shader. That works fine except for alpha tested geometry. In this case I need a pixel shader to discard pixels that fail the alpha test. Of course the DirectX debug layer complains as no render target is bound:
#D3D11 WARNING: ID3D11DeviceContext::DrawIndexedInstanced: The Pixel Shader expects a Render Target View bound to slot 0, but none is bound.
The results are correct but I'd like to suppress this annoying warning. Any suggestions ? For example, is there something in DirectX 11 equivalent to the NULL render target hack in DirectX 9 ? Or should I simply create and bind a temporary render target for alpha tested geometry ? 
 
Thanks

Share this post


Link to post
Share on other sites
Advertisement

Does your pixel shader write to SV_TARGET / return a value using the SV_TARGET semantic? If so, that's the colour export that the runtime is complaining about -- either forcing the driver to patch your shader to remove it, or wasting a bit of GPU time exporting colours to a null destination. Try changing your alpha-tested shadow-mapping pixel shader to return void.

Share this post


Link to post
Share on other sites

You can have a pixel shader that returns void:

void PSMain(in PSInput input)
{
    if(MyTexture.Sample(MySampler, input.UV).w < 0.5f)
        discard;
}
Edited by MJP

Share this post


Link to post
Share on other sites

Thank you so much! All these years of hlsl programming and I never knew about this.

On a related note, according to the debug layer, my card does not support a comparison sampler with a 16-bit depth/shadow map, which forces me to either emulate PCF filtering with GatherRed or use a 32 bit depth format. First, is that true for all cards ? I remember that hardware PCF worked fine in DX9 for 16 bit depth maps...

My use case is volumetric shadows (8 samples per ray, 1x1 PCF). I will have to profile the two options but I suppose the reduced bandwidth will win over the additional ALU and register pressure. What's your recommendation ?

 

Thanks

Share this post


Link to post
Share on other sites

The way to check for this kind of feature support is to go to the DXGI Programming Guide, and then go to the "Format Support" section for your minimum feature level. Looking at the guide for feature level 11.0, it looks like R16_UNORM supports both sampling a comparison filter, as well GatherCmp. So I'm not sure why the debug layer would be complaining. What's the message that it's giving you?

Edited by MJP

Share this post


Link to post
Share on other sites

Mistery solved. I was binding the depth map as R16_FLOAT instead of R16_UNORM. All works fine now, thank you again!

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!