r300g: Atomize ZTOP.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 10 Jan 2010 19:49:25 +0000 (11:49 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 10 Jan 2010 19:49:25 +0000 (11:49 -0800)
Also do state-change checks. ZTOP's too important to not check.

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_derived.c

index 81a14c02b2d8df9cec8d895fc297d16fb698f366..abd5d268747269a1d20c49644a68412f15856b13 100644 (file)
@@ -76,6 +76,7 @@ static void r300_destroy_context(struct pipe_context* context)
     FREE(r300->scissor_state);
     FREE(r300->vertex_info);
     FREE(r300->viewport_state);
+    FREE(r300->ztop_state.state);
     FREE(r300);
 }
 
@@ -118,6 +119,7 @@ static void r300_flush_cb(void *data)
 static void r300_setup_atoms(struct r300_context* r300)
 {
     make_empty_list(&r300->atom_list);
+    R300_INIT_ATOM(ztop);
     R300_INIT_ATOM(blend);
     R300_INIT_ATOM(blend_color);
     R300_INIT_ATOM(clip);
@@ -172,20 +174,21 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     r300->shader_hash_table = util_hash_table_create(r300_shader_key_hash,
         r300_shader_key_compare);
 
+    r300_setup_atoms(r300);
+
     r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state);
     r300->clip_state.state = CALLOC_STRUCT(pipe_clip_state);
     r300->rs_block = CALLOC_STRUCT(r300_rs_block);
     r300->scissor_state = CALLOC_STRUCT(r300_scissor_state);
     r300->vertex_info = CALLOC_STRUCT(r300_vertex_info);
     r300->viewport_state = CALLOC_STRUCT(r300_viewport_state);
+    r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state);
 
     /* Open up the OQ BO. */
     r300->oqbo = screen->buffer_create(screen, 4096,
             PIPE_BUFFER_USAGE_VERTEX, 4096);
     make_empty_list(&r300->query_list);
 
-    r300_setup_atoms(r300);
-
     r300_init_flush_functions(r300);
 
     r300_init_query_functions(r300);
index 1445ba5699d2b0a692bebdbac09ee22d460b39d9..56c49f7efa121ce493cd0961d0a1504d6b388b6f 100644 (file)
@@ -311,7 +311,7 @@ struct r300_context {
     /* Viewport state. */
     struct r300_viewport_state* viewport_state;
     /* ZTOP state. */
-    struct r300_ztop_state ztop_state;
+    struct r300_atom ztop_state;
 
     /* Vertex buffers for Gallium. */
     struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
index 852ac9886384f4f9b6fc618fce3c35979949575e..27fb9aa9ba8d5a823e64bc0f7d0fbcbe58c159a5 100644 (file)
@@ -113,7 +113,7 @@ void r300_emit_dsa_state(struct r300_context* r300, void* state)
     struct r300_screen* r300screen = r300_screen(r300->context.screen);
     CS_LOCALS(r300);
 
-    BEGIN_CS(r300screen->caps->is_r500 ? 10 : 8);
+    BEGIN_CS(r300screen->caps->is_r500 ? 8 : 6);
     OUT_CS_REG(R300_FG_ALPHA_FUNC, dsa->alpha_function);
 
     /* not needed since we use the 8bit alpha ref */
@@ -132,7 +132,6 @@ void r300_emit_dsa_state(struct r300_context* r300, void* state)
     }
 
     OUT_CS(dsa->stencil_ref_mask);
-    OUT_CS_REG(R300_ZB_ZTOP, r300->ztop_state.z_buffer_top);
 
     /* XXX it seems r3xx doesn't support STENCILREFMASK_BF */
     if (r300screen->caps->is_r500) {
@@ -956,6 +955,16 @@ void r300_emit_texture_count(struct r300_context* r300)
 
 }
 
+void r300_emit_ztop_state(struct r300_context* r300, void* state)
+{
+    struct r300_ztop_state* ztop = (struct r300_ztop_state*)state;
+    CS_LOCALS(r300);
+
+    BEGIN_CS(2);
+    OUT_CS_REG(R300_ZB_ZTOP, ztop->z_buffer_top);
+    END_CS;
+}
+
 void r300_flush_textures(struct r300_context* r300)
 {
     CS_LOCALS(r300);
index 7cea50e627812ac6db252050b13294e4cc1f215b..0ccae0031bd5eb98a709024b991fd3e3568e1bd7 100644 (file)
@@ -90,6 +90,8 @@ void r300_emit_viewport_state(struct r300_context* r300,
 
 void r300_emit_texture_count(struct r300_context* r300);
 
+void r300_emit_ztop_state(struct r300_context* r300, void* state);
+
 void r300_flush_textures(struct r300_context* r300);
 
 /* Emit all dirty state. */
index 0f6ff02d9cedd8e379b3efbb0da98e117f07fedc..a4029fca49f08c4f16a8044b697297f1ad0daa8d 100644 (file)
@@ -508,7 +508,9 @@ static boolean r300_dsa_alpha_test_enabled(struct r300_dsa_state* dsa)
 
 static void r300_update_ztop(struct r300_context* r300)
 {
-    uint32_t ztop = r300->ztop_state.z_buffer_top;
+    struct r300_ztop_state* ztop_state =
+        (struct r300_ztop_state*)r300->ztop_state.state;
+    uint32_t ztop = ztop_state->z_buffer_top;
 
     /* This is important enough that I felt it warranted a comment.
      *
@@ -546,8 +548,9 @@ static void r300_update_ztop(struct r300_context* r300)
         ztop = R300_ZTOP_ENABLE;
     }
 
-    if (r300->ztop_state.z_buffer_top != ztop) {
-        r300->ztop_state.z_buffer_top = ztop;
+    if (ztop_state->z_buffer_top != ztop) {
+        ztop_state->z_buffer_top = ztop;
+        r300->ztop_state.dirty = TRUE;
     }
 }