r300-gallium: Another constantbuf shader recompile test.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 20 May 2009 21:55:03 +0000 (14:55 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 20 May 2009 21:55:03 +0000 (14:55 -0700)
Less briefly... Shaders need to be recompiled if their constantbuf
offsets have changed. However, since we only change them from shaders if
immediates need to be emitted, we shouldn't bother if the shader doesn't
use immediates.

src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_state_shader.c
src/gallium/drivers/r300/r300_state_tcl.c

index d1cf75032ca77c414df2329715595d8f0ac0c838..a9dd041e083a6c02397637d49aaeb24cfced8b8c 100644 (file)
@@ -158,6 +158,10 @@ struct r3xx_fragment_shader {
 
     /* Pixel stack size */
     int stack_size;
+
+    /* Are there immediates in this shader?
+     * If not, we can heavily optimize recompilation. */
+    boolean uses_imms;
 };
 
 struct r300_fragment_shader {
@@ -248,6 +252,10 @@ struct r300_vertex_shader {
     /* Has this shader been translated yet? */
     boolean translated;
 
+    /* Are there immediates in this shader?
+     * If not, we can heavily optimize recompilation. */
+    boolean uses_imms;
+
     /* Number of used instructions */
     int instruction_count;
 
index 4e65fbbabee97275a0950025e63ba065d5b552d9..0461ffd681afdd0e9d5d5dba4ab8c9658db293a9 100644 (file)
@@ -151,10 +151,12 @@ static void
 
     /* If the number of constants have changed, invalidate the shader. */
     if (r300->shader_constants[shader].user_count != i) {
-        if (shader == PIPE_SHADER_FRAGMENT && r300->fs) {
+        if (shader == PIPE_SHADER_FRAGMENT && r300->fs &&
+                r300->fs->uses_imms) {
             r300->fs->translated = FALSE;
             r300_translate_fragment_shader(r300, r300->fs);
-        } else if (shader == PIPE_SHADER_VERTEX && r300->vs) {
+        } else if (shader == PIPE_SHADER_VERTEX && r300->vs &&
+                r300->vs->uses_imms) {
             r300->vs->translated = FALSE;
             r300_translate_vertex_shader(r300, r300->vs);
         }
index a56b507eefa0fe5bfa107e290a035dfa4a1c1baf..f27d7233d8e8e43ef10e064a0da085f51cd89d01 100644 (file)
@@ -652,6 +652,7 @@ void r300_translate_fragment_shader(struct r300_context* r300,
             assembler->tex_count + assembler->color_count);
 
     consts->count = consts->user_count + assembler->imm_count;
+    fs->uses_imms = assembler->imm_count;
     debug_printf("r300: fs: %d total constants, "
             "%d from user and %d from immediates\n", consts->count,
             consts->user_count, assembler->imm_count);
index fdbcbf3db8cca32c9a5d5891b519a88148f12a02..32e61bc1d72858e0b9d6d0b3365e104c7ae9ad49 100644 (file)
@@ -386,6 +386,7 @@ void r300_translate_vertex_shader(struct r300_context* r300,
             assembler->tex_count + assembler->color_count);
 
     consts->count = consts->user_count + assembler->imm_count;
+    vs->uses_imms = assembler->imm_count;
     debug_printf("r300: vs: %d total constants, "
             "%d from user and %d from immediates\n", consts->count,
             consts->user_count, assembler->imm_count);