summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorNeil Roberts <[email protected]>2014-11-25 17:52:27 +0000
committerEmil Velikov <[email protected]>2015-02-24 12:21:33 +0000
commit7bcdde5174b80c6a4bddf13daae6c7934c995661 (patch)
treecd36426790b6af83caa5af674687d89e406155bb /src/mesa
parentf2e513b2c0abfde2c5c91930714f0b58d46ec3df (diff)
meta: Fix saving the results of the current occlusion query
When restoring the current state in _mesa_meta_end it was previously trying to copy the on-going sample count of the current occlusion query into the new query after restarting it so that the driver will continue adding to the previous value. This wouldn't work for two reasons. Firstly, the query might not be ready yet so the Result member will usually be zero. Secondly the saved query is stored as a pointer to the query object, not a copy of the struct, so it is actually restarting the exact same object. Copying the result value is just copying between identical addresses with no effect. The call to _mesa_BeginQuery will have always reset it back to zero. This patch fixes it by making it actually wait for the query object to be ready before grabbing the previous result. The downside of doing this is that it could introduce a stall but I think this situation is unlikely so it might not matter too much. A better solution might be to introduce a real suspend/resume mechanism to the driver interface. This could be implemented in the i965 driver by saving the depth count multiple times like it does in the i945 driver. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88248 Reviewed-by: Carl Worth <[email protected]> Cc: "10.5" <[email protected]> (cherry picked from commit bb77745681e179b53ea64da7bc1987b57643b7b0)
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/common/meta.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index bb0073074e7..3636ee83b9b 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -827,15 +827,18 @@ _mesa_meta_end(struct gl_context *ctx)
const GLbitfield state = save->SavedState;
int i;
- /* After starting a new occlusion query, initialize the results to the
- * values saved previously. The driver will then continue to increment
- * these values.
- */
+ /* Grab the result of the old occlusion query before starting it again. The
+ * old result is added to the result of the new query so the driver will
+ * continue adding where it left off. */
if (state & MESA_META_OCCLUSION_QUERY) {
if (save->CurrentOcclusionObject) {
- _mesa_BeginQuery(save->CurrentOcclusionObject->Target,
- save->CurrentOcclusionObject->Id);
- ctx->Query.CurrentOcclusionObject->Result = save->CurrentOcclusionObject->Result;
+ struct gl_query_object *q = save->CurrentOcclusionObject;
+ GLuint64EXT result;
+ if (!q->Ready)
+ ctx->Driver.WaitQuery(ctx, q);
+ result = q->Result;
+ _mesa_BeginQuery(q->Target, q->Id);
+ ctx->Query.CurrentOcclusionObject->Result += result;
}
}