GLSL profile now emits correct array deference on instructions. trunk
authorRyan C. Gordon <icculus@icculus.org>
Fri, 02 May 2008 07:04:43 -0400
branchtrunk
changeset 268 6d5a1323db28
parent 267 06b94bd80081
child 269 fbc4e1843809
GLSL profile now emits correct array deference on instructions. Need to coerce the uniforms into real arrays, still, though. :/
mojoshader.c
--- a/mojoshader.c	Fri May 02 06:47:41 2008 -0400
+++ b/mojoshader.c	Fri May 02 07:04:43 2008 -0400
@@ -1826,6 +1826,30 @@
         return "";
     } // if
 
+    const char *rel_lbracket = "";
+    const char *rel_rbracket = "";
+    char rel_swizzle[4] = { '\0' };
+    char rel_regnum_str[16] = { '\0' };
+    const char *rel_regtype_str = "";
+    if (arg->relative)
+    {
+        rel_swizzle[0] = '.';
+        rel_swizzle[1] = swizzle_channels[arg->relative_component];
+        rel_swizzle[2] = '\0';
+        rel_lbracket = "[";
+        rel_rbracket = "]";
+        rel_regtype_str = get_GLSL_register_string(ctx, arg->relative_regtype,
+                                                   arg->relative_regnum,
+                                                   rel_regnum_str,
+                                                   sizeof (rel_regnum_str));
+
+        if (regtype_str == NULL)
+        {
+            fail(ctx, "Unknown relative source register type.");
+            return "";
+        } // if
+    } // if
+
     char swiz_str[6];
     int i = 0;
     // 0xE4 == 11100100 ... 3 2 1 0. No swizzle.
@@ -1842,8 +1866,10 @@
 
     const char *shader_type_str = get_shader_type_string(ctx);
     char *retval = get_scratch_buffer(ctx);
-    snprintf(retval, SCRATCH_BUFFER_SIZE, "%s%s_%s%s%s%s", premod_str,
-             shader_type_str, regtype_str, regnum_str, swiz_str, postmod_str);
+    snprintf(retval, SCRATCH_BUFFER_SIZE, "%s%s_%s%s%s%s%s%s%s%s%s",
+             premod_str, shader_type_str, regtype_str, regnum_str,
+             rel_lbracket, rel_regtype_str, rel_regnum_str, rel_swizzle,
+             rel_rbracket, swiz_str, postmod_str);
     // !!! FIXME: make sure the scratch buffer was large enough.
     return retval;
 } // make_GLSL_srcarg_string