OSDN Git Service

r300/compiler: add new compiler parameter max_constants
authorMarek Olšák <maraeo@gmail.com>
Wed, 1 Sep 2010 02:59:22 +0000 (04:59 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sat, 4 Sep 2010 16:56:21 +0000 (18:56 +0200)
src/gallium/drivers/r300/r300_fs.c
src/gallium/drivers/r300/r300_vs.c
src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c
src/mesa/drivers/dri/r300/compiler/radeon_compiler.c
src/mesa/drivers/dri/r300/compiler/radeon_compiler.h
src/mesa/drivers/dri/r300/r300_blit.c
src/mesa/drivers/dri/r300/r300_fragprog_common.c
src/mesa/drivers/dri/r300/r300_vertprog.c

index 485faef..7a5ed1b 100644 (file)
@@ -386,6 +386,7 @@ static void r300_translate_fragment_shader(
     compiler.state = shader->compare_state;
     compiler.Base.is_r500 = r300->screen->caps.is_r500;
     compiler.Base.max_temp_regs = compiler.Base.is_r500 ? 128 : 32;
+    compiler.Base.max_constants = compiler.Base.is_r500 ? 256 : 32;
     compiler.Base.max_alu_insts = compiler.Base.is_r500 ? 512 : 64;
     compiler.Base.remove_unused_constants = TRUE;
     compiler.AllocateHwInputs = &allocate_hardware_inputs;
index 29569d9..4df6464 100644 (file)
@@ -206,6 +206,7 @@ void r300_translate_vertex_shader(struct r300_context *r300,
     compiler.UserData = vs;
     compiler.Base.is_r500 = r300->screen->caps.is_r500;
     compiler.Base.max_temp_regs = 32;
+    compiler.Base.max_constants = 256;
     compiler.Base.max_alu_insts = r300->screen->caps.is_r500 ? 1024 : 256;
     compiler.Base.remove_unused_constants = TRUE;
 
index eb35265..4aed9dd 100644 (file)
@@ -971,15 +971,6 @@ static struct rc_swizzle_caps r300_vertprog_swizzle_caps = {
        .Split = 0 /* should never be called */
 };
 
-static void validate_final_shader(struct radeon_compiler *c, void *user)
-{
-       /* Check the number of constants. */
-       if (c->Program.Constants.Count > 256) {
-               rc_error(c, "Too many constants. Max: 256, Got: %i\n",
-                        c->Program.Constants.Count);
-       }
-}
-
 void r3xx_compile_vertex_program(struct r300_vertex_program_compiler *c)
 {
        int is_r500 = c->Base.is_r500;
@@ -1027,7 +1018,7 @@ void r3xx_compile_vertex_program(struct r300_vertex_program_compiler *c)
                {"dataflow swizzles",           1, 1,           rc_dataflow_swizzles,           NULL},
                {"register allocation",         1, 1,           allocate_temporary_registers,   NULL},
                {"dead constants",              1, kill_consts, rc_remove_unused_constants,     &c->code->constants_remap_table},
-               {"final code validation",       0, 1,           validate_final_shader,          NULL},
+               {"final code validation",       0, 1,           rc_validate_final_shader,       NULL},
                {"machine code generation",     0, 1,           translate_vertex_program,       NULL},
                {"dump machine code",           0,c->Base.Debug,r300_vertex_program_dump,       NULL},
                {NULL, 0, 0, NULL, NULL}
index 4aff69c..b410b2d 100644 (file)
@@ -374,3 +374,12 @@ void rc_run_compiler(struct radeon_compiler *c, struct radeon_compiler_pass *lis
                }
        }
 }
+
+void rc_validate_final_shader(struct radeon_compiler *c, void *user)
+{
+       /* Check the number of constants. */
+       if (c->Program.Constants.Count > c->max_constants) {
+               rc_error(c, "Too many constants. Max: 256, Got: %i\n",
+                        c->Program.Constants.Count);
+       }
+}
index 0f6ad27..fcb0aee 100644 (file)
@@ -42,6 +42,7 @@ struct radeon_compiler {
        /* Hardware specification. */
        unsigned is_r500:1;
        unsigned max_temp_regs;
+       unsigned max_constants;
        int max_alu_insts;
 
        /* Whether to remove unused constants and empty holes in constant space. */
@@ -136,5 +137,6 @@ struct radeon_compiler_pass {
 /* Executes a list of compiler passes given in the parameter 'list'. */
 void rc_run_compiler(struct radeon_compiler *c, struct radeon_compiler_pass *list,
                     const char *shader_name);
+void rc_validate_final_shader(struct radeon_compiler *c, void *user);
 
 #endif /* RADEON_COMPILER_H */
index 91d715a..c22890c 100644 (file)
@@ -90,6 +90,7 @@ static void create_vertex_program(struct r300_context *r300)
     compiler.code = &r300->blit.vp_code;
     compiler.Base.is_r500 = r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515;
     compiler.Base.max_temp_regs = 32;
+    compiler.Base.max_constants = 256;
     compiler.Base.max_alu_insts = compiler.Base.is_r500 ? 1024 : 256;
 
     r3xx_compile_vertex_program(&compiler);
@@ -123,6 +124,7 @@ static void create_fragment_program(struct r300_context *r300)
     compiler.enable_shadow_ambient = GL_TRUE;
     compiler.Base.is_r500 = (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515);
     compiler.Base.max_temp_regs = (compiler.Base.is_r500) ? 128 : 32;
+    compiler.Base.max_constants = compiler.Base.is_r500 ? 256 : 32;
     compiler.Base.max_alu_insts = compiler.Base.is_r500 ? 512 : 64;
     compiler.code = &r300->blit.fp_code;
     compiler.AllocateHwInputs = fp_allocate_hw_inputs;
index d6d41b4..cd0f6b3 100644 (file)
@@ -221,6 +221,7 @@ static void translate_fragment_program(GLcontext *ctx, struct r300_fragment_prog
        compiler.enable_shadow_ambient = GL_TRUE;
        compiler.Base.is_r500 = (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) ? GL_TRUE : GL_FALSE;
        compiler.Base.max_temp_regs = (compiler.Base.is_r500) ? 128 : 32;
+       compiler.Base.max_constants = compiler.Base.is_r500 ? 256 : 32;
        compiler.Base.max_alu_insts = compiler.Base.is_r500 ? 512 : 64;
        compiler.OutputDepth = FRAG_RESULT_DEPTH;
        memset(compiler.OutputColor, 0, 4 * sizeof(unsigned));
index 948517b..e7dcdef 100644 (file)
@@ -246,6 +246,7 @@ static struct r300_vertex_program *build_program(GLcontext *ctx,
        compiler.SetHwInputOutput = &t_inputs_outputs;
        compiler.Base.is_r500 = R300_CONTEXT(ctx)->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515;
        compiler.Base.max_temp_regs = 32;
+       compiler.Base.max_constants = 256;
        compiler.Base.max_alu_insts = compiler.Base.is_r500 ? 1024 : 256;
 
        if (compiler.Base.Debug) {