From f4070d66d9575ac71c77d195df3add1f14b58022 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Thu, 9 Jan 2020 23:22:02 -0500 Subject: [PATCH] spv_output_location for COLOR0+ pixel shader output --- profiles/mojoshader_profile_spirv.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/profiles/mojoshader_profile_spirv.c b/profiles/mojoshader_profile_spirv.c index f3ef3113..6096810d 100644 --- a/profiles/mojoshader_profile_spirv.c +++ b/profiles/mojoshader_profile_spirv.c @@ -1531,7 +1531,15 @@ static void spv_link_ps_attributes(Context *ctx, uint32 id, RegisterType regtype 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)