summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}
}