r300g: add a function for marking framebuffer atoms as dirty
authorMarek Olšák <maraeo@gmail.com>
Thu, 8 Jul 2010 04:20:01 +0000 (06:20 +0200)
committerMarek Olšák <maraeo@gmail.com>
Thu, 8 Jul 2010 16:02:30 +0000 (18:02 +0200)
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_state.c

index 3ca3436cdd66d83427ae070765da7190b3299a2b..7f43281af4abb15dfa481b9cdf1062f0198960e1 100644 (file)
@@ -233,7 +233,7 @@ static void r300_setup_atoms(struct r300_context* r300)
     r300->query_start.allow_null_state = TRUE;
     r300->texture_cache_inval.allow_null_state = TRUE;
 
-    /* Some states must be marked dirty here to properly set up
+    /* Some states must be marked as dirty here to properly set up
      * hardware in the first command stream. */
     r300->invariant_state.dirty = TRUE;
     r300->pvs_flush.dirty = TRUE;
index 9a4df0a375e24e15934d29217d7d1ec355ed4dee..2483af7fb5e315b2ae75cdc943cec9f98054b208 100644 (file)
@@ -592,6 +592,12 @@ void r300_translate_index_buffer(struct r300_context *r300,
 void r300_plug_in_stencil_ref_fallback(struct r300_context *r300);
 
 /* r300_state.c */
+enum r300_fb_state_change {
+    R300_CHANGED_FB_STATE = 0
+};
+
+void r300_mark_fb_state_dirty(struct r300_context *r300,
+                              enum r300_fb_state_change change);
 void r300_mark_fs_code_dirty(struct r300_context *r300);
 
 /* r300_debug.c */
index 4bb5757689994475f35a91fd9d47a4b48ecb1d57..4fbe8bfa4e6481069200fa2b4a556bb521e98cbd 100644 (file)
@@ -670,6 +670,30 @@ static void r300_print_fb_surf_info(struct pipe_surface *surf, unsigned index,
             tex->last_level, util_format_short_name(tex->format));
 }
 
+void r300_mark_fb_state_dirty(struct r300_context *r300,
+                              enum r300_fb_state_change change)
+{
+    struct pipe_framebuffer_state *state = r300->fb_state.state;
+
+    /* What is marked as dirty depends on the enum r300_fb_state_change. */
+    r300->gpu_flush.dirty = TRUE;
+    r300->fb_state.dirty = TRUE;
+    r300->hyperz_state.dirty = TRUE;
+
+    if (change == R300_CHANGED_FB_STATE) {
+        r300->aa_state.dirty = TRUE;
+        r300->fb_state_pipelined.dirty = TRUE;
+    }
+
+    /* Now compute the fb_state atom size. */
+    r300->fb_state.size = 2 + (8 * state->nr_cbufs);
+
+    if (state->zsbuf)
+        r300->fb_state.size += r300->screen->caps.has_hiz ? 18 : 14;
+
+    /* The size of the rest of atoms stays the same. */
+}
+
 static void
     r300_set_framebuffer_state(struct pipe_context* pipe,
                                const struct pipe_framebuffer_state* state)
@@ -698,12 +722,6 @@ static void
         draw_flush(r300->draw);
     }
 
-    r300->gpu_flush.dirty = TRUE;
-    r300->aa_state.dirty = TRUE;
-    r300->fb_state.dirty = TRUE;
-    r300->hyperz_state.dirty = TRUE;
-    r300->fb_state_pipelined.dirty = TRUE;
-
     /* If nr_cbufs is changed from zero to non-zero or vice versa... */
     if (!!old_state->nr_cbufs != !!state->nr_cbufs) {
         r300->blend_state.dirty = TRUE;
@@ -718,10 +736,7 @@ static void
 
     util_assign_framebuffer_state(r300->fb_state.state, state);
 
-    r300->fb_state.size =
-            2 +
-            (8 * state->nr_cbufs) +
-            (state->zsbuf ? (r300->screen->caps.has_hiz ? 18 : 14) : 0);
+    r300_mark_fb_state_dirty(r300, R300_CHANGED_FB_STATE);
 
     /* Polygon offset depends on the zbuffer bit depth. */
     if (state->zsbuf && r300->polygon_offset_enabled) {