Mesa (master): r300g: add conditional rendering

Marek Olšák mareko at kemper.freedesktop.org
Sun Apr 4 07:00:37 UTC 2010


Module: Mesa
Branch: master
Commit: 655fe281556679669699052f37412a6243771619
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=655fe281556679669699052f37412a6243771619

Author: Marek Olšák <maraeo at gmail.com>
Date:   Sun Apr  4 08:59:09 2010 +0200

r300g: add conditional rendering

---

 src/gallium/drivers/r300/r300_context.h |    2 ++
 src/gallium/drivers/r300/r300_query.c   |   23 +++++++++++++++++++++++
 src/gallium/drivers/r300/r300_render.c  |    8 ++++++++
 3 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index 0a82484..0310923 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -377,6 +377,8 @@ struct r300_context {
     uint32_t zbuffer_bpp;
     /* Whether scissor is enabled. */
     boolean scissor_enabled;
+    /* Whether rendering is conditional and should be skipped. */
+    boolean skip_rendering;
     /* upload managers */
     struct u_upload_mgr *upload_vb;
     struct u_upload_mgr *upload_ib;
diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c
index f8b52d5..1778dc9 100644
--- a/src/gallium/drivers/r300/r300_query.c
+++ b/src/gallium/drivers/r300/r300_query.c
@@ -159,10 +159,33 @@ static boolean r300_get_query_result(struct pipe_context* pipe,
     return TRUE;
 }
 
+static void r300_render_condition(struct pipe_context *pipe,
+                                  struct pipe_query *query,
+                                  uint mode)
+{
+    struct r300_context *r300 = r300_context(pipe);
+    uint64_t result;
+    boolean wait;
+
+    if (query) {
+        wait = mode == PIPE_RENDER_COND_WAIT ||
+               mode == PIPE_RENDER_COND_BY_REGION_WAIT;
+
+        if (!r300_get_query_result(pipe, query, wait, &result)) {
+            r300->skip_rendering = FALSE;
+        }
+
+        r300->skip_rendering = result == 0;
+    } else {
+        r300->skip_rendering = FALSE;
+    }
+}
+
 void r300_init_query_functions(struct r300_context* r300) {
     r300->context.create_query = r300_create_query;
     r300->context.destroy_query = r300_destroy_query;
     r300->context.begin_query = r300_begin_query;
     r300->context.end_query = r300_end_query;
     r300->context.get_query_result = r300_get_query_result;
+    r300->context.render_condition = r300_render_condition;
 }
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index 1fb7eac..7898329 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -427,6 +427,10 @@ void r300_draw_range_elements(struct pipe_context* pipe,
 #endif
     unsigned short_count;
 
+    if (r300->skip_rendering) {
+        return;
+    }
+
     if (!u_trim_pipe_prim(mode, &count)) {
         return;
     }
@@ -503,6 +507,10 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode,
 #endif
     unsigned short_count;
 
+    if (r300->skip_rendering) {
+        return;
+    }
+
     if (!u_trim_pipe_prim(mode, &count)) {
         return;
     }




More information about the mesa-commit mailing list