From f1ff08a7999885b288613fb495067274841d9a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 23 Mar 2026 22:32:52 -0700 Subject: [PATCH] shaderc: Fixed GLSL 140. (#3644) --- tools/shaderc/shaderc.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/tools/shaderc/shaderc.cpp b/tools/shaderc/shaderc.cpp index cf50612e3..a7b16f8a9 100644 --- a/tools/shaderc/shaderc.cpp +++ b/tools/shaderc/shaderc.cpp @@ -2452,11 +2452,24 @@ namespace bgfx bx::stringPrintf(code, "#version %d\n", need130 ? 130 : glsl_profile); - if (need130) + if (need130 + || glsl_profile >= 130) { + bx::stringPrintf(code, "#define attribute in\n"); bx::stringPrintf(code, "#define varying %s\n" , 'f' == _options.shaderType ? "in" : "out" ); + bx::stringPrintf(code + , "#define bgfxShadow2D(_sampler, _coord) vec4_splat(texture(_sampler, _coord) )\n" + "#define bgfxShadow2DProj(_sampler, _coord) vec4_splat(textureProj(_sampler, _coord) )\n" + ); + } + else + { + bx::stringPrintf(code + , "#define bgfxShadow2D shadow2D\n" + "#define bgfxShadow2DProj shader2DProj\n" + ); } if (usesInstanceID) @@ -2547,21 +2560,6 @@ namespace bgfx "#define textureCubeGrad textureCubeGradEXT\n" ); } - - if (need130 || (glsl_profile >= 130) ) - { - bx::stringPrintf(code - , "#define bgfxShadow2D(_sampler, _coord) vec4_splat(texture(_sampler, _coord) )\n" - "#define bgfxShadow2DProj(_sampler, _coord) vec4_splat(textureProj(_sampler, _coord) )\n" - ); - } - else - { - bx::stringPrintf(code - , "#define bgfxShadow2D shadow2D\n" - "#define bgfxShadow2DProj shader2DProj\n" - ); - } } else {