Fix default precision check for formal parameters; it was one level too deep. This will accept more fragment shaders with no default precision before declaring functions.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@29281 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
33a5423f76
commit
c311d35500
@ -2266,27 +2266,27 @@ TPrecisionQualifier TParseContext::getDefaultPrecision(TPublicType& publicType)
|
||||
return defaultPrecision[publicType.basicType];
|
||||
}
|
||||
|
||||
void TParseContext::precisionQualifierCheck(TSourceLoc loc, TPublicType& publicType)
|
||||
void TParseContext::precisionQualifierCheck(TSourceLoc loc, TBasicType baseType, TQualifier& qualifier)
|
||||
{
|
||||
// Built-in symbols are allowed some ambiguous precisions, to be pinned down
|
||||
// later by context.
|
||||
if (profile != EEsProfile || parsingBuiltins)
|
||||
return;
|
||||
|
||||
if (publicType.basicType == EbtAtomicUint && publicType.qualifier.precision != EpqNone && publicType.qualifier.precision != EpqHigh)
|
||||
if (baseType == EbtAtomicUint && qualifier.precision != EpqNone && qualifier.precision != EpqHigh)
|
||||
error(loc, "atomic counters can only be highp", "atomic_uint", "");
|
||||
|
||||
if (publicType.basicType == EbtFloat || publicType.basicType == EbtUint || publicType.basicType == EbtInt || publicType.basicType == EbtSampler || publicType.basicType == EbtAtomicUint) {
|
||||
if (publicType.qualifier.precision == EpqNone) {
|
||||
if (baseType == EbtFloat || baseType == EbtUint || baseType == EbtInt || baseType == EbtSampler || baseType == EbtAtomicUint) {
|
||||
if (qualifier.precision == EpqNone) {
|
||||
if (messages & EShMsgRelaxedErrors)
|
||||
warn(loc, "type requires declaration of default precision qualifier", TType::getBasicString(publicType.basicType), "substituting 'mediump'");
|
||||
warn(loc, "type requires declaration of default precision qualifier", TType::getBasicString(baseType), "substituting 'mediump'");
|
||||
else
|
||||
error(loc, "type requires declaration of default precision qualifier", TType::getBasicString(publicType.basicType), "");
|
||||
publicType.qualifier.precision = EpqMedium;
|
||||
defaultPrecision[publicType.basicType] = EpqMedium;
|
||||
error(loc, "type requires declaration of default precision qualifier", TType::getBasicString(baseType), "");
|
||||
qualifier.precision = EpqMedium;
|
||||
defaultPrecision[baseType] = EpqMedium;
|
||||
}
|
||||
} else if (publicType.qualifier.precision != EpqNone)
|
||||
error(loc, "type cannot have precision qualifier", TType::getBasicString(publicType.basicType), "");
|
||||
} else if (qualifier.precision != EpqNone)
|
||||
error(loc, "type cannot have precision qualifier", TType::getBasicString(baseType), "");
|
||||
}
|
||||
|
||||
void TParseContext::parameterTypeCheck(TSourceLoc loc, TStorageQualifier qualifier, const TType& type)
|
||||
|
||||
@ -138,7 +138,7 @@ public:
|
||||
void setDefaultPrecision(TSourceLoc, TPublicType&, TPrecisionQualifier);
|
||||
int computeSamplerTypeIndex(TSampler&);
|
||||
TPrecisionQualifier getDefaultPrecision(TPublicType&);
|
||||
void precisionQualifierCheck(TSourceLoc, TPublicType&);
|
||||
void precisionQualifierCheck(TSourceLoc, TBasicType, TQualifier&);
|
||||
void parameterTypeCheck(TSourceLoc, TStorageQualifier qualifier, const TType& type);
|
||||
bool containsFieldWithBasicType(const TType& type ,TBasicType basicType);
|
||||
TSymbol* redeclareBuiltinVariable(TSourceLoc, const TString&, const TQualifier&, const TShaderQualifiers&, bool& newDeclaration);
|
||||
|
||||
@ -609,7 +609,7 @@ assignment_operator
|
||||
$$.loc = $1.loc;
|
||||
$$.op = EOpDivAssign;
|
||||
}
|
||||
| MOD_ASSIGN {
|
||||
| MOD_ASSIGN {
|
||||
parseContext.fullIntegerCheck($1.loc, "%=");
|
||||
$$.loc = $1.loc;
|
||||
$$.op = EOpModAssign;
|
||||
@ -622,7 +622,7 @@ assignment_operator
|
||||
$$.loc = $1.loc;
|
||||
$$.op = EOpSubAssign;
|
||||
}
|
||||
| LEFT_ASSIGN {
|
||||
| LEFT_ASSIGN {
|
||||
parseContext.fullIntegerCheck($1.loc, "bit-shift left assign");
|
||||
$$.loc = $1.loc; $$.op = EOpLeftShiftAssign;
|
||||
}
|
||||
@ -630,15 +630,15 @@ assignment_operator
|
||||
parseContext.fullIntegerCheck($1.loc, "bit-shift right assign");
|
||||
$$.loc = $1.loc; $$.op = EOpRightShiftAssign;
|
||||
}
|
||||
| AND_ASSIGN {
|
||||
| AND_ASSIGN {
|
||||
parseContext.fullIntegerCheck($1.loc, "bitwise-and assign");
|
||||
$$.loc = $1.loc; $$.op = EOpAndAssign;
|
||||
}
|
||||
| XOR_ASSIGN {
|
||||
| XOR_ASSIGN {
|
||||
parseContext.fullIntegerCheck($1.loc, "bitwise-xor assign");
|
||||
$$.loc = $1.loc; $$.op = EOpExclusiveOrAssign;
|
||||
}
|
||||
| OR_ASSIGN {
|
||||
| OR_ASSIGN {
|
||||
parseContext.fullIntegerCheck($1.loc, "bitwise-or assign");
|
||||
$$.loc = $1.loc; $$.op = EOpInclusiveOrAssign;
|
||||
}
|
||||
@ -809,7 +809,6 @@ parameter_declarator
|
||||
parseContext.error($2.loc, "illegal use of type 'void'", $2.string->c_str(), "");
|
||||
}
|
||||
parseContext.reservedErrorCheck($2.loc, *$2.string);
|
||||
parseContext.precisionQualifierCheck($1.loc, $1);
|
||||
|
||||
TParameter param = {$2.string, new TType($1)};
|
||||
$$.loc = $2.loc;
|
||||
@ -825,7 +824,6 @@ parameter_declarator
|
||||
|
||||
parseContext.arraySizeRequiredCheck($3.loc, $3.arraySizes->getSize());
|
||||
parseContext.reservedErrorCheck($2.loc, *$2.string);
|
||||
parseContext.precisionQualifierCheck($1.loc, $1);
|
||||
|
||||
$1.arraySizes = $3.arraySizes;
|
||||
|
||||
@ -843,16 +841,19 @@ parameter_declaration
|
||||
$$ = $2;
|
||||
if ($1.qualifier.precision != EpqNone)
|
||||
$$.param.type->getQualifier().precision = $1.qualifier.precision;
|
||||
parseContext.precisionQualifierCheck($$.loc, $$.param.type->getBasicType(), $$.param.type->getQualifier());
|
||||
|
||||
parseContext.checkNoShaderLayouts($1.loc, $1.shaderQualifiers);
|
||||
parseContext.parameterTypeCheck($2.loc, $1.qualifier.storage, *$$.param.type);
|
||||
parseContext.paramCheckFix($1.loc, $1.qualifier, *$$.param.type);
|
||||
|
||||
}
|
||||
| parameter_declarator {
|
||||
$$ = $1;
|
||||
|
||||
parseContext.parameterTypeCheck($1.loc, EvqIn, *$1.param.type);
|
||||
parseContext.paramCheckFix($1.loc, EvqTemporary, *$$.param.type);
|
||||
parseContext.precisionQualifierCheck($$.loc, $$.param.type->getBasicType(), $$.param.type->getQualifier());
|
||||
}
|
||||
//
|
||||
// Without name
|
||||
@ -861,6 +862,7 @@ parameter_declaration
|
||||
$$ = $2;
|
||||
if ($1.qualifier.precision != EpqNone)
|
||||
$$.param.type->getQualifier().precision = $1.qualifier.precision;
|
||||
parseContext.precisionQualifierCheck($1.loc, $$.param.type->getBasicType(), $$.param.type->getQualifier());
|
||||
|
||||
parseContext.checkNoShaderLayouts($1.loc, $1.shaderQualifiers);
|
||||
parseContext.parameterTypeCheck($2.loc, $1.qualifier.storage, *$$.param.type);
|
||||
@ -871,6 +873,7 @@ parameter_declaration
|
||||
|
||||
parseContext.parameterTypeCheck($1.loc, EvqIn, *$1.param.type);
|
||||
parseContext.paramCheckFix($1.loc, EvqTemporary, *$$.param.type);
|
||||
parseContext.precisionQualifierCheck($$.loc, $$.param.type->getBasicType(), $$.param.type->getQualifier());
|
||||
}
|
||||
;
|
||||
|
||||
@ -880,7 +883,6 @@ parameter_type_specifier
|
||||
$$.param = param;
|
||||
if ($1.arraySizes)
|
||||
parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getSize());
|
||||
parseContext.precisionQualifierCheck($1.loc, $1);
|
||||
}
|
||||
;
|
||||
|
||||
@ -947,7 +949,7 @@ fully_specified_type
|
||||
parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
|
||||
}
|
||||
|
||||
parseContext.precisionQualifierCheck($$.loc, $$);
|
||||
parseContext.precisionQualifierCheck($$.loc, $$.basicType, $$.qualifier);
|
||||
}
|
||||
| type_qualifier type_specifier {
|
||||
parseContext.globalQualifierFixCheck($1.loc, $1.qualifier);
|
||||
@ -964,7 +966,7 @@ fully_specified_type
|
||||
parseContext.checkNoShaderLayouts($2.loc, $1.shaderQualifiers);
|
||||
$2.shaderQualifiers.merge($1.shaderQualifiers);
|
||||
parseContext.mergeQualifiers($2.loc, $2.qualifier, $1.qualifier, true);
|
||||
parseContext.precisionQualifierCheck($2.loc, $2);
|
||||
parseContext.precisionQualifierCheck($2.loc, $2.basicType, $2.qualifier);
|
||||
|
||||
$$ = $2;
|
||||
|
||||
@ -1955,7 +1957,7 @@ struct_declaration
|
||||
$$ = $2;
|
||||
|
||||
parseContext.voidErrorCheck($1.loc, (*$2)[0].type->getFieldName(), $1.basicType);
|
||||
parseContext.precisionQualifierCheck($1.loc, $1);
|
||||
parseContext.precisionQualifierCheck($1.loc, $1.basicType, $1.qualifier);
|
||||
|
||||
for (unsigned int i = 0; i < $$->size(); ++i) {
|
||||
parseContext.arrayDimCheck($1.loc, (*$$)[i].type, $1.arraySizes);
|
||||
@ -1976,7 +1978,7 @@ struct_declaration
|
||||
parseContext.checkNoShaderLayouts($1.loc, $1.shaderQualifiers);
|
||||
parseContext.voidErrorCheck($2.loc, (*$3)[0].type->getFieldName(), $2.basicType);
|
||||
parseContext.mergeQualifiers($2.loc, $2.qualifier, $1.qualifier, true);
|
||||
parseContext.precisionQualifierCheck($2.loc, $2);
|
||||
parseContext.precisionQualifierCheck($2.loc, $2.basicType, $2.qualifier);
|
||||
|
||||
for (unsigned int i = 0; i < $$->size(); ++i) {
|
||||
parseContext.arrayDimCheck($1.loc, (*$$)[i].type, $2.arraySizes);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user