[svn] Simplified and corrected source arg swizzle. trunk
authoricculus
Sun, 16 Mar 2008 22:37:05 -0400
branchtrunk
changeset 25 9664b0f62af6
parent 24 2177c6bee93d
child 26 ed1dc1eca8b2
[svn] Simplified and corrected source arg swizzle.
d3d2glsl.c
--- a/d3d2glsl.c	Sun Mar 16 20:55:34 2008 -0400
+++ b/d3d2glsl.c	Sun Mar 16 22:37:05 2008 -0400
@@ -253,6 +253,7 @@
     uint32 minor_ver;
     DestArgInfo dest_args[1];
     SourceArgInfo source_args[4];
+    uint32 instruction_count;
 };
 
 
@@ -604,20 +605,14 @@
     {
         static const char channel[] = { 'x', 'y', 'z', 'w' };
         swizzle_str[i++] = '.';
+        swizzle_str[i++] = channel[arg->swizzle_x];
+        swizzle_str[i++] = channel[arg->swizzle_y];
+        swizzle_str[i++] = channel[arg->swizzle_z];
+        swizzle_str[i++] = channel[arg->swizzle_w];
 
-        if ( (arg->swizzle_x == arg->swizzle_y) &&
-             (arg->swizzle_x == arg->swizzle_z) &&
-             (arg->swizzle_x == arg->swizzle_w) )
-        {
-            swizzle_str[i++] = channel[arg->swizzle_x];  // syntactic sugar.
-        } // if
-        else
-        {
-            swizzle_str[i++] = channel[arg->swizzle_x];
-            swizzle_str[i++] = channel[arg->swizzle_y];
-            swizzle_str[i++] = channel[arg->swizzle_z];
-            swizzle_str[i++] = channel[arg->swizzle_w];
-        } // else
+        // .xyzz is the same as .xyz, .z is the same as .zzzz, etc.
+        while (swizzle_str[i-1] == swizzle_str[i-2])
+            i--;
     } // if
     swizzle_str[i] = '\0';
     assert(i < sizeof (swizzle_str));
@@ -1705,6 +1700,8 @@
         } // else if
     } // if
 
+    ctx->instruction_count++;
+
     // Update the context with instruction's arguments.
     ctx->tokens++;
     ctx->tokencount--;