[Mesa-dev] [PATCH 1/4] meta: Pause/resume an active occlusion query over any meta operation

Carl Worth cworth at cworth.org
Mon Dec 17 14:24:35 PST 2012


This avoids the occlusion query erroneously accumulating results during the
meta operation.

This fixes the following es3conform tests:

	occlusion_query_draw_occluded.test
 	occlusion_query_clear
	occlusion_query_custom_framebuffer
	occlusion_query_stencil_test
	occlusion_query_discarded_fragments
---
 src/mesa/drivers/common/meta.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index f95d207..e66476c 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -54,6 +54,7 @@
 #include "main/pixel.h"
 #include "main/pbo.h"
 #include "main/polygon.h"
+#include "main/queryobj.h"
 #include "main/readpix.h"
 #include "main/scissor.h"
 #include "main/shaderapi.h"
@@ -89,6 +90,9 @@ struct save_state
 {
    GLbitfield SavedState;  /**< bitmask of MESA_META_* flags */
 
+   /** MESA_META_CLEAR (and others?) */
+   struct gl_query_object *CurrentOcclusionObject;
+   
    /** MESA_META_ALPHA_TEST */
    GLboolean AlphaEnabled;
    GLenum AlphaFunc;
@@ -479,6 +483,13 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
    if (save->TransformFeedbackNeedsResume)
       _mesa_PauseTransformFeedback();
 
+   /* After saving the current occlusion object, call EndQuery so that no
+    * occlusion querying will be active during the meta-operation.
+    */
+   save->CurrentOcclusionObject = ctx->Query.CurrentOcclusionObject;
+   if (save->CurrentOcclusionObject)
+      _mesa_EndQuery(save->CurrentOcclusionObject->Target);
+
    if (state & MESA_META_ALPHA_TEST) {
       save->AlphaEnabled = ctx->Color.AlphaEnabled;
       save->AlphaFunc = ctx->Color.AlphaFunc;
@@ -807,6 +818,16 @@ _mesa_meta_end(struct gl_context *ctx)
    struct save_state *save = &ctx->Meta->Save[ctx->Meta->SaveStackDepth - 1];
    const GLbitfield state = save->SavedState;
 
+   /* After starting a new occlusion query, initialize the results to the
+    * values saved previously. The driver will then continue to increment
+    * these values.
+    */
+   if (save->CurrentOcclusionObject) {
+      _mesa_BeginQuery(save->CurrentOcclusionObject->Target,
+                       save->CurrentOcclusionObject->Id);
+      ctx->Query.CurrentOcclusionObject->Result = save->CurrentOcclusionObject->Result;
+   }
+
    if (state & MESA_META_ALPHA_TEST) {
       if (ctx->Color.AlphaEnabled != save->AlphaEnabled)
          _mesa_set_enable(ctx, GL_ALPHA_TEST, save->AlphaEnabled);
-- 
1.7.10.4



More information about the mesa-dev mailing list