diff options
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp')
-rw-r--r-- | src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp b/src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp index f6f568897d..c8718daa10 100644 --- a/src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp +++ b/src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp @@ -6,9 +6,24 @@ #include "compiler/translator/VersionGLSL.h" -static const int GLSL_VERSION_110 = 110; -static const int GLSL_VERSION_120 = 120; -static const int GLSL_VERSION_150 = 150; +int ShaderOutputTypeToGLSLVersion(ShShaderOutput output) +{ + switch (output) + { + case SH_GLSL_130_OUTPUT: return GLSL_VERSION_130; + case SH_GLSL_140_OUTPUT: return GLSL_VERSION_140; + case SH_GLSL_150_CORE_OUTPUT: return GLSL_VERSION_150; + case SH_GLSL_330_CORE_OUTPUT: return GLSL_VERSION_330; + case SH_GLSL_400_CORE_OUTPUT: return GLSL_VERSION_400; + case SH_GLSL_410_CORE_OUTPUT: return GLSL_VERSION_410; + case SH_GLSL_420_CORE_OUTPUT: return GLSL_VERSION_420; + case SH_GLSL_430_CORE_OUTPUT: return GLSL_VERSION_430; + case SH_GLSL_440_CORE_OUTPUT: return GLSL_VERSION_440; + case SH_GLSL_450_CORE_OUTPUT: return GLSL_VERSION_450; + case SH_GLSL_COMPATIBILITY_OUTPUT: return GLSL_VERSION_110; + default: UNREACHABLE(); return 0; + } +} // We need to scan for the following: // 1. "invariant" keyword: This can occur in both - vertex and fragment shaders @@ -30,25 +45,21 @@ static const int GLSL_VERSION_150 = 150; TVersionGLSL::TVersionGLSL(sh::GLenum type, const TPragma &pragma, ShShaderOutput output) + : TIntermTraverser(true, false, false) { - if (output == SH_GLSL_CORE_OUTPUT) + mVersion = ShaderOutputTypeToGLSLVersion(output); + if (pragma.stdgl.invariantAll) { - mVersion = GLSL_VERSION_150; - } - else - { - ASSERT(output == SH_GLSL_COMPATIBILITY_OUTPUT); - if (pragma.stdgl.invariantAll) - mVersion = GLSL_VERSION_120; - else - mVersion = GLSL_VERSION_110; + ensureVersionIsAtLeast(GLSL_VERSION_120); } } void TVersionGLSL::visitSymbol(TIntermSymbol *node) { if (node->getSymbol() == "gl_PointCoord") - updateVersion(GLSL_VERSION_120); + { + ensureVersionIsAtLeast(GLSL_VERSION_120); + } } bool TVersionGLSL::visitAggregate(Visit, TIntermAggregate *node) @@ -64,16 +75,14 @@ bool TVersionGLSL::visitAggregate(Visit, TIntermAggregate *node) case EOpDeclaration: { const TIntermSequence &sequence = *(node->getSequence()); - TQualifier qualifier = sequence.front()->getAsTyped()->getQualifier(); - if ((qualifier == EvqInvariantVaryingIn) || - (qualifier == EvqInvariantVaryingOut)) + if (sequence.front()->getAsTyped()->getType().isInvariant()) { - updateVersion(GLSL_VERSION_120); + ensureVersionIsAtLeast(GLSL_VERSION_120); } break; } case EOpInvariantDeclaration: - updateVersion(GLSL_VERSION_120); + ensureVersionIsAtLeast(GLSL_VERSION_120); break; case EOpParameters: { @@ -87,7 +96,7 @@ bool TVersionGLSL::visitAggregate(Visit, TIntermAggregate *node) TQualifier qualifier = param->getQualifier(); if ((qualifier == EvqOut) || (qualifier == EvqInOut)) { - updateVersion(GLSL_VERSION_120); + ensureVersionIsAtLeast(GLSL_VERSION_120); break; } } @@ -97,7 +106,13 @@ bool TVersionGLSL::visitAggregate(Visit, TIntermAggregate *node) break; } case EOpConstructMat2: + case EOpConstructMat2x3: + case EOpConstructMat2x4: + case EOpConstructMat3x2: case EOpConstructMat3: + case EOpConstructMat3x4: + case EOpConstructMat4x2: + case EOpConstructMat4x3: case EOpConstructMat4: { const TIntermSequence &sequence = *(node->getSequence()); @@ -106,7 +121,7 @@ bool TVersionGLSL::visitAggregate(Visit, TIntermAggregate *node) TIntermTyped *typed = sequence.front()->getAsTyped(); if (typed && typed->isMatrix()) { - updateVersion(GLSL_VERSION_120); + ensureVersionIsAtLeast(GLSL_VERSION_120); } } break; @@ -118,7 +133,7 @@ bool TVersionGLSL::visitAggregate(Visit, TIntermAggregate *node) return visitChildren; } -void TVersionGLSL::updateVersion(int version) +void TVersionGLSL::ensureVersionIsAtLeast(int version) { mVersion = std::max(version, mVersion); } |