r300/compiler: remove at least unused immediates if externals cannot be removed
authorMarek Olšák <maraeo@gmail.com>
Wed, 8 Dec 2010 03:27:58 +0000 (04:27 +0100)
committerMarek Olšák <maraeo@gmail.com>
Wed, 8 Dec 2010 03:39:51 +0000 (04:39 +0100)
src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c
src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c
src/mesa/drivers/dri/r300/compiler/radeon_remove_constants.c

index 3716deaa7e7b9a3430f7507cdf75503ccd343105..e0d349b98ce147b33c17cd3b61b5857a6785b99d 100644 (file)
@@ -81,7 +81,6 @@ static void rc_rewrite_depth_out(struct radeon_compiler *cc, void *user)
 void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c)
 {
        int is_r500 = c->Base.is_r500;
-       int kill_consts = c->Base.remove_unused_constants;
        int opt = !c->Base.disable_optimizations;
 
        /* Lists of instruction transformations. */
@@ -121,7 +120,7 @@ void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c)
                {"emulate loops",               1, !is_r500,    rc_emulate_loops,               NULL},
                {"dataflow optimize",           1, opt,         rc_optimize,                    NULL},
                {"dataflow swizzles",           1, 1,           rc_dataflow_swizzles,           NULL},
-               {"dead constants",              1, kill_consts, rc_remove_unused_constants,     &c->code->constants_remap_table},
+               {"dead constants",              1, 1,           rc_remove_unused_constants,     &c->code->constants_remap_table},
                /* This pass makes it easier for the scheduler to group TEX
                 * instructions and reduces the chances of creating too
                 * many texture indirections.*/
index 54f4cf3316dbad87429b0b8572a41f9400ce9e5c..472029f63d0758d2b0b8d7c5f508da794edc8d34 100644 (file)
@@ -1014,7 +1014,6 @@ static struct rc_swizzle_caps r300_vertprog_swizzle_caps = {
 void r3xx_compile_vertex_program(struct r300_vertex_program_compiler *c)
 {
        int is_r500 = c->Base.is_r500;
-       int kill_consts = c->Base.remove_unused_constants;
        int opt = !c->Base.disable_optimizations;
 
        /* Lists of instruction transformations. */
@@ -1059,7 +1058,7 @@ void r3xx_compile_vertex_program(struct r300_vertex_program_compiler *c)
                /* This pass must be done after optimizations. */
                {"source conflict resolve",     1, 1,           rc_local_transform,             resolve_src_conflicts},
                {"register allocation",         1, opt,         allocate_temporary_registers,   NULL},
-               {"dead constants",              1, kill_consts, rc_remove_unused_constants,     &c->code->constants_remap_table},
+               {"dead constants",              1, 1,           rc_remove_unused_constants,     &c->code->constants_remap_table},
                {"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 & RC_DBG_LOG, r300_vertex_program_dump,        NULL},
index 5f67f536f61ae29e75aff97d7f8177551f2953ee..7d76585a593b6b822bd48b1d12a5477e947019b1 100644 (file)
@@ -87,8 +87,9 @@ void rc_remove_unused_constants(struct radeon_compiler *c, void *user)
                rc_for_all_reads_src(inst, mark_used, &d);
        }
 
-       /* Pass 2: If there is relative addressing, mark all externals as used. */
-       if (has_rel_addr) {
+       /* Pass 2: If there is relative addressing or dead constant elimination
+        * is disabled, mark all externals as used. */
+       if (has_rel_addr || !c->remove_unused_constants) {
                for (unsigned i = 0; i < c->Program.Constants.Count; i++)
                        if (constants[i].Type == RC_CONSTANT_EXTERNAL)
                                const_used[i] = 1;
@@ -119,7 +120,7 @@ void rc_remove_unused_constants(struct radeon_compiler *c, void *user)
        /*  is_identity ==> new_count == old_count
         * !is_identity ==> new_count <  old_count */
        assert( is_identity || new_count <  c->Program.Constants.Count);
-       assert(!(has_rel_addr && are_externals_remapped));
+       assert(!((has_rel_addr || !c->remove_unused_constants) && are_externals_remapped));
 
        /* Pass 4: Redirect reads of all constants to their new locations. */
        if (!is_identity) {
@@ -127,7 +128,6 @@ void rc_remove_unused_constants(struct radeon_compiler *c, void *user)
                     inst != &c->Program.Instructions; inst = inst->Next) {
                        rc_remap_registers(inst, remap_regs, inv_remap_table);
                }
-
        }
 
        /* Set the new constant count. Note that new_count may be less than