mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-12 21:20:06 +00:00
1) Don't propagate precision of built-in function arguments to return type when return type is bool (e.g., isnan).
2) Check an additional path for missing default precision qualification, except allow built-in declarations to pass the check. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22241 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
6c0928d924
commit
1fde51d3fb
@ -1,5 +1,5 @@
|
||||
#version 300 es
|
||||
|
||||
precision highp float;
|
||||
uniform int c, d;
|
||||
in highp float x;
|
||||
|
||||
|
@ -289,7 +289,7 @@ TIntermTyped* TIntermediate::addBuiltInFunctionCall(TOperator op, bool unary, TI
|
||||
node->setType(returnType);
|
||||
|
||||
// propagate precision up from child
|
||||
if (returnType.getQualifier().precision == EpqNone && profile == EEsProfile)
|
||||
if (profile == EEsProfile && returnType.getQualifier().precision == EpqNone && returnType.getBasicType() != EbtBool)
|
||||
node->getQualifier().precision = child->getQualifier().precision;
|
||||
|
||||
// propagate precision down to child
|
||||
|
@ -40,11 +40,11 @@
|
||||
#include <stdarg.h>
|
||||
#include <algorithm>
|
||||
|
||||
TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, int v, EProfile p, EShLanguage L, TInfoSink& is,
|
||||
TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, bool pb, int v, EProfile p, EShLanguage L, TInfoSink& is,
|
||||
bool fc, EShMessages m) :
|
||||
intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0), linkage(0),
|
||||
numErrors(0), lexAfterType(false), loopNestingLevel(0),
|
||||
structNestingLevel(0), inTypeParen(false),
|
||||
structNestingLevel(0), inTypeParen(false), parsingBuiltins(pb),
|
||||
version(v), profile(p), forwardCompatible(fc), messages(m),
|
||||
contextPragma(true, false)
|
||||
{
|
||||
@ -885,12 +885,17 @@ TPrecisionQualifier TParseContext::getDefaultPrecision(TPublicType& publicType)
|
||||
|
||||
void TParseContext::precisionQualifierCheck(int line, TPublicType& publicType)
|
||||
{
|
||||
if (profile != EEsProfile)
|
||||
// Built-in symbols are allowed some ambiguous precisions, to be pinned down
|
||||
// later by context.
|
||||
if (profile != EEsProfile || parsingBuiltins)
|
||||
return;
|
||||
|
||||
if (publicType.basicType == EbtFloat || publicType.basicType == EbtUint || publicType.basicType == EbtInt || publicType.basicType == EbtSampler) {
|
||||
if (publicType.qualifier.precision == EpqNone)
|
||||
if (publicType.qualifier.precision == EpqNone) {
|
||||
error(line, "type requires declaration of default precision qualifier", TType::getBasicString(publicType.basicType), "");
|
||||
publicType.qualifier.precision = EpqMedium;
|
||||
defaultPrecision[publicType.basicType] = EpqMedium;
|
||||
}
|
||||
} else if (publicType.qualifier.precision != EpqNone)
|
||||
error(line, "type cannot have precision qualifier", TType::getBasicString(publicType.basicType), "");
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ struct TPragma {
|
||||
// they can be passed to the parser without needing a global.
|
||||
//
|
||||
struct TParseContext {
|
||||
TParseContext(TSymbolTable&, TIntermediate&, int version, EProfile, EShLanguage, TInfoSink&,
|
||||
TParseContext(TSymbolTable&, TIntermediate&, bool parsingBuiltins, int version, EProfile, EShLanguage, TInfoSink&,
|
||||
bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
|
||||
TIntermediate& intermediate; // to hold and build a parse tree
|
||||
TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile
|
||||
@ -78,6 +78,7 @@ struct TParseContext {
|
||||
bool inTypeParen; // true if in parentheses, looking only for an identifier
|
||||
const TType* currentFunctionType; // the return type of the function that's currently being parsed
|
||||
bool functionReturnsValue; // true if a non-void function has a return
|
||||
bool parsingBuiltins; // true if parsing built-in symbols/functions
|
||||
|
||||
int version; // version, updated by #version in the shader
|
||||
EProfile profile; // the declared profile in the shader (core by default)
|
||||
|
@ -98,7 +98,7 @@ bool InitializeSymbolTable(TBuiltInStrings* BuiltInStrings, int version, EProfil
|
||||
else
|
||||
symbolTable = &symbolTables[language];
|
||||
|
||||
TParseContext parseContext(*symbolTable, intermediate, version, profile, language, infoSink);
|
||||
TParseContext parseContext(*symbolTable, intermediate, true, version, profile, language, infoSink);
|
||||
|
||||
GlobalParseContext = &parseContext;
|
||||
|
||||
@ -411,7 +411,7 @@ int ShCompile(
|
||||
// they get popped again further down.
|
||||
AddContextSpecificSymbols(resources, compiler->infoSink, &symbolTable, version, profile, compiler->getLanguage());
|
||||
|
||||
TParseContext parseContext(symbolTable, intermediate, version, profile, compiler->getLanguage(), compiler->infoSink, forwardCompatible, messages);
|
||||
TParseContext parseContext(symbolTable, intermediate, false, version, profile, compiler->getLanguage(), compiler->infoSink, forwardCompatible, messages);
|
||||
|
||||
if (! goodProfile)
|
||||
parseContext.error(1, "incorrect", "#version", "");
|
||||
|
@ -1483,6 +1483,8 @@ fully_specified_type
|
||||
if (parseContext.profile == EEsProfile)
|
||||
parseContext.arraySizeRequiredCheck($1.line, $1.arraySizes->front());
|
||||
}
|
||||
|
||||
parseContext.precisionQualifierCheck($$.line, $$);
|
||||
}
|
||||
| type_qualifier type_specifier {
|
||||
parseContext.globalQualifierFix($1.line, $1.qualifier, $2);
|
||||
|
Loading…
Reference in New Issue
Block a user