Let d3d and bytecode profiles use relative addressing without a CTAB.
authorRyan C. Gordon <icculus@icculus.org>
Mon, 01 Aug 2011 15:14:50 -0400
changeset 1058 dcbe39bffedc
parent 1057 4c5cb78c6cdd
child 1059 9655c606b39d
Let d3d and bytecode profiles use relative addressing without a CTAB. Since these would work on Windows without them, too.
mojoshader.c
--- a/mojoshader.c	Mon Aug 01 15:06:52 2011 -0400
+++ b/mojoshader.c	Mon Aug 01 15:14:50 2011 -0400
@@ -148,6 +148,7 @@
     int glsl_generated_texldd_setup;
     int arb1_wrote_position;
     int have_preshader;
+    int ignores_ctab;
     MOJOSHADER_preshader *preshader;
 
 #if SUPPORT_PROFILE_ARB1_NV
@@ -1059,6 +1060,8 @@
     const uint minor = (uint) ctx->minor_ver;
     char minor_str[16];
 
+    ctx->ignores_ctab = 1;
+
     if (minor == 0xFF)
         strcpy(minor_str, "sw");
     else if ((major > 1) && (minor == 1))
@@ -1506,6 +1509,8 @@
 
 static void emit_BYTECODE_start(Context *ctx, const char *profilestr)
 {
+    ctx->ignores_ctab = 1;
+
     // just copy the whole token stream and make all other emitters no-ops.
     if (set_output(ctx, &ctx->mainline))
     {
@@ -5435,8 +5440,11 @@
             fail(ctx, "Relative addressing in non-vertex shader");
         if (!shader_version_atleast(ctx, 3, 0))
             fail(ctx, "Relative addressing in vertex shader version < 3.0");
-        if (!ctx->ctab.have_ctab)  // it's hard to do this efficiently without!
+        if ((!ctx->ctab.have_ctab) && (!ctx->ignores_ctab))
+        {
+            // it's hard to do this efficiently without!
             fail(ctx, "relative addressing unsupported without a CTAB");
+        } // if
 
         // !!! FIXME: I don't have a shader that has a relative dest currently.
         fail(ctx, "Relative addressing of dest tokens is unsupported");
@@ -5713,28 +5721,31 @@
         else if (info->regtype == REG_TYPE_CONST)
         {
             // figure out what array we're in...
-            if (!ctx->ctab.have_ctab)  // it's hard to do efficiently without!
-                fail(ctx, "relative addressing unsupported without a CTAB");
-            else
+            if (!ctx->ignores_ctab)
             {
-                determine_constants_arrays(ctx);
-
-                VariableList *var;
-                const int reltarget = info->regnum;
-                for (var = ctx->variables; var != NULL; var = var->next)
+                if (!ctx->ctab.have_ctab)  // hard to do efficiently without!
+                    fail(ctx, "relative addressing unsupported without a CTAB");
+                else
                 {
-                    const int lo = var->index;
-                    if ( (reltarget >= lo) && (reltarget < (lo + var->count)) )
-                        break;  // match!
-                } // for
-
-                if (var == NULL)
-                    fail(ctx, "relative addressing of indeterminate array");
-
-                var->used = 1;
-                info->relative_array = var;
-                set_used_register(ctx, info->relative_regtype, info->relative_regnum);
-            } // else
+                    determine_constants_arrays(ctx);
+
+                    VariableList *var;
+                    const int reltarget = info->regnum;
+                    for (var = ctx->variables; var != NULL; var = var->next)
+                    {
+                        const int lo = var->index;
+                        if ( (reltarget >= lo) && (reltarget < (lo + var->count)) )
+                            break;  // match!
+                    } // for
+
+                    if (var == NULL)
+                        fail(ctx, "relative addressing of indeterminate array");
+
+                    var->used = 1;
+                    info->relative_array = var;
+                    set_used_register(ctx, info->relative_regtype, info->relative_regnum);
+                } // else
+            } // if
         } // else if
         else
         {