On 12/17/2012 02:24 PM, Carl Worth wrote:
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);
+

I think we need a flag to select this behavior. There are some meta ops that *do* generate fragments (e.g., _mesa_meta_DrawPixels), and this will prevent them from being counted.

     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);


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to