r300g: atomize invalidation of texture caches
authorMarek Olšák <maraeo@gmail.com>
Sat, 27 Feb 2010 22:37:01 +0000 (23:37 +0100)
committerMarek Olšák <maraeo@gmail.com>
Sat, 27 Feb 2010 23:46:35 +0000 (00:46 +0100)
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 5fc3a30804364a4f1622e298fb7f35b06cc125d6..5f50b60eab7ff0a772c7ae4cf3965f90449e504c 100644 (file)
@@ -128,6 +128,7 @@ static void r300_setup_atoms(struct r300_context* r300)
     R300_INIT_ATOM(vertex_format_state, 26);
     R300_INIT_ATOM(pvs_flush, 2);
     R300_INIT_ATOM(vs_state, 1031);
+    R300_INIT_ATOM(texture_cache_inval, 2);
 
     /* Some non-CSO atoms need explicit space to store the state locally. */
     r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state);
index 32b64b6b28a47e4acfce25d33ba0e52ffa908794..47f2aa5154a68554ba8829238c9af1e96422269f 100644 (file)
@@ -320,6 +320,8 @@ struct r300_context {
     struct r300_atom ztop_state;
     /* PVS flush. */
     struct r300_atom pvs_flush;
+    /* Texture cache invalidate. */
+    struct r300_atom texture_cache_inval;
 
     /* Invariant state. This must be emitted to get the engine started. */
     struct r300_atom invariant_state;
index 6a0ede359b0d939125575a2c9d4271b879278591..ad19725e60bcd7d79de00a3e2d5eca4104bf4554 100644 (file)
@@ -1002,7 +1002,7 @@ void r300_emit_ztop_state(struct r300_context* r300,
     END_CS;
 }
 
-void r300_flush_textures(struct r300_context* r300)
+void r300_emit_texture_cache_inval(struct r300_context* r300, unsigned size, void* state)
 {
     CS_LOCALS(r300);
 
@@ -1107,7 +1107,6 @@ void r300_emit_dirty_state(struct r300_context* r300)
     struct r300_screen* r300screen = r300_screen(r300->context.screen);
     struct r300_atom* atom;
     unsigned i;
-    int dirty_tex = 0;
 
     if (r300->dirty_state & R300_NEW_QUERY) {
         r300_emit_query_start(r300);
@@ -1155,7 +1154,6 @@ void r300_emit_dirty_state(struct r300_context* r300)
                                      r300->sampler_states[i],
                                      r300->textures[i],
                                      i);
-                    dirty_tex |= r300->dirty_state & (R300_NEW_TEXTURE << i);
                 }
                 r300->dirty_state &=
                     ~((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i));
@@ -1164,10 +1162,6 @@ void r300_emit_dirty_state(struct r300_context* r300)
         r300->dirty_state &= ~(R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES);
     }
 
-    if (dirty_tex) {
-        r300_flush_textures(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 5809bf4340544eb6f922213b41a81f4985dffee6..c73b016b76c96ba6dd21556f5ad13af3f5062833 100644 (file)
@@ -98,7 +98,7 @@ void r300_emit_ztop_state(struct r300_context* r300,
 
 void r300_emit_pvs_flush(struct r300_context* r300, unsigned size, void* state);
 
-void r300_flush_textures(struct r300_context* r300);
+void r300_emit_texture_cache_inval(struct r300_context* r300, unsigned size, void* state);
 
 unsigned r300_get_num_dirty_dwords(struct r300_context *r300);
 
index 79cd715af17a33225d132e07db303573f7173a39..15e0a0ad358b86e3f90d2a0e7b73fbe939415c9e 100644 (file)
@@ -922,6 +922,7 @@ static void r300_set_sampler_textures(struct pipe_context* pipe,
 {
     struct r300_context* r300 = r300_context(pipe);
     boolean is_r500 = r300_screen(r300->context.screen)->caps->is_r500;
+    boolean dirty_tex = FALSE;
     int i;
 
     /* XXX magic num */
@@ -934,6 +935,7 @@ static void r300_set_sampler_textures(struct pipe_context* pipe,
             pipe_texture_reference((struct pipe_texture**)&r300->textures[i],
                 texture[i]);
             r300->dirty_state |= (R300_NEW_TEXTURE << i);
+            dirty_tex = TRUE;
 
             /* R300-specific - set the texrect factor in a fragment shader */
             if (!is_r500 && r300->textures[i]->is_npot) {
@@ -953,6 +955,10 @@ static void r300_set_sampler_textures(struct pipe_context* pipe,
     }
 
     r300->texture_count = count;
+
+    if (dirty_tex) {
+        r300->texture_cache_inval.dirty = TRUE;
+    }
 }
 
 static void r300_set_scissor_state(struct pipe_context* pipe,