Jump to content

  • Log In with Google      Sign In   
  • Create Account


Debugging the stencil buffer


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 menohack   Members   -  Reputation: 216

Like
0Likes
Like

Posted 10 July 2013 - 10:19 PM

Is it possible to display the stencil buffer as a texture? The only formats available to a shader resource view are DXGI_FORMAT_R24_UNORM_X8_TYPELESS and DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS. When I try to draw this as a quad I only seem to have access to the x or r component, which is the depth.

 

Thanks!



Sponsor:

#2 MJP   Moderators   -  Reputation: 10945

Like
1Likes
Like

Posted 10 July 2013 - 11:07 PM

It depends on which format you used to create the depth buffer. If you used DXGI_FORMAT_R24G8_TYPELESS, then use DXGI_FORMAT_X24_TYPELESS_G8_UINT to create your SRV and then access the G channel in your shader. If you used DXGI_FORMAT_R32G8X24_TYPELESS, then do the same with DXGI_FORMAT_X32_TYPELESS_G8X24_UINT.

In your shader, make sure that you declare your texture as Texture2D<uint2>. You'll then get an integer that's [0, 255], which you can convert to a [0,1] float for displaying.


Edited by MJP, 10 July 2013 - 11:08 PM.


#3 menohack   Members   -  Reputation: 216

Like
0Likes
Like

Posted 11 July 2013 - 12:34 AM

Exactly what I needed. Thank you very much!



#4 NightCreature83   Crossbones+   -  Reputation: 2745

Like
0Likes
Like

Posted 11 July 2013 - 01:28 AM

The other way of doing this is to turn color writes back on and stencil writes off for the objects you are rendering to the stencil, they will then appear on screen. This is easier then rendering to a render target and then displaying that if all you need to do is debugging.

 

I used this a lot during the development of DiRT3 where we were using a lot of stencil animations to do certain transitions, because of how our renderer worked. This is a renderstate change as well no need for an additional shader or texture.


Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, Mad Max

#5 ATEFred   Members   -  Reputation: 1055

Like
0Likes
Like

Posted 11 July 2013 - 01:52 AM

nividia's NSight can display the stencil buffer for you. Great tool for debugging this kind of thing.



#6 NightCreature83   Crossbones+   -  Reputation: 2745

Like
0Likes
Like

Posted 11 July 2013 - 02:21 AM

So can AMDs gDEBugger and GPU PerfStudio 2

 

gDEBugger is GL only and PerStudio is when you have a AMD card instead of an NVidia one (NSight only supports NVidia GPUs).


Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, Mad Max

#7 menohack   Members   -  Reputation: 216

Like
0Likes
Like

Posted 11 July 2013 - 05:22 PM

Just for future reference: I believe that the Shader Debugger in Visual Studio 2012 can also check the stencil buffer.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS