diff options
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp')
-rw-r--r-- | src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp | 145 |
1 files changed, 74 insertions, 71 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp b/src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp index c8718daa10..81688765b8 100644 --- a/src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp +++ b/src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp @@ -6,22 +6,40 @@ #include "compiler/translator/VersionGLSL.h" +#include "angle_gl.h" + +namespace sh +{ + 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; + 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; } } @@ -42,9 +60,7 @@ int ShaderOutputTypeToGLSLVersion(ShShaderOutput output) // GLSL 1.2 relaxed the restriction on arrays, section 5.8: "Variables that // are built-in types, entire structures or arrays... are all l-values." // -TVersionGLSL::TVersionGLSL(sh::GLenum type, - const TPragma &pragma, - ShShaderOutput output) +TVersionGLSL::TVersionGLSL(sh::GLenum type, const TPragma &pragma, ShShaderOutput output) : TIntermTraverser(true, false, false) { mVersion = ShaderOutputTypeToGLSLVersion(output); @@ -52,6 +68,10 @@ TVersionGLSL::TVersionGLSL(sh::GLenum type, { ensureVersionIsAtLeast(GLSL_VERSION_120); } + if (type == GL_COMPUTE_SHADER) + { + ensureVersionIsAtLeast(GLSL_VERSION_430); + } } void TVersionGLSL::visitSymbol(TIntermSymbol *node) @@ -62,75 +82,57 @@ void TVersionGLSL::visitSymbol(TIntermSymbol *node) } } -bool TVersionGLSL::visitAggregate(Visit, TIntermAggregate *node) +bool TVersionGLSL::visitDeclaration(Visit, TIntermDeclaration *node) +{ + const TIntermSequence &sequence = *(node->getSequence()); + if (sequence.front()->getAsTyped()->getType().isInvariant()) + { + ensureVersionIsAtLeast(GLSL_VERSION_120); + } + return true; +} + +bool TVersionGLSL::visitInvariantDeclaration(Visit, TIntermInvariantDeclaration *node) { - bool visitChildren = true; + ensureVersionIsAtLeast(GLSL_VERSION_120); + return true; +} - switch (node->getOp()) +bool TVersionGLSL::visitFunctionPrototype(Visit, TIntermFunctionPrototype *node) +{ + const TIntermSequence ¶ms = *(node->getSequence()); + for (TIntermSequence::const_iterator iter = params.begin(); iter != params.end(); ++iter) { - case EOpSequence: - // We need to visit sequence children to get to global or inner scope. - visitChildren = true; - break; - case EOpDeclaration: + const TIntermTyped *param = (*iter)->getAsTyped(); + if (param->isArray()) { - const TIntermSequence &sequence = *(node->getSequence()); - if (sequence.front()->getAsTyped()->getType().isInvariant()) + TQualifier qualifier = param->getQualifier(); + if ((qualifier == EvqOut) || (qualifier == EvqInOut)) { ensureVersionIsAtLeast(GLSL_VERSION_120); + break; } - break; } - case EOpInvariantDeclaration: - ensureVersionIsAtLeast(GLSL_VERSION_120); - break; - case EOpParameters: - { - const TIntermSequence ¶ms = *(node->getSequence()); - for (TIntermSequence::const_iterator iter = params.begin(); - iter != params.end(); ++iter) - { - const TIntermTyped *param = (*iter)->getAsTyped(); - if (param->isArray()) - { - TQualifier qualifier = param->getQualifier(); - if ((qualifier == EvqOut) || (qualifier == EvqInOut)) - { - ensureVersionIsAtLeast(GLSL_VERSION_120); - break; - } - } - } - // Fully processed. No need to visit children. - visitChildren = false; - break; - } - case EOpConstructMat2: - case EOpConstructMat2x3: - case EOpConstructMat2x4: - case EOpConstructMat3x2: - case EOpConstructMat3: - case EOpConstructMat3x4: - case EOpConstructMat4x2: - case EOpConstructMat4x3: - case EOpConstructMat4: + } + // Fully processed. No need to visit children. + return false; +} + +bool TVersionGLSL::visitAggregate(Visit, TIntermAggregate *node) +{ + if (node->getOp() == EOpConstruct && node->getType().isMatrix()) + { + const TIntermSequence &sequence = *(node->getSequence()); + if (sequence.size() == 1) { - const TIntermSequence &sequence = *(node->getSequence()); - if (sequence.size() == 1) + TIntermTyped *typed = sequence.front()->getAsTyped(); + if (typed && typed->isMatrix()) { - TIntermTyped *typed = sequence.front()->getAsTyped(); - if (typed && typed->isMatrix()) - { - ensureVersionIsAtLeast(GLSL_VERSION_120); - } + ensureVersionIsAtLeast(GLSL_VERSION_120); } - break; } - default: - break; } - - return visitChildren; + return true; } void TVersionGLSL::ensureVersionIsAtLeast(int version) @@ -138,3 +140,4 @@ void TVersionGLSL::ensureVersionIsAtLeast(int version) mVersion = std::max(version, mVersion); } +} // namespace sh |