diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index 1ea9f253..6c2ded8e 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -1075,7 +1075,7 @@ public: qualifier.clear(); qualifier.storage = q; qualifier.precision = p; - assert(p >= 0 && p <= EpqHigh); + assert(p >= EpqNone && p <= EpqHigh); } // for turning a TPublicType into a TType, using a shallow copy explicit TType(const TPublicType& p) : diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index 3a929fd9..00ffc1bc 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -2,5 +2,5 @@ // For the version, it uses the latest git tag followed by the number of commits. // For the date, it uses the current date (when then script is run). -#define GLSLANG_REVISION "SPIRV99.1426" -#define GLSLANG_DATE "23-Aug-2016" +#define GLSLANG_REVISION "SPIRV99.1384" +#define GLSLANG_DATE "03-Aug-2016" diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 7211d4b0..822c361e 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -61,6 +61,43 @@ TParseContext::TParseContext(TSymbolTable& symbolTable, TIntermediate& interm, b // ensure we always have a linkage node, even if empty, to simplify tree topology algorithms linkage = new TIntermAggregate; + // decide whether precision qualifiers should be ignored or respected + obeyPrecisionQualifiers_ = profile == EEsProfile; + setPrecisionDefaults(); + + globalUniformDefaults.clear(); + globalUniformDefaults.layoutMatrix = ElmColumnMajor; + globalUniformDefaults.layoutPacking = spvVersion.spv != 0 ? ElpStd140 : ElpShared; + + globalBufferDefaults.clear(); + globalBufferDefaults.layoutMatrix = ElmColumnMajor; + globalBufferDefaults.layoutPacking = spvVersion.spv != 0 ? ElpStd430 : ElpShared; + + globalInputDefaults.clear(); + globalOutputDefaults.clear(); + + // "Shaders in the transform + // feedback capturing mode have an initial global default of + // layout(xfb_buffer = 0) out;" + if (language == EShLangVertex || + language == EShLangTessControl || + language == EShLangTessEvaluation || + language == EShLangGeometry) + globalOutputDefaults.layoutXfbBuffer = 0; + + if (language == EShLangGeometry) + globalOutputDefaults.layoutStream = 0; +} + +TParseContext::~TParseContext() +{ + delete [] atomicUintOffsets; +} + +// Set up all default precisions as needed by the current environment. +// Intended just as a TParseContext constructor helper. +void TParseContext::setPrecisionDefaults() +{ // set all precision defaults to EpqNone, which is correct for all desktop types // and for ES types that don't have defaults (thus getting an error on use) for (int type = 0; type < EbtNumTypes; ++type) @@ -70,7 +107,7 @@ TParseContext::TParseContext(TSymbolTable& symbolTable, TIntermediate& interm, b defaultSamplerPrecision[type] = EpqNone; // replace with real precision defaults for those that have them - if (profile == EEsProfile) { + if (obeyPrecisionQualifiers()) { TSampler sampler; sampler.set(EbtFloat, Esd2D); defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow; @@ -101,34 +138,6 @@ TParseContext::TParseContext(TSymbolTable& symbolTable, TIntermediate& interm, b defaultPrecision[EbtSampler] = EpqLow; defaultPrecision[EbtAtomicUint] = EpqHigh; } - - globalUniformDefaults.clear(); - globalUniformDefaults.layoutMatrix = ElmColumnMajor; - globalUniformDefaults.layoutPacking = spvVersion.spv != 0 ? ElpStd140 : ElpShared; - - globalBufferDefaults.clear(); - globalBufferDefaults.layoutMatrix = ElmColumnMajor; - globalBufferDefaults.layoutPacking = spvVersion.spv != 0 ? ElpStd430 : ElpShared; - - globalInputDefaults.clear(); - globalOutputDefaults.clear(); - - // "Shaders in the transform - // feedback capturing mode have an initial global default of - // layout(xfb_buffer = 0) out;" - if (language == EShLangVertex || - language == EShLangTessControl || - language == EShLangTessEvaluation || - language == EShLangGeometry) - globalOutputDefaults.layoutXfbBuffer = 0; - - if (language == EShLangGeometry) - globalOutputDefaults.layoutStream = 0; -} - -TParseContext::~TParseContext() -{ - delete [] atomicUintOffsets; } void TParseContext::setLimits(const TBuiltInResource& r) @@ -1223,7 +1232,9 @@ TIntermTyped* TParseContext::handleBuiltInFunctionCall(TSourceLoc loc, TIntermNo TIntermTyped *result = intermediate.addBuiltInFunctionCall(loc, function.getBuiltInOp(), function.getParamCount() == 1, &arguments, function.getType()); - computeBuiltinPrecisions(*result, function); + if (obeyPrecisionQualifiers()) + computeBuiltinPrecisions(*result, function); + if (result == nullptr) { error(arguments.getLoc(), " wrong operand type", "Internal Error", "built in unary operator function. Type: %s", @@ -1271,9 +1282,6 @@ void TParseContext::computeBuiltinPrecisions(TIntermTyped& node, const TFunction TPrecisionQualifier operationPrecision = EpqNone; TPrecisionQualifier resultPrecision = EpqNone; - if (profile != EEsProfile) - return; - TIntermOperator* opNode = node.getAsOperator(); if (opNode == nullptr) return; @@ -2934,7 +2942,7 @@ void TParseContext::precisionQualifierCheck(const TSourceLoc& loc, TBasicType ba { // Built-in symbols are allowed some ambiguous precisions, to be pinned down // later by context. - if (profile != EEsProfile || parsingBuiltins) + if (! obeyPrecisionQualifiers() || parsingBuiltins) return; if (baseType == EbtAtomicUint && qualifier.precision != EpqNone && qualifier.precision != EpqHigh) diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h index 544c3d30..0c64b570 100644 --- a/glslang/MachineIndependent/ParseHelper.h +++ b/glslang/MachineIndependent/ParseHelper.h @@ -80,7 +80,7 @@ public: symbolTable(symbolTable), tokensBeforeEOF(false), linkage(nullptr), scanContext(nullptr), ppContext(nullptr) { } virtual ~TParseContextBase() { } - + virtual void setLimits(const TBuiltInResource&) = 0; EShLanguage getLanguage() const { return language; } @@ -155,6 +155,9 @@ public: bool forwardCompatible = false, EShMessages messages = EShMsgDefault); virtual ~TParseContext(); + bool obeyPrecisionQualifiers() const { return obeyPrecisionQualifiers_; }; + void setPrecisionDefaults(); + void setLimits(const TBuiltInResource&); bool parseShaderStrings(TPpContext&, TInputScanner& input, bool versionWillBeError = false); void parserError(const char* s); // for bison's yyerror @@ -351,6 +354,7 @@ protected: TIdSetType inductiveLoopIds; bool anyIndexLimits; TVector needsIndexLimitationChecking; + bool obeyPrecisionQualifiers_; // // Geometry shader input arrays: diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y index 72bad947..aafe85c6 100644 --- a/glslang/MachineIndependent/glslang.y +++ b/glslang/MachineIndependent/glslang.y @@ -2206,19 +2206,19 @@ precision_qualifier : HIGH_PRECISION { parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "highp precision qualifier"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); - if (parseContext.profile == EEsProfile) + if (parseContext.obeyPrecisionQualifiers()) $$.qualifier.precision = EpqHigh; } | MEDIUM_PRECISION { parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "mediump precision qualifier"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); - if (parseContext.profile == EEsProfile) + if (parseContext.obeyPrecisionQualifiers()) $$.qualifier.precision = EpqMedium; } | LOW_PRECISION { parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "lowp precision qualifier"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); - if (parseContext.profile == EEsProfile) + if (parseContext.obeyPrecisionQualifiers()) $$.qualifier.precision = EpqLow; } ; diff --git a/glslang/MachineIndependent/glslang_tab.cpp b/glslang/MachineIndependent/glslang_tab.cpp index 0d1dc433..84f46dac 100644 --- a/glslang/MachineIndependent/glslang_tab.cpp +++ b/glslang/MachineIndependent/glslang_tab.cpp @@ -6667,7 +6667,7 @@ yyreduce: { parseContext.profileRequires((yyvsp[0].lex).loc, ENoProfile, 130, 0, "highp precision qualifier"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); - if (parseContext.profile == EEsProfile) + if (parseContext.obeyPrecisionQualifiers()) (yyval.interm.type).qualifier.precision = EpqHigh; } #line 6674 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */ @@ -6678,7 +6678,7 @@ yyreduce: { parseContext.profileRequires((yyvsp[0].lex).loc, ENoProfile, 130, 0, "mediump precision qualifier"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); - if (parseContext.profile == EEsProfile) + if (parseContext.obeyPrecisionQualifiers()) (yyval.interm.type).qualifier.precision = EpqMedium; } #line 6685 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */ @@ -6689,7 +6689,7 @@ yyreduce: { parseContext.profileRequires((yyvsp[0].lex).loc, ENoProfile, 130, 0, "lowp precision qualifier"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); - if (parseContext.profile == EEsProfile) + if (parseContext.obeyPrecisionQualifiers()) (yyval.interm.type).qualifier.precision = EpqLow; } #line 6696 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */