spv_output_location for COLOR0+ pixel shader output
authorEthan Lee <flibitijibibo@flibitijibibo.com>
Thu, 09 Jan 2020 23:22:02 -0500
changeset 1227 b7a3f02389b6
parent 1226 773dafd11a6e
child 1228 22aa1f7914d3
spv_output_location for COLOR0+ pixel shader output
profiles/mojoshader_profile_spirv.c
--- a/profiles/mojoshader_profile_spirv.c	Wed Jan 01 10:58:53 2020 -0500
+++ b/profiles/mojoshader_profile_spirv.c	Thu Jan 09 23:22:02 2020 -0500
@@ -1531,7 +1531,15 @@
     switch (regtype)
     {
         case REG_TYPE_COLOROUT:
-            // nothing to do for color, OpenGL should hook it up automatically??
+            // Per KHR_glsl_shader:
+            // The fragment-stage built-in gl_FragColor, which implies a broadcast to all
+            // outputs, is not present in SPIR-V. Shaders where writing to gl_FragColor
+            // is allowed can still write to it, but it only means to write to an output:
+            // - of the same type as gl_FragColor
+            // - decorated with location 0
+            // - not decorated as a built-in variable.
+            // There is no implicit broadcast.
+            spv_output_location(ctx, id, 0 + index);
             break;
         case REG_TYPE_INPUT: // v# (MOJOSHADER_USAGE_COLOR aka `oC#` in vertex shader)
             switch (usage)