Jump to content
  • Advertisement
Sign in to follow this  
16bit_port

Determining if a pixel has affected/updated by draw call

This topic is 2709 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

So I THINK the best way to go about this is checking the stencil buffer (frame and depth won't work), by clearing the buffer before the draw call, draw, and then check to see if the pixel's stencil component is not the same as the default value (set by the clear function). If I create the stencil buffer with a DXGI_FORMAT_D24_UNORM_S8_UINT format, is the stencil component the 4th component (the A in RGBA) or is the 1st component (the R in RGBA)?

Also, is this the best way to check to see if a draw call affects a certain pixel? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
You could just use an occlusion query. Start your query, draw a 1 pixel point using the proper depth testing states, then check the results of your query. If you're you're using clip/discard/alpha testing for your geometry, then you can use your stencil method and afterwards draw the 1 pixel point (with the occlusion query) with stencil testing enable (set the test to EQUAL using the same ref as before.

Share this post


Link to post
Share on other sites

You could just use an occlusion query. Start your query, draw a 1 pixel point using the proper depth testing states, then check the results of your query. If you're you're using clip/discard/alpha testing for your geometry, then you can use your stencil method and afterwards draw the 1 pixel point (with the occlusion query) with stencil testing enable (set the test to EQUAL using the same ref as before.


My current situation is slightly different from the one I'd originally posted, but I think your suggestion might still be of some use.

situation : want to see if a primitive passes the depth test for certain pixel.

With your suggestion, I'd need to create a pixel point. How do I even do that? Take a point in screen-space and do an inverse-transform and bring it to world-space? But then even after that, I'd need to check to see if the world-space point inside world-point primitive to decide if I should even do the query (in other words, do picking). I don't know... there has to be a simpler solution..

Another approach would be to test against the depth buffer but I don't think that'll work because the depth test uses a less-than-or-equal-to condition, meaning that checking the depth value against the one before the draw call won't work if the depth value happens to be the same as the one before.

Share this post


Link to post
Share on other sites
Someone suggested to clear the render target to white, set a state with depth and stencil disabled, render, and if the pixel is still white then it "must have failed the depth test". What? How can that possibly work? If the pixel shader outputs white then this will not work. Am I missing something here?

Share this post


Link to post
Share on other sites
Can you shed some light on the background of this problem? Does it need to be efficient/fast? Is the result of this query needed on the GPU or the CPU?

Share this post


Link to post
Share on other sites

Can you shed some light on the background of this problem? Does it need to be efficient/fast? Is the result of this query needed on the GPU or the CPU?


Does not need to be fast. It's on the CPU.

Share this post


Link to post
Share on other sites
With your suggestion, I'd need to create a pixel point. How do I even do that?[/quote]

How about clipping your output to that very pixel and draw your primitive normally ? E.g. using a 1-pixel sized viewport or scissors.

Edit: With "normally" I mean still using a occlusion query setup.

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!