r300g: atomize compiler's state variables for fragment shader
authorMarek Olšák <maraeo@gmail.com>
Mon, 12 Apr 2010 01:46:03 +0000 (03:46 +0200)
committerMarek Olšák <maraeo@gmail.com>
Mon, 12 Apr 2010 02:16:08 +0000 (04:16 +0200)
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 8d8612ed6ebb6416193807cc9fdef8c045cdf9b5..061322b75fd53da9aa005afb7331204aabe21345 100644 (file)
@@ -116,10 +116,12 @@ static void r300_setup_atoms(struct r300_context* r300)
     R300_INIT_ATOM(texture_cache_inval, 2);
     R300_INIT_ATOM(textures_state, 0);
     R300_INIT_ATOM(fs, 0);
+    R300_INIT_ATOM(fs_rc_constant_state, 0);
 
     /* Replace emission functions for r500. */
     if (r300->screen->caps.is_r500) {
         r300->fs.emit = r500_emit_fs;
+        r300->fs_rc_constant_state.emit = r500_emit_fs_rc_constant_state;
     }
 
     /* Some non-CSO atoms need explicit space to store the state locally. */
index 51beaa50f57855418e00a8ccbd3f5382906fe187..2e248a4d6cdd1fb8fe658fd57208f60d87561462 100644 (file)
@@ -358,6 +358,8 @@ struct r300_context {
     struct r300_atom dsa_state;
     /* Fragment shader. */
     struct r300_atom fs;
+    /* Fragment shader RC_CONSTANT_STATE variables. */
+    struct r300_atom fs_rc_constant_state;
     /* Framebuffer state. */
     struct r300_atom fb_state;
     /* Rasterizer state. */
index 2fa3f6fe2eca50f56a2586e9b4878e4b9f8a0ae6..fd857a4ac1954f129d26b363453cfce8267a0378 100644 (file)
@@ -344,10 +344,10 @@ void r300_emit_fs_constant_buffer(struct r300_context* r300,
     END_CS;
 }
 
-void r300_emit_fs_constant_rc_state(struct r300_context* r300,
-                                    struct rc_constant_list* constants)
+void r300_emit_fs_rc_constant_state(struct r300_context* r300, unsigned size, void *state)
 {
     struct r300_fragment_shader *fs = r300_fs(r300);
+    struct rc_constant_list *constants = &fs->shader->code.constants;
     unsigned i;
     unsigned count = fs->shader->rc_state_count;
     unsigned first = fs->shader->externals_count;
@@ -465,10 +465,10 @@ void r500_emit_fs_constant_buffer(struct r300_context* r300,
     END_CS;
 }
 
-void r500_emit_fs_constant_rc_state(struct r300_context* r300,
-                                    struct rc_constant_list* constants)
+void r500_emit_fs_rc_constant_state(struct r300_context* r300, unsigned size, void *state)
 {
     struct r300_fragment_shader *fs = r300_fs(r300);
+    struct rc_constant_list *constants = &fs->shader->code.constants;
     unsigned i;
     unsigned count = fs->shader->rc_state_count;
     unsigned first = fs->shader->externals_count;
@@ -1215,13 +1215,9 @@ void r300_emit_dirty_state(struct r300_context* r300)
         if (r300screen->caps.is_r500) {
             r500_emit_fs_constant_buffer(r300,
                                          &r300_fs(r300)->shader->code.constants);
-            r500_emit_fs_constant_rc_state(r300,
-                                           &r300_fs(r300)->shader->code.constants);
         } else {
             r300_emit_fs_constant_buffer(r300,
                                          &r300_fs(r300)->shader->code.constants);
-            r300_emit_fs_constant_rc_state(r300,
-                                           &r300_fs(r300)->shader->code.constants);
         }
         r300->dirty_state &= ~R300_NEW_FRAGMENT_SHADER_CONSTANTS;
     }
index 266538d06f3dd98519df2d9a6f1f6e283a346cf7..09737fbb5975d56b95b0fa5bdf03aa6d6e98f5b4 100644 (file)
@@ -50,8 +50,7 @@ void r300_emit_fs(struct r300_context* r300, unsigned size, void *state);
 void r300_emit_fs_constant_buffer(struct r300_context* r300,
                                   struct rc_constant_list* constants);
 
-void r300_emit_fs_constant_rc_state(struct r300_context* r300,
-                                    struct rc_constant_list* constants);
+void r300_emit_fs_rc_constant_state(struct r300_context* r300, unsigned size, void *state);
 
 unsigned r500_get_fs_atom_size(struct r300_context *r300);
 
@@ -60,8 +59,7 @@ void r500_emit_fs(struct r300_context* r300, unsigned size, void *state);
 void r500_emit_fs_constant_buffer(struct r300_context* r300,
                                   struct rc_constant_list* constants);
 
-void r500_emit_fs_constant_rc_state(struct r300_context* r300,
-                                    struct rc_constant_list* constants);
+void r500_emit_fs_rc_constant_state(struct r300_context* r300, unsigned size, void *state);
 
 void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state);
 
index 1a0087241d7114f2b752fa0b2d2b3688013f1e93..aacaa4e6afe45b66d56db69893d0fb5214527fe1 100644 (file)
@@ -688,11 +688,14 @@ static void r300_mark_fs_code_dirty(struct r300_context *r300)
     struct r300_fragment_shader* fs = r300_fs(r300);
 
     r300->fs.dirty = TRUE;
+    r300->fs_rc_constant_state.dirty = TRUE;
 
     if (r300->screen->caps.is_r500) {
         r300->fs.size = r500_get_fs_atom_size(r300);
+        r300->fs_rc_constant_state.size = fs->shader->rc_state_count * 7;
     } else {
         r300->fs.size = r300_get_fs_atom_size(r300);
+        r300->fs_rc_constant_state.size = fs->shader->rc_state_count * 5;
     }
 
     r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
@@ -999,9 +1002,7 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe,
             /* R300-specific - set the texrect factor in the fragment shader */
             texture = r300_texture(views[i]->texture);
             if (!is_r500 && texture->uses_pitch) {
-                /* XXX It would be nice to re-emit just 1 constant,
-                 * XXX not all of them */
-                r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
+                r300->fs_rc_constant_state.dirty = TRUE;
             }
         }
     }
@@ -1115,7 +1116,7 @@ static void r300_set_viewport_state(struct pipe_context* pipe,
 
     r300->viewport_state.dirty = TRUE;
     if (r300->fs.state && r300_fs(r300)->shader->inputs.wpos != ATTR_UNUSED) {
-        r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
+        r300->fs_rc_constant_state.dirty = TRUE;
     }
 }