spirv: Fix bogus detection of PSIZE0
authorEthan Lee <flibitijibibo@flibitijibibo.com>
Tue, 07 Jul 2020 17:44:32 -0400
changeset 1278 be0f548f321f
parent 1277 da61410edbc9
child 1279 b1f51cfa8933
spirv: Fix bogus detection of PSIZE0
mojoshader_common.c
profiles/mojoshader_profile_spirv.c
--- a/mojoshader_common.c	Tue Jul 07 17:19:45 2020 -0400
+++ b/mojoshader_common.c	Tue Jul 07 17:44:32 2020 -0400
@@ -1091,6 +1091,8 @@
         const MOJOSHADER_attribute *vAttr = &vertex->outputs[i];
         if (vAttr->usage == MOJOSHADER_USAGE_POSITION && vAttr->index == 0)
             continue;
+        if (vAttr->usage == MOJOSHADER_USAGE_POINTSIZE && vAttr->index == 0)
+            continue;
         if (vAttr->usage == MOJOSHADER_USAGE_COLOR && vAttr->index == 0)
             continue;
 
--- a/profiles/mojoshader_profile_spirv.c	Tue Jul 07 17:19:45 2020 -0400
+++ b/profiles/mojoshader_profile_spirv.c	Tue Jul 07 17:44:32 2020 -0400
@@ -271,17 +271,14 @@
     return (buffer_size(ctx->helpers) >> 2) - 1;
 } // spv_output_location
 
-static uint32 spv_output_attrib_location(Context *ctx, uint32 id,
-                                         MOJOSHADER_usage usage, uint32 index)
+static void spv_output_attrib_location(Context *ctx, uint32 id,
+                                       MOJOSHADER_usage usage, uint32 index)
 {
-    uint32 result;
     SpirvPatchTable* table = &ctx->spirv.patch_table;
     push_output(ctx, &ctx->helpers);
     spv_emit(ctx, 4, SpvOpDecorate, id, SpvDecorationLocation, 0xDEADBEEF);
     pop_output(ctx);
-    result = (buffer_size(ctx->helpers) >> 2) - 1;
-    table->attrib_offsets[usage][index] = result;
-    return result;
+    table->attrib_offsets[usage][index] = (buffer_size(ctx->helpers) >> 2) - 1;
 } // spv_output_attrib_location
 
 static void spv_output_sampler_binding(Context *ctx, uint32 id, uint32 binding)
@@ -1631,7 +1628,10 @@
     if (usage == MOJOSHADER_USAGE_POSITION && index == 0)
         spv_output_builtin(ctx, id, SpvBuiltInPosition);
     else if (usage == MOJOSHADER_USAGE_POINTSIZE && index == 0)
+    {
         spv_output_builtin(ctx, id, SpvBuiltInPointSize);
+        ctx->spirv.patch_table.attrib_offsets[usage][index] = 1;
+    } // else if
     else if (usage == MOJOSHADER_USAGE_COLOR && index == 0)
         spv_output_location(ctx, id, 0);
     else