From 9d1590670edd948ec4c73ed42712fcee5cb69c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Tue, 15 Jan 2019 19:01:18 -0800 Subject: [PATCH] shaderc: Fixed metal interpolation qualifiers. --- .../glsl-optimizer/src/glsl/glsl_optimizer.cpp | 1 + tools/shaderc/shaderc.cpp | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.cpp b/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.cpp index b5cf24c7f..dde202896 100644 --- a/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.cpp @@ -61,6 +61,7 @@ initialize_mesa_context(struct gl_context *ctx, glslopt_target api) ctx->Extensions.EXT_shader_framebuffer_fetch = true; break; case kGlslTargetMetal: + ctx->Const.GLSLVersion = 150; ctx->Extensions.ARB_ES3_compatibility = true; ctx->Extensions.EXT_shader_framebuffer_fetch = true; break; diff --git a/tools/shaderc/shaderc.cpp b/tools/shaderc/shaderc.cpp index 4d4a06ef5..3a32e34cf 100644 --- a/tools/shaderc/shaderc.cpp +++ b/tools/shaderc/shaderc.cpp @@ -1131,9 +1131,13 @@ namespace bgfx || 0 == bx::strCmp(typen, "noperspective", 13) || 0 == bx::strCmp(typen, "centroid", 8) ) { - interpolation = typen; + if ('f' == _options.shaderType) + { + interpolation = typen; + usesInterpolationQualifiers = true; + } + typen = nextWord(parse); - usesInterpolationQualifiers = true; } bx::StringView name = nextWord(parse); @@ -1956,15 +1960,15 @@ namespace bgfx if (0 == essl) { - const bool need130 = 120 == glsl && (false + const bool need130 = 0 != metal || (120 == glsl && (false || !bx::findIdentifierMatch(input, s_130).isEmpty() || usesInterpolationQualifiers || usesTexelFetch - ); + ) ); if (0 != metal) { - bx::stringPrintf(code, "#version 120\n"); + bx::stringPrintf(code, "#version 130\n"); } else { @@ -2081,7 +2085,7 @@ namespace bgfx { bx::stringPrintf(code , "#define bgfxShadow2D shadow2D\n" - "#define bgfxShadow2DProj shadow2DProj\n" + "#define bgfxShadow2DProj shadow2DProj\n" ); } }