Determining if a pixel has affected/updated by draw call

Started by
5 comments, last by unbird 13 years, 1 month ago
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.
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.

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.
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?
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?

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.
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.

This topic is closed to new replies.

Advertisement