r300g: Atomize DSA.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 10 Jan 2010 19:08:14 +0000 (11:08 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 10 Jan 2010 19:17:34 +0000 (11:17 -0800)
Also a bit of ztop.

src/gallium/drivers/r300/r300_blit.c
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_emit.h
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_state_derived.c

index 6c6e0567a44caa9147400c6f2ae85f6452e12cc4..b2fec4a50bf1672e5821bd42c26d4e9d8016776f 100644 (file)
@@ -28,7 +28,7 @@
 static void r300_blitter_save_states(struct r300_context* r300)
 {
     util_blitter_save_blend(r300->blitter, r300->blend_state.state);
-    util_blitter_save_depth_stencil_alpha(r300->blitter, r300->dsa_state);
+    util_blitter_save_depth_stencil_alpha(r300->blitter, r300->dsa_state.state);
     util_blitter_save_rasterizer(r300->blitter, r300->rs_state);
     util_blitter_save_fragment_shader(r300->blitter, r300->fs);
     util_blitter_save_vertex_shader(r300->blitter, r300->vs);
index 489f701e46d02907a69e5c2a2e1b300c745ac669..81a14c02b2d8df9cec8d895fc297d16fb698f366 100644 (file)
@@ -121,6 +121,7 @@ static void r300_setup_atoms(struct r300_context* r300)
     R300_INIT_ATOM(blend);
     R300_INIT_ATOM(blend_color);
     R300_INIT_ATOM(clip);
+    R300_INIT_ATOM(dsa);
 }
 
 struct pipe_context* r300_create_context(struct pipe_screen* screen,
index 3a54659df416c62ae4d0ec9210d11f72be58b9ac..1445ba5699d2b0a692bebdbac09ee22d460b39d9 100644 (file)
@@ -144,7 +144,6 @@ struct r300_ztop_state {
     uint32_t z_buffer_top;      /* R300_ZB_ZTOP: 0x4f14 */
 };
 
-#define R300_NEW_DSA             0x00000008
 #define R300_NEW_FRAMEBUFFERS    0x00000010
 #define R300_NEW_FRAGMENT_SHADER 0x00000020
 #define R300_NEW_FRAGMENT_SHADER_CONSTANTS    0x00000040
@@ -290,7 +289,7 @@ struct r300_context {
     /* Shader constants. */
     struct r300_constant_buffer shader_constants[PIPE_SHADER_TYPES];
     /* Depth, stencil, and alpha state. */
-    struct r300_dsa_state* dsa_state;
+    struct r300_atom dsa_state;
     /* Fragment shader. */
     struct r300_fragment_shader* fs;
     /* Framebuffer state. We currently don't need our own version of this. */
index 1517eed92350454585620a72a98314eb4c83def8..852ac9886384f4f9b6fc618fce3c35979949575e 100644 (file)
@@ -107,9 +107,9 @@ void r300_emit_clip_state(struct r300_context* r300, void* state)
 
 }
 
-void r300_emit_dsa_state(struct r300_context* r300,
-                           struct r300_dsa_state* dsa)
+void r300_emit_dsa_state(struct r300_context* r300, void* state)
 {
+    struct r300_dsa_state* dsa = (struct r300_dsa_state*)state;
     struct r300_screen* r300screen = r300_screen(r300->context.screen);
     CS_LOCALS(r300);
 
@@ -983,10 +983,6 @@ void r300_emit_dirty_state(struct r300_context* r300)
     int i, dirty_tex = 0;
     boolean invalid = FALSE;
 
-    if (!(r300->dirty_state)) {
-        return;
-    }
-
     /* Check size of CS. */
     /* Make sure we have at least 8*1024 spare dwords. */
     /* XXX It would be nice to know the number of dwords we really need to
@@ -1069,11 +1065,6 @@ validate:
         }
     }
 
-    if (r300->dirty_state & R300_NEW_DSA) {
-        r300_emit_dsa_state(r300, r300->dsa_state);
-        r300->dirty_state &= ~R300_NEW_DSA;
-    }
-
     if (r300->dirty_state & R300_NEW_FRAGMENT_SHADER) {
         r300_emit_fragment_depth_config(r300, r300->fs);
         if (r300screen->caps->is_r500) {
index 81b5f735eff73950f12d20dd788d611eb983c756..7cea50e627812ac6db252050b13294e4cc1f215b 100644 (file)
@@ -37,8 +37,7 @@ void r300_emit_blend_color_state(struct r300_context* r300, void* state);
 
 void r300_emit_clip_state(struct r300_context* r300, void* state);
 
-void r300_emit_dsa_state(struct r300_context* r300,
-                         struct r300_dsa_state* dsa);
+void r300_emit_dsa_state(struct r300_context* r300, void* state);
 
 void r300_emit_fragment_program_code(struct r300_context* r300,
                                      struct rX00_fragment_program_code* generic_code);
index 732292fdaf8ccd8a318ab2af1326c8e3afa79d00..288b2149b50a0a214fe54cdb29c7647263d52029 100644 (file)
@@ -463,8 +463,8 @@ static void r300_bind_dsa_state(struct pipe_context* pipe,
 {
     struct r300_context* r300 = r300_context(pipe);
 
-    r300->dsa_state = (struct r300_dsa_state*)state;
-    r300->dirty_state |= R300_NEW_DSA;
+    r300->dsa_state.state = state;
+    r300->dsa_state.dirty = TRUE;
 }
 
 /* Free DSA state. */
@@ -523,9 +523,9 @@ static void
         r300->dirty_state |= R300_NEW_SCISSOR;
     }
     r300->dirty_state |= R300_NEW_FRAMEBUFFERS;
-    r300->dirty_state |= R300_NEW_DSA;
 
     r300->blend_state.dirty = TRUE;
+    r300->dsa_state.dirty = TRUE;
 }
 
 /* Create fragment shader state. */
index 22660a52d9ac1d067125631fa765d78becbec26e..0f6ff02d9cedd8e379b3efbb0da98e117f07fedc 100644 (file)
@@ -508,7 +508,7 @@ static boolean r300_dsa_alpha_test_enabled(struct r300_dsa_state* dsa)
 
 static void r300_update_ztop(struct r300_context* r300)
 {
-    r300->ztop_state.z_buffer_top = R300_ZTOP_ENABLE;
+    uint32_t ztop = r300->ztop_state.z_buffer_top;
 
     /* This is important enough that I felt it warranted a comment.
      *
@@ -534,14 +534,20 @@ static void r300_update_ztop(struct r300_context* r300)
      */
 
     /* ZS writes */
-    if (r300_dsa_writes_depth_stencil(r300->dsa_state) &&
-           (r300_dsa_alpha_test_enabled(r300->dsa_state) ||   /* (1) */
-            r300->fs->info.uses_kill)) {                      /* (2) */
-        r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE;
-    } else if (r300_fragment_shader_writes_depth(r300->fs)) { /* (5) */
-        r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE;
-    } else if (r300->query_current) {                         /* (6) */
-        r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE;
+    if (r300_dsa_writes_depth_stencil(r300->dsa_state.state) &&
+           (r300_dsa_alpha_test_enabled(r300->dsa_state.state) ||/* (1) */
+            r300->fs->info.uses_kill)) {                         /* (2) */
+        ztop = R300_ZTOP_DISABLE;
+    } else if (r300_fragment_shader_writes_depth(r300->fs)) {    /* (5) */
+        ztop = R300_ZTOP_DISABLE;
+    } else if (r300->query_current) {                            /* (6) */
+        ztop = R300_ZTOP_DISABLE;
+    } else {
+        ztop = R300_ZTOP_ENABLE;
+    }
+
+    if (r300->ztop_state.z_buffer_top != ztop) {
+        r300->ztop_state.z_buffer_top = ztop;
     }
 }
 
@@ -553,8 +559,5 @@ void r300_update_derived_state(struct r300_context* r300)
         r300_update_derived_shader_state(r300);
     }
 
-    if (r300->dirty_state &
-            (R300_NEW_DSA | R300_NEW_FRAGMENT_SHADER | R300_NEW_QUERY)) {
-        r300_update_ztop(r300);
-    }
+    r300_update_ztop(r300);
 }