Question

I was reading about Conditional rendering and I am having hard time understanding the difference between GL_QUERY_BY_REGION_WAIT and GL_QUERY_WAIT. Is it the following:

GL_QUERY_WAIT - wait for your occlusion query to pass to decide if you should go ahead with conditional rendering.

GL_QUERY_BY_REGION_WAIT - wait for your occlusion query to pass IN THE REGION COVERED BY YOUR CONDITIONAL DRAW to decide if you should go ahead with conditional rendering.

Was it helpful?

Solution

The primary difference is that QUERY_BY_REGION adds an extra test to this. It stipulates that on top of conditionally rendering, parts of the result of any conditional render may be discarded if they occur outside of the region covered by the original query.

OpenGL 4.4 Core Profile Specification - 10.10 Conditional Rendering - pp. 339

If mode is QUERY_BY_REGION_WAIT, the GL will also wait for occlusion query results and discard rendering commands if the result of the occlusion query is zero. If the query result is non-zero, subsequent rendering commands are executed, but the GL may discard the results of the commands for any region of the framebuffer that did not contribute to the sample count in the specified occlusion query. Any such discarding is done in an implementation-dependent manner, but the rendering command results may not be discarded for any samples that contributed to the occlusion query sample count.

The details of this additional behavior are implementation-specific, but you can think of it sort of like a specialized scissor/stencil test. After the conditional render completes, parts of the screen that did not generate any samples in the original query will be discarded. Theoretically, this test/discard behavior could be implemented before shading, that sort of optimization is not forbidden the way the spec. is written. In any event, what this boils down to is a special fragment test.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top