r300/compiler: use null-terminated array of transformation functions
authorMarek Olšák <maraeo@gmail.com>
Tue, 31 Aug 2010 23:10:26 +0000 (01:10 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sat, 4 Sep 2010 16:56:21 +0000 (18:56 +0200)
I need to reduce the number of parameters of each compiler pass function.
This is part of a larger cleanup.

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_program.c
src/mesa/drivers/dri/r300/compiler/radeon_program.h

index 96c5d6fda9f02f8f22770c68fc65a34fb14ff569..fdad1255e9a7f2980aef893326b9e068a1f7b8cc 100644 (file)
@@ -123,9 +123,10 @@ void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c)
                        { &r500_transform_IF, 0 },
                        { &radeonTransformALU, 0 },
                        { &radeonTransformDeriv, 0 },
-                       { &radeonTransformTrigScale, 0 }
+                       { &radeonTransformTrigScale, 0 },
+                       { 0, 0 }
                };
-               radeonLocalTransform(&c->Base, 4, transformations);
+               radeonLocalTransform(&c->Base, transformations);
 
                debug_program_log(c, "after native rewrite part 1");
 
@@ -133,9 +134,10 @@ void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c)
        } else {
                struct radeon_program_transformation transformations[] = {
                        { &radeonTransformALU, 0 },
-                       { &radeonTransformTrigSimple, 0 }
+                       { &radeonTransformTrigSimple, 0 },
+                       { 0, 0 }
                };
-               radeonLocalTransform(&c->Base, 2, transformations);
+               radeonLocalTransform(&c->Base, transformations);
 
                debug_program_log(c, "after native rewrite part 1");
 
@@ -146,11 +148,12 @@ void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c)
         * Remember, lowering comes last! */
        struct radeon_program_transformation common_transformations[] = {
                { &radeonTransformTEX, c },
+               { 0, 0 }
        };
-       radeonLocalTransform(&c->Base, 1, common_transformations);
+       radeonLocalTransform(&c->Base, common_transformations);
 
        common_transformations[0].function = &radeonTransformALU;
-       radeonLocalTransform(&c->Base, 1, common_transformations);
+       radeonLocalTransform(&c->Base, common_transformations);
 
        if (c->Base.Error)
                return;
index 29c6c869ff70934dd28c2270935a92d4b84626ab..c98e123411c4df5b6ed2b10e6f062785aa9222b8 100644 (file)
@@ -1005,9 +1005,10 @@ void r3xx_compile_vertex_program(struct r300_vertex_program_compiler *c)
        if (c->Base.is_r500) {
                struct radeon_program_transformation transformations[] = {
                        { &r300_transform_vertex_alu, 0 },
-                       { &r300_transform_trig_scale_vertex, 0 }
+                       { &r300_transform_trig_scale_vertex, 0 },
+                       { 0, 0 }
                };
-               radeonLocalTransform(&c->Base, 2, transformations);
+               radeonLocalTransform(&c->Base, transformations);
                if (c->Base.Error)
                        return;
 
@@ -1015,9 +1016,10 @@ void r3xx_compile_vertex_program(struct r300_vertex_program_compiler *c)
        } else {
                struct radeon_program_transformation transformations[] = {
                        { &r300_transform_vertex_alu, 0 },
-                       { &radeonTransformTrigSimple, 0 }
+                       { &radeonTransformTrigSimple, 0 },
+                       { 0, 0 }
                };
-               radeonLocalTransform(&c->Base, 2, transformations);
+               radeonLocalTransform(&c->Base, transformations);
                if (c->Base.Error)
                        return;
 
@@ -1028,8 +1030,9 @@ void r3xx_compile_vertex_program(struct r300_vertex_program_compiler *c)
                 */
                struct radeon_program_transformation transformations2[] = {
                        { &transform_nonnative_modifiers, 0 },
+                       { 0, 0 }
                };
-               radeonLocalTransform(&c->Base, 1, transformations2);
+               radeonLocalTransform(&c->Base, transformations2);
                if (c->Base.Error)
                        return;
 
@@ -1043,8 +1046,9 @@ void r3xx_compile_vertex_program(struct r300_vertex_program_compiler *c)
                 */
                struct radeon_program_transformation transformations[] = {
                        { &transform_source_conflicts, 0 },
+                       { 0, 0 }
                };
-               radeonLocalTransform(&c->Base, 1, transformations);
+               radeonLocalTransform(&c->Base, transformations);
                if (c->Base.Error)
                        return;
        }
index a3c41d7bd44b700102693b6c7b820e48758a1b20..9ab52b64eafbdc4c982d92576a6eda328ac693b6 100644 (file)
@@ -49,7 +49,6 @@
  */
 void radeonLocalTransform(
        struct radeon_compiler * c,
-       int num_transformations,
        struct radeon_program_transformation* transformations)
 {
        struct rc_instruction * inst = c->Program.Instructions.Next;
@@ -60,7 +59,7 @@ void radeonLocalTransform(
 
                inst = inst->Next;
 
-               for(i = 0; i < num_transformations; ++i) {
+               for(i = 0; transformations[i].function; ++i) {
                        struct radeon_program_transformation* t = transformations + i;
 
                        if (t->function(c, current, t->userData))
index e31886769655a048a6003bc441dc97adec080164..56740643f293290f511727bc10c2b43fe71d86dd 100644 (file)
@@ -216,7 +216,6 @@ struct radeon_program_transformation {
 
 void radeonLocalTransform(
        struct radeon_compiler *c,
-       int num_transformations,
        struct radeon_program_transformation* transformations);
 
 unsigned int rc_find_free_temporary(struct radeon_compiler * c);