Make sure attribute registers are declared correctly in weird SM1 case.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 13 Oct 2020 01:23:19 -0400
changeset 1309 b7f37f047a81
parent 1308 ff7fe8bdbb8f
child 1310 9f3b98d12a37
Make sure attribute registers are declared correctly in weird SM1 case.
mojoshader.c
--- a/mojoshader.c	Tue Oct 13 01:03:20 2020 -0400
+++ b/mojoshader.c	Tue Oct 13 01:23:19 2020 -0400
@@ -1736,6 +1736,16 @@
         TextureType ttyp = (dims == 2) ? TEXTURE_TYPE_2D : TEXTURE_TYPE_CUBE;
         add_sampler(ctx, dst->regnum, ttyp, texbem);
     } // if
+
+    add_attribute_register(ctx, REG_TYPE_TEXTURE, dst->regnum,
+                           MOJOSHADER_USAGE_TEXCOORD, dst->regnum, 0xF, 0);
+
+    // Strictly speaking, there should be a TEX opcode prior to this call that
+    //  should fill in this metadata, but I'm not sure that's required for the
+    //  shader to assemble in D3D, so we'll do this so we don't fail with a
+    //  cryptic error message even if the developer didn't do the TEX.
+    add_attribute_register(ctx, REG_TYPE_TEXTURE, src->regnum,
+                           MOJOSHADER_USAGE_TEXCOORD, src->regnum, 0xF, 0);
 } // state_texops
 
 static void state_texbem(Context *ctx, const char *opcode)