spirv: Fix support for POSITION1+
authorEthan Lee <flibitijibibo@flibitijibibo.com>
Wed, 24 Jun 2020 14:19:28 -0400
changeset 1265 dee3df2af08f
parent 1264 64e7e0a0daba
child 1266 285a186ad69d
spirv: Fix support for POSITION1+
profiles/mojoshader_profile_spirv.c
--- a/profiles/mojoshader_profile_spirv.c	Wed Jun 24 14:17:58 2020 -0400
+++ b/profiles/mojoshader_profile_spirv.c	Wed Jun 24 14:19:28 2020 -0400
@@ -1516,8 +1516,13 @@
     switch (usage)
     {
         case MOJOSHADER_USAGE_POSITION:
-            assert(index == 0);
-            spv_output_builtin(ctx, id, SpvBuiltInPosition);
+            if (index == 0)
+                spv_output_builtin(ctx, id, SpvBuiltInPosition);
+            else // locations [24,32]
+            {
+                assert(index < 10);
+                spv_output_location(ctx, id, 24 + (index - 1));
+            } // else
             break;
         case MOJOSHADER_USAGE_POINTSIZE:
             spv_output_builtin(ctx, id, SpvBuiltInPointSize);
@@ -1688,6 +1693,10 @@
                 case MOJOSHADER_USAGE_NORMAL:
                     spv_output_location(ctx, id, 14 + index);
                     break;
+                case MOJOSHADER_USAGE_POSITION:
+                    assert(index > 0 && index < 10);
+                    spv_output_location(ctx, id, 24 + (index - 1));
+                    break;
                 default:
                     failf(ctx, "unexpected attribute usage %d in pixel shader", usage);
                     break;