r300g: atomize PVS flush
authorMarek Olšák <maraeo@gmail.com>
Sat, 27 Feb 2010 22:26:19 +0000 (23:26 +0100)
committerMarek Olšák <maraeo@gmail.com>
Sat, 27 Feb 2010 23:46:35 +0000 (00:46 +0100)
The first non-state atom. It's better and cleaner to have it.

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

index 47883589a76ffe2fdfe71cd859ec4b3077ca24ed..5fc3a30804364a4f1622e298fb7f35b06cc125d6 100644 (file)
@@ -96,12 +96,12 @@ static void r300_flush_cb(void *data)
 }
 
 #define R300_INIT_ATOM(atomname, atomsize) \
-    r300->atomname##_state.name = #atomname; \
-    r300->atomname##_state.state = NULL; \
-    r300->atomname##_state.size = atomsize; \
-    r300->atomname##_state.emit = r300_emit_##atomname##_state; \
-    r300->atomname##_state.dirty = FALSE; \
-    insert_at_tail(&r300->atom_list, &r300->atomname##_state);
+    r300->atomname.name = #atomname; \
+    r300->atomname.state = NULL; \
+    r300->atomname.size = atomsize; \
+    r300->atomname.emit = r300_emit_##atomname; \
+    r300->atomname.dirty = FALSE; \
+    insert_at_tail(&r300->atom_list, &r300->atomname);
 
 static void r300_setup_atoms(struct r300_context* r300)
 {
@@ -114,19 +114,20 @@ static void r300_setup_atoms(struct r300_context* r300)
      * an upper bound on each atom, to keep the emission machinery from
      * underallocating space. */
     make_empty_list(&r300->atom_list);
-    R300_INIT_ATOM(invariant, 71);
-    R300_INIT_ATOM(ztop, 2);
-    R300_INIT_ATOM(blend, 8);
-    R300_INIT_ATOM(blend_color, 3);
-    R300_INIT_ATOM(clip, 29);
-    R300_INIT_ATOM(dsa, 8);
-    R300_INIT_ATOM(fb, 56);
-    R300_INIT_ATOM(rs, 25);
-    R300_INIT_ATOM(scissor, 3);
-    R300_INIT_ATOM(viewport, 9);
-    R300_INIT_ATOM(rs_block, 21);
-    R300_INIT_ATOM(vertex_format, 26);
-    R300_INIT_ATOM(vs, 1031);
+    R300_INIT_ATOM(invariant_state, 71);
+    R300_INIT_ATOM(ztop_state, 2);
+    R300_INIT_ATOM(blend_state, 8);
+    R300_INIT_ATOM(blend_color_state, 3);
+    R300_INIT_ATOM(clip_state, 29);
+    R300_INIT_ATOM(dsa_state, 8);
+    R300_INIT_ATOM(fb_state, 56);
+    R300_INIT_ATOM(rs_state, 25);
+    R300_INIT_ATOM(scissor_state, 3);
+    R300_INIT_ATOM(viewport_state, 9);
+    R300_INIT_ATOM(rs_block_state, 21);
+    R300_INIT_ATOM(vertex_format_state, 26);
+    R300_INIT_ATOM(pvs_flush, 2);
+    R300_INIT_ATOM(vs_state, 1031);
 
     /* Some non-CSO atoms need explicit space to store the state locally. */
     r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state);
index e3ad5869213f43dfdcf279cdfe3a9694e1a20510..32b64b6b28a47e4acfce25d33ba0e52ffa908794 100644 (file)
@@ -318,6 +318,8 @@ struct r300_context {
     struct r300_atom viewport_state;
     /* ZTOP state. */
     struct r300_atom ztop_state;
+    /* PVS flush. */
+    struct r300_atom pvs_flush;
 
     /* Invariant state. This must be emitted to get the engine started. */
     struct r300_atom invariant_state;
index a17ebb3ea87b5e5c13c2ca96154ca4eff4828ee0..6a0ede359b0d939125575a2c9d4271b879278591 100644 (file)
@@ -853,7 +853,7 @@ void r300_emit_vertex_format_state(struct r300_context* r300,
     END_CS;
 }
 
-static void r300_flush_pvs(struct r300_context* r300)
+void r300_emit_pvs_flush(struct r300_context* r300, unsigned size, void* state)
 {
     CS_LOCALS(r300);
 
@@ -887,8 +887,6 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state)
         return;
     }
 
-    r300_flush_pvs(r300);
-
     BEGIN_CS(9 + code->length);
     /* R300_VAP_PVS_CODE_CNTL_0
      * R300_VAP_PVS_CONST_CNTL
@@ -1170,10 +1168,6 @@ void r300_emit_dirty_state(struct r300_context* r300)
         r300_flush_textures(r300);
     }
 
-    if (r300->dirty_state & R300_NEW_VERTEX_SHADER_CONSTANTS || r300->vs_state.dirty) {
-        r300_flush_pvs(r300);
-    }
-
     if (r300->dirty_state & R300_NEW_VERTEX_SHADER_CONSTANTS) {
         struct r300_vertex_shader* vs = r300->vs_state.state;
         r300_emit_vs_constant_buffer(r300, &vs->code.constants);
index a9b75d5b37bd0856e975d77f70701c9975cffed2..5809bf4340544eb6f922213b41a81f4985dffee6 100644 (file)
@@ -96,6 +96,8 @@ void r300_emit_texture_count(struct r300_context* r300);
 void r300_emit_ztop_state(struct r300_context* r300,
                           unsigned size, void* state);
 
+void r300_emit_pvs_flush(struct r300_context* r300, unsigned size, void* state);
+
 void r300_flush_textures(struct r300_context* r300);
 
 unsigned r300_get_num_dirty_dwords(struct r300_context *r300);
index f1f0de1a46365c8bf6f8ccb9545e790183bdc958..79cd715af17a33225d132e07db303573f7173a39 100644 (file)
@@ -1109,6 +1109,7 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader)
         r300->vs_state.dirty = TRUE;
 
         r300->vertex_format_state.dirty = TRUE;
+        r300->pvs_flush.dirty = TRUE;
 
         if (r300->fs) {
             r300_vertex_shader_setup_wpos(r300);
@@ -1186,8 +1187,10 @@ static void r300_set_constant_buffer(struct pipe_context *pipe,
     r300->shader_constants[shader].count = buf->size / (4 * sizeof(float));
     pipe_buffer_unmap(pipe->screen, buf);
 
-    if (shader == PIPE_SHADER_VERTEX)
+    if (shader == PIPE_SHADER_VERTEX) {
         r300->dirty_state |= R300_NEW_VERTEX_SHADER_CONSTANTS;
+        r300->pvs_flush.dirty = TRUE;
+    }
     else if (shader == PIPE_SHADER_FRAGMENT)
         r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
 }