Correct precision qualification on built-in functions.

This is a replacement commit for pull request #238.

This is a design change, followed by implementation change that
A) fixes the changes caused by the design change, and
B) fixes some cases that were originally incorrect.

The design change is to not give built-in functions default precision qualification.
This is to allow the rule that the precision of some built-in functions adopt their
precision qualification from the calling arguments.  This is A above.

A consequence of this design change is that all built-ins that are supposed to have
an explicit precision qualifier must now be declared that way.  So, a lot more
built-in declarations now have precision qualifiers, just to keep things the same.
This is B above.
This commit is contained in:
John Kessenich 2016-05-03 19:34:00 -06:00
parent f88a5c756e
commit af459216a1
13 changed files with 213 additions and 199 deletions

View file

@ -69,7 +69,7 @@ TParseContext::TParseContext(TSymbolTable& symbolTable, TIntermediate& interm, b
for (int type = 0; type < maxSamplerIndex; ++type)
defaultSamplerPrecision[type] = EpqNone;
// replace with real defaults for those that have them
// replace with real precision defaults for those that have them
if (profile == EEsProfile) {
TSampler sampler;
sampler.set(EbtFloat, Esd2D);
@ -80,16 +80,22 @@ TParseContext::TParseContext(TSymbolTable& symbolTable, TIntermediate& interm, b
sampler.external = true;
defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
switch (language) {
case EShLangFragment:
defaultPrecision[EbtInt] = EpqMedium;
defaultPrecision[EbtUint] = EpqMedium;
break;
default:
defaultPrecision[EbtInt] = EpqHigh;
defaultPrecision[EbtUint] = EpqHigh;
defaultPrecision[EbtFloat] = EpqHigh;
break;
// If we are parsing built-in computational variables/functions, it is meaningful to record
// whether the built-in has no precision qualifier, as that ambiguity
// is used to resolve the precision from the supplied arguments/operands instead.
// So, we don't actually want to replace EpqNone with a default precision for built-ins.
if (! parsingBuiltins) {
switch (language) {
case EShLangFragment:
defaultPrecision[EbtInt] = EpqMedium;
defaultPrecision[EbtUint] = EpqMedium;
break;
default:
defaultPrecision[EbtInt] = EpqHigh;
defaultPrecision[EbtUint] = EpqHigh;
defaultPrecision[EbtFloat] = EpqHigh;
break;
}
}
defaultPrecision[EbtSampler] = EpqLow;