Front-End: Non-ES trigger for processing precision qualifiers.

Initially non-functional: Have an independent test for whether to obey
precision qualifiers other than whether the profile is es.
This commit is contained in:
John Kessenich 2016-08-03 15:19:37 -06:00
parent 219b025d7e
commit 4d535640e4
6 changed files with 56 additions and 44 deletions

View File

@ -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) :

View File

@ -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"

View File

@ -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)

View File

@ -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<TIntermTyped*> needsIndexLimitationChecking;
bool obeyPrecisionQualifiers_;
//
// Geometry shader input arrays:

View File

@ -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;
}
;

View File

@ -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 */