Mesa (7.10): r300g: clear can be killed by render condition

Marek Olšák mareko at kemper.freedesktop.org
Fri Jun 10 11:33:00 PDT 2011


Module: Mesa
Branch: 7.10
Commit: 3d5e6c4c1e8f670bf6ce128b80e494d53024b60d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3d5e6c4c1e8f670bf6ce128b80e494d53024b60d

Author: Marek Olšák <maraeo at gmail.com>
Date:   Fri Jun 10 19:06:04 2011 +0200

r300g: clear can be killed by render condition

Fixes piglit:
- NV_conditional_render/clear
(cherry picked from commit 76056510bcd35b6b5607b572c0c0ff47b5c5e7e2)

Conflicts:

	src/gallium/drivers/r300/r300_blit.c

---

 src/gallium/drivers/r300/r300_blit.c    |   37 +++++++++++++++++++++++++------
 src/gallium/drivers/r300/r300_context.h |    2 +
 src/gallium/drivers/r300/r300_render.c  |    3 ++
 3 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c
index 6e88643..f4823d4 100644
--- a/src/gallium/drivers/r300/r300_blit.c
+++ b/src/gallium/drivers/r300/r300_blit.c
@@ -31,14 +31,24 @@
 
 enum r300_blitter_op /* bitmask */
 {
-    R300_CLEAR         = 1,
-    R300_CLEAR_SURFACE = 2,
-    R300_COPY          = 4
+    R300_STOP_QUERY         = 1,
+    R300_SAVE_TEXTURES      = 2,
+    R300_SAVE_FRAMEBUFFER   = 4,
+    R300_IGNORE_RENDER_COND = 8,
+
+    R300_CLEAR         = R300_STOP_QUERY,
+
+    R300_CLEAR_SURFACE = R300_STOP_QUERY | R300_SAVE_FRAMEBUFFER,
+
+    R300_COPY          = R300_STOP_QUERY | R300_SAVE_FRAMEBUFFER |
+                         R300_SAVE_TEXTURES | R300_IGNORE_RENDER_COND,
+
+    R300_DECOMPRESS    = R300_STOP_QUERY | R300_IGNORE_RENDER_COND,
 };
 
 static void r300_blitter_begin(struct r300_context* r300, enum r300_blitter_op op)
 {
-    if (r300->query_current) {
+    if ((op & R300_STOP_QUERY) && r300->query_current) {
         r300->blitter_saved_query = r300->query_current;
         r300_stop_query(r300);
     }
@@ -58,10 +68,10 @@ static void r300_blitter_begin(struct r300_context* r300, enum r300_blitter_op o
     util_blitter_save_vertex_buffers(r300->blitter, r300->vertex_buffer_count,
                                      r300->vertex_buffer);
 
-    if (op & (R300_CLEAR_SURFACE | R300_COPY))
+    if (op & R300_SAVE_FRAMEBUFFER)
         util_blitter_save_framebuffer(r300->blitter, r300->fb_state.state);
 
-    if (op & R300_COPY) {
+    if (op & R300_SAVE_TEXTURES) {
         struct r300_textures_state* state =
             (struct r300_textures_state*)r300->textures_state.state;
 
@@ -73,6 +83,14 @@ static void r300_blitter_begin(struct r300_context* r300, enum r300_blitter_op o
             r300->blitter, state->sampler_view_count,
             (struct pipe_sampler_view**)state->sampler_views);
     }
+
+    if (op & R300_IGNORE_RENDER_COND) {
+        /* Save the flag. */
+        r300->blitter_saved_skip_rendering = r300->skip_rendering+1;
+        r300->skip_rendering = FALSE;
+    } else {
+        r300->blitter_saved_skip_rendering = 0;
+    }
 }
 
 static void r300_blitter_end(struct r300_context *r300)
@@ -81,6 +99,11 @@ static void r300_blitter_end(struct r300_context *r300)
         r300_resume_query(r300, r300->blitter_saved_query);
         r300->blitter_saved_query = NULL;
     }
+
+    if (r300->blitter_saved_skip_rendering) {
+        /* Restore the flag. */
+        r300->skip_rendering = r300->blitter_saved_skip_rendering-1;
+    }
 }
 
 static uint32_t r300_depth_clear_cb_value(enum pipe_format format,
@@ -320,7 +343,7 @@ void r300_flush_depth_stencil(struct pipe_context *pipe,
     dstsurf = pipe->create_surface(pipe, dst, &surf_tmpl);
 
     r300->z_decomp_rd = TRUE;
-    r300_blitter_begin(r300, R300_CLEAR_SURFACE);
+    r300_blitter_begin(r300, R300_DECOMPRESS);
     util_blitter_flush_depth_stencil(r300->blitter, dstsurf);
     r300_blitter_end(r300);
     r300->z_decomp_rd = FALSE;
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index c719c02..ed4894d 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -584,6 +584,8 @@ struct r300_context {
     uint32_t zbuffer_bpp;
     /* Whether rendering is conditional and should be skipped. */
     boolean skip_rendering;
+    /* The flag above saved by blitter. */
+    unsigned char blitter_saved_skip_rendering;
     /* Point sprites texcoord index,  1 bit per texcoord */
     int sprite_coord_enable;
     /* Whether two-sided color selection is enabled (AKA light_twoside). */
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index 494c452..bb06d3d 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -1104,6 +1104,9 @@ static void r300_blitter_draw_rectangle(struct blitter_context *blitter,
     const float zeros[4] = {0, 0, 0, 0};
     CS_LOCALS(r300);
 
+    if (r300->skip_rendering)
+        return;
+
     r300->context.set_vertex_buffers(&r300->context, 0, NULL);
 
     if (type == UTIL_BLITTER_ATTRIB_TEXCOORD)



More information about the mesa-commit mailing list