glsl: Implemented most of the missing srcmods.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 18 Apr 2012 00:19:32 -0400
changeset 1095 bc3d2c6e06cf
parent 1094 c2009ce6278d
child 1096 b04fca1befb8
glsl: Implemented most of the missing srcmods. Reread the GLSL spec, and it turns out that "vec3(x,y,z) - 3.0" is legal syntactic sugar: the compiler knows to subtract 3.0 from each of the three components in that vec3. This made this simpler than having to tapdance to generate correct constant vectors ourselves, and it's easier to read.
mojoshader.c
--- a/mojoshader.c	Tue Apr 17 03:08:51 2012 -0400
+++ b/mojoshader.c	Wed Apr 18 00:19:32 2012 -0400
@@ -1933,7 +1933,6 @@
         return buf;
     } // if
 
-// !!! FIXME: not right.
     const SourceArgInfo *arg = &ctx->source_args[idx];
 
     const char *premod_str = "";
@@ -1955,27 +1954,26 @@
             break;
 
         case SRCMOD_SIGNNEGATE:
-            premod_str = "-";
-            // fall through.
+            premod_str = "-((";
+            postmod_str = " - 0.5) * 2.0)";
+            break;
+
         case SRCMOD_SIGN:
-            fail(ctx, "SRCMOD_SIGN unsupported"); return buf; // !!! FIXME
-            postmod_str = "_bx2";
+            premod_str = "((";
+            postmod_str = " - 0.5) * 2.0)";
             break;
 
         case SRCMOD_COMPLEMENT:
-            fail(ctx, "SRCMOD_COMPLEMENT unsupported"); return buf; // !!! FIXME  (need to handle vecsize)
-            premod_str = "(1.0 - (";
-            postmod_str = "))";
+            premod_str = "(1.0 - ";
+            postmod_str = ")";
             break;
 
         case SRCMOD_X2NEGATE:
-            fail(ctx, "SRCMOD_X2NEGATE unsupported"); return buf; // !!! FIXME  (need to handle vecsize)
             premod_str = "-(";
             postmod_str = " * 2.0)";
             break;
 
         case SRCMOD_X2:
-            fail(ctx, "SRCMOD_X2 unsupported"); return buf; // !!! FIXME  (need to handle vecsize)
             premod_str = "(";
             postmod_str = " * 2.0)";
             break;