r300g: clear can be killed by render condition
authorMarek Olšák <maraeo@gmail.com>
Sun, 29 May 2011 04:12:22 +0000 (06:12 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sun, 29 May 2011 14:17:11 +0000 (16:17 +0200)
Fixes piglit:
- NV_conditional_render/clear

src/gallium/drivers/r300/r300_blit.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_render.c

index 7f430269e417dd64a82070632a194b1c8b79af28..388ebcdbf32d1d5c6aa6816f3cb85196be56017d 100644 (file)
 
 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);
     }
@@ -57,11 +67,11 @@ static void r300_blitter_begin(struct r300_context* r300, enum r300_blitter_op o
     util_blitter_save_vertex_buffers(r300->blitter, r300->vbuf_mgr->nr_vertex_buffers,
                                      r300->vbuf_mgr->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,
@@ -374,7 +397,7 @@ void r300_decompress_zmask(struct r300_context *r300)
     r300->zmask_decompress = TRUE;
     r300_mark_atom_dirty(r300, &r300->hyperz_state);
 
-    r300_blitter_begin(r300, R300_CLEAR);
+    r300_blitter_begin(r300, R300_DECOMPRESS);
     util_blitter_clear_depth_custom(r300->blitter, fb->width, fb->height, 0,
                                     r300->dsa_decompress_zmask);
     r300_blitter_end(r300);
index 139dd210b8fda8bb9ea6c840b0c0757543a1f098..d71db0001a9783bfaaec7ee37a8f7c74ad0fd833 100644 (file)
@@ -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). */
index 429b85545f70a6dfd04972c7ae40db14044fa806..b24e7faa644e648d6e294db9ff480bbc0aa1c921 100644 (file)
@@ -1200,6 +1200,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)