Fixed wrong data from scalar_register().
authorRyan C. Gordon <icculus@icculus.org>
Wed, 10 Dec 2008 05:05:55 -0500
changeset 491 bcc3c215807a
parent 490 14b6586d9c43
child 492 29bfa3448549
Fixed wrong data from scalar_register(). Apparently the predicate register is scalar, but only in pixel shaders.
mojoshader.c
mojoshader_assembler.c
mojoshader_internal.h
--- a/mojoshader.c	Wed Dec 10 05:04:52 2008 -0500
+++ b/mojoshader.c	Wed Dec 10 05:05:55 2008 -0500
@@ -895,7 +895,7 @@
 
     char swizzle_str[6];
     int i = 0;
-    const int scalar = scalar_register(arg->regtype, arg->regnum);
+    const int scalar = scalar_register(ctx->shader_type, arg->regtype, arg->regnum);
     if (!scalar && !no_swizzle(arg->swizzle))
     {
         swizzle_str[i++] = '.';
@@ -952,7 +952,7 @@
 
     char writemask_str[6];
     int i = 0;
-    const int scalar = scalar_register(arg->regtype, arg->regnum);
+    const int scalar = scalar_register(ctx->shader_type, arg->regtype, arg->regnum);
     if (!scalar && !writemask_xyzw(arg->writemask))
     {
         writemask_str[i++] = '.';
@@ -1723,7 +1723,7 @@
                                                        sizeof (regnum_str));
     char writemask_str[6];
     int i = 0;
-    const int scalar = scalar_register(arg->regtype, arg->regnum);
+    const int scalar = scalar_register(ctx->shader_type, arg->regtype, arg->regnum);
     if (!scalar && !writemask_xyzw(arg->writemask))
     {
         writemask_str[i++] = '.';
@@ -1890,7 +1890,7 @@
     } // if
 
     char swiz_str[6] = { '\0' };
-    if (!scalar_register(arg->regtype, arg->regnum))
+    if (!scalar_register(ctx->shader_type, arg->regtype, arg->regnum))
     {
         make_GLSL_swizzle_string(swiz_str, sizeof (swiz_str),
                                  arg->swizzle, writemask);
@@ -2962,7 +2962,7 @@
                 return;
         } // switch
 
-        assert(!scalar_register(samp_arg->regtype, samp_arg->regnum));
+        assert(!scalar_register(ctx->shader_type, samp_arg->regtype, samp_arg->regnum));
         char swiz_str[6] = { '\0' };
         make_GLSL_swizzle_string(swiz_str, sizeof (swiz_str),
                                  samp_arg->swizzle, ctx->dest_arg.writemask);
@@ -3381,7 +3381,7 @@
         } // if
     } // if
 
-    const int scalar = scalar_register(arg->regtype, arg->regnum);
+    const int scalar = scalar_register(ctx->shader_type, arg->regtype, arg->regnum);
     if (!scalar && !no_swizzle(arg->swizzle))
     {
         swizzle_str[i++] = '.';
@@ -3469,7 +3469,7 @@
 
     char writemask_str[6];
     int i = 0;
-    const int scalar = scalar_register(arg->regtype, arg->regnum);
+    const int scalar = scalar_register(ctx->shader_type, arg->regtype, arg->regnum);
     if (!scalar && !writemask_xyzw(arg->writemask))
     {
         writemask_str[i++] = '.';
@@ -4929,7 +4929,7 @@
     info->regtype = (RegisterType) (((token >> 28) & 0x7) | ((token >> 8) & 0x18));  // bits 28-30, 11-12
 
     int writemask;
-    if (scalar_register(info->regtype, info->regnum))
+    if (scalar_register(ctx->shader_type, info->regtype, info->regnum))
         writemask = 0x1;  // just x.
     else
         writemask = info->orig_writemask;
--- a/mojoshader_assembler.c	Wed Dec 10 05:04:52 2008 -0500
+++ b/mojoshader_assembler.c	Wed Dec 10 05:05:55 2008 -0500
@@ -669,7 +669,7 @@
         info->writemask0 = info->writemask1 = info->writemask2 = info->writemask3 = 1;
         pushback(ctx);  // no explicit writemask; do full mask.
     } // if
-    else if (scalar_register(info->regtype, info->regnum))
+    else if (scalar_register(ctx->shader_type, info->regtype, info->regnum))
         return fail(ctx, "Writemask specified for scalar register");
     else if (nexttoken(ctx, 0, 1, 0, 0) == FAIL)
         return FAIL;
@@ -830,7 +830,7 @@
         swizzle = 0xE4;  // 0xE4 == 11100100 ... 0 1 2 3. No swizzle.
         pushback(ctx);  // no explicit writemask; do full mask.
     } // if
-    else if (scalar_register(regtype, regnum))
+    else if (scalar_register(ctx->shader_type, regtype, regnum))
         return fail(ctx, "Swizzle specified for scalar register");
     else if (nexttoken(ctx, 0, 1, 0, 0) == FAIL)
         return FAIL;
--- a/mojoshader_internal.h	Wed Dec 10 05:04:52 2008 -0500
+++ b/mojoshader_internal.h	Wed Dec 10 05:05:55 2008 -0500
@@ -227,13 +227,13 @@
 } DestArgInfo;
 
 
-static inline int scalar_register(const RegisterType regtype, const int regnum)
+static inline int scalar_register(const MOJOSHADER_shaderType shader_type,
+                                  const RegisterType regtype, const int regnum)
 {
     switch (regtype)
     {
         case REG_TYPE_DEPTHOUT:
         case REG_TYPE_CONSTBOOL:
-        case REG_TYPE_PREDICATE:
         case REG_TYPE_LOOP:
             return 1;
 
@@ -242,6 +242,9 @@
                 return 1;
             return 0;
 
+        case REG_TYPE_PREDICATE:
+            return (shader_type == MOJOSHADER_TYPE_PIXEL) ? 1 : 0;
+
         default: break;
     } // switch