Sign in to follow this  

Determining if a pixel has affected/updated by draw call

This topic is 2492 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
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
[quote name='MJP' timestamp='1297893855' post='4775137']
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.
[/quote]

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
[quote name='Hodgman' timestamp='1297996113' post='4775673']
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?
[/quote]

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

Share this post


Link to post
Share on other sites
[quote]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

This topic is 2492 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this