i try to implement the nVidia-Occlusion-Query for my application. In the basic version all works fine. In this version i check the queries by the following way:
(1) check extension support
(2) generate queries in OpenGL init
(1) check query for each object
(2) compute visible pixels
(3) render objects
Now i try to follow the hints of nVidia and the GPU-Gems book. In this case, the queries should be checked after the rendering process by the following way:
All 5 or 10 frames (basic check):
(1) check FOV
(2) check Query for all Objects
(1) check visible pixel from
last frame/basic check
(2) render objects
(3) check query only for occludees
(4) compute visible pixels
The problem i’ve, is, that i got everytime zero pixels for each object when i compute the visible pixels by this whay.
I can’t understand why? Knows anyone what I’ve made wrong or knows a sollution?
You check the occlusion query for objects that were occluded in the previous frame.
Then isn’t it logical that most of the time these objects will remain occluded in the next frame, resulting in a value of zero?
Btw, what do you mean exactly by computing visible pixels?
Yes, i (will) check only the occludees that where occluded in the previous frame, this is one of the tasks that must be done, when u follow the nVidia hints from the GDC2002 Occluding document or GPU-Gems book:
“If you have too many objects and want to avoid
generating too many queries, you can skip the
occlusion queries for visible objects for the next
few frames. (For occluded objects you still have
to test in case it has become visible.)”
With computing visible pixels i mean the call of the Query-Function glGetOcclusionQueryuivNV, to get the number of visible pixels…
The problem is, that i got everytime a zero pixel count, also i check occludees and occluders after the render call. I got the zero pixel count for an occludee too, when it becomes visible and this is wrong! When it is done before i got only for the occludees zero. But i don’t know why …
Often, occlusion query results will be returned asychronously with
respect to the host processor’s operation. As a result, sometimes,
if a pixel count is queried, the host must wait until the result is
back. If <pname> is PIXEL_COUNT_AVAILABLE_NV, the value placed in
params indicates whether or not such a wait would occur if the pixel
count for that occlusion query were to be queried presently. A
result of TRUE means no wait would be required; a result of FALSE
means that some wait would occur. The length of this wait is
potentially unbounded. It must always be true that if the result for
one occlusion query is available, the result for all previous
occlusion queries must also be available at that point in time."
Will polling an occlusion query without a glFlush possibly cause
an infinite loop?
RESOLVED: Yes, this is a risk. If you ask for the result,
however, any flush required will be done automatically. It is
only when you are polling that this is a problem because there is
no guarantee that a flush has occured in the time since
glEndOcclusionQueryNV, and the spec is written to say that the
result is only "available" if the value could be returned
In short, if you use GL_PIXEL_COUNT_AVAILABLE_NV, you must use
glFlush, or your app may hang.
Am not sure that this is the problem, but I’m just giving you some debugging methods here.