Mesa (gallium-render-condition-predicate): gallium: add a predicate value to render_condition()

Keith Whitwell keithw at kemper.freedesktop.org
Thu Jun 10 18:01:27 UTC 2010


Module: Mesa
Branch: gallium-render-condition-predicate
Commit: 01202aafb6cb1c77332e8938de88f6f081070bf2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=01202aafb6cb1c77332e8938de88f6f081070bf2

Author: Keith Whitwell <keithw at vmware.com>
Date:   Thu Jun 10 18:55:38 2010 +0100

gallium: add a predicate value to render_condition()

This can be used to invert the condition under which we render / do
not render subsequent commands.

The old behaviour matches the case where the predicate is FALSE.

---

 src/gallium/drivers/nv50/nv50_query.c     |    8 +++++++-
 src/gallium/drivers/r300/r300_query.c     |    3 ++-
 src/gallium/drivers/softpipe/sp_context.c |    2 ++
 src/gallium/drivers/softpipe/sp_context.h |    1 +
 src/gallium/drivers/softpipe/sp_query.c   |   11 +++++++++--
 src/gallium/include/pipe/p_context.h      |    2 ++
 src/mesa/state_tracker/st_cb_condrender.c |    2 +-
 7 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c
index 53f9482..59aa2f9 100644
--- a/src/gallium/drivers/nv50/nv50_query.c
+++ b/src/gallium/drivers/nv50/nv50_query.c
@@ -128,13 +128,19 @@ nv50_query_result(struct pipe_context *pipe, struct pipe_query *pq,
 
 static void
 nv50_render_condition(struct pipe_context *pipe,
-		      struct pipe_query *pq, uint mode)
+		      struct pipe_query *pq,
+                      boolean predicate,
+                      uint mode)
 {
 	struct nv50_context *nv50 = nv50_context(pipe);
 	struct nouveau_channel *chan = nv50->screen->base.channel;
 	struct nouveau_grobj *tesla = nv50->screen->tesla;
 	struct nv50_query *q;
 
+        /* Mesa state tracker only uses FALSE so far:
+         */
+        assert(predicate == FALSE);
+
 	if (!pq) {
 		BEGIN_RING(chan, tesla, NV50TCL_COND_MODE, 1);
 		OUT_RING  (chan, NV50TCL_COND_MODE_ALWAYS);
diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c
index 7c08806..d0a430b 100644
--- a/src/gallium/drivers/r300/r300_query.c
+++ b/src/gallium/drivers/r300/r300_query.c
@@ -172,6 +172,7 @@ static boolean r300_get_query_result(struct pipe_context* pipe,
 
 static void r300_render_condition(struct pipe_context *pipe,
                                   struct pipe_query *query,
+                                  boolean predicate,
                                   uint mode)
 {
     struct r300_context *r300 = r300_context(pipe);
@@ -186,7 +187,7 @@ static void r300_render_condition(struct pipe_context *pipe,
             r300->skip_rendering = FALSE;
         }
 
-        r300->skip_rendering = result == 0;
+        r300->skip_rendering = (result > 0) == predicate;
     } else {
         r300->skip_rendering = FALSE;
     }
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index 401a28a..13ae91c 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -184,11 +184,13 @@ softpipe_is_resource_referenced( struct pipe_context *pipe,
 static void
 softpipe_render_condition( struct pipe_context *pipe,
                            struct pipe_query *query,
+                           boolean predicate,
                            uint mode )
 {
    struct softpipe_context *softpipe = softpipe_context( pipe );
 
    softpipe->render_cond_query = query;
+   softpipe->render_cond_predicate = predicate;
    softpipe->render_cond_mode = mode;
 }
 
diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h
index e641a81..bd0141d 100644
--- a/src/gallium/drivers/softpipe/sp_context.h
+++ b/src/gallium/drivers/softpipe/sp_context.h
@@ -135,6 +135,7 @@ struct softpipe_context {
 
    /** Conditional query object and mode */
    struct pipe_query *render_cond_query;
+   boolean render_cond_predicate;
    uint render_cond_mode;
 
    /** Software quad rendering pipeline */
diff --git a/src/gallium/drivers/softpipe/sp_query.c b/src/gallium/drivers/softpipe/sp_query.c
index 245f1b5..23f65ef 100644
--- a/src/gallium/drivers/softpipe/sp_query.c
+++ b/src/gallium/drivers/softpipe/sp_query.c
@@ -168,8 +168,15 @@ softpipe_check_render_cond(struct softpipe_context *sp)
            sp->render_cond_mode == PIPE_RENDER_COND_BY_REGION_WAIT);
 
    b = pipe->get_query_result(pipe, sp->render_cond_query, wait, &result);
-   if (b)
-      return result > 0;
+   if (b) {
+      /* Consider the condition TRUE if any fragments were rasterized.
+       */
+      boolean predicate = (result > 0);
+      
+      /* Permit rendering if condition does not match render_cond_predicate.
+       */
+      return predicate != sp->render_cond_predicate;
+   }
    else
       return TRUE;
 }
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index 72afad6..8732eab 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -111,10 +111,12 @@ struct pipe_context {
    /**
     * Predicate subsequent rendering on occlusion query result
     * \param query  the query predicate, or NULL if no predicate
+    * \param value  the condition on which to permit rendering
     * \param mode  one of PIPE_RENDER_COND_x
     */
    void (*render_condition)( struct pipe_context *pipe,
                              struct pipe_query *query,
+                             boolean predicate_value,
                              uint mode );
 
    /**
diff --git a/src/mesa/state_tracker/st_cb_condrender.c b/src/mesa/state_tracker/st_cb_condrender.c
index b509d43..f65f71e 100644
--- a/src/mesa/state_tracker/st_cb_condrender.c
+++ b/src/mesa/state_tracker/st_cb_condrender.c
@@ -72,7 +72,7 @@ st_BeginConditionalRender(GLcontext *ctx, struct gl_query_object *q,
       m = PIPE_RENDER_COND_WAIT;
    }
 
-   pipe->render_condition(pipe, stq->pq, m);
+   pipe->render_condition(pipe, stq->pq, FALSE, m);
 }
 
 




More information about the mesa-commit mailing list