Vulkan: Have desktop shaders respect precision qualifiers.
Sets highp defaults for the appropriate types, for all stages, and turns on precision qualifiers for non-ES shaders. Required fixing some qualifier orders for desktop built-in declarations for pre-420 shaders.
This commit is contained in:
@@ -1460,15 +1460,15 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"uvec3 usubBorrow(highp uvec3, highp uvec3, out lowp uvec3 borrow);"
|
||||
"uvec4 usubBorrow(highp uvec4, highp uvec4, out lowp uvec4 borrow);"
|
||||
|
||||
"void umulExtended(highp uint, highp uint, highp out uint, out highp uint lsb);"
|
||||
"void umulExtended(highp uvec2, highp uvec2, highp out uvec2, out highp uvec2 lsb);"
|
||||
"void umulExtended(highp uvec3, highp uvec3, highp out uvec3, out highp uvec3 lsb);"
|
||||
"void umulExtended(highp uvec4, highp uvec4, highp out uvec4, out highp uvec4 lsb);"
|
||||
"void umulExtended(highp uint, highp uint, out highp uint, out highp uint lsb);"
|
||||
"void umulExtended(highp uvec2, highp uvec2, out highp uvec2, out highp uvec2 lsb);"
|
||||
"void umulExtended(highp uvec3, highp uvec3, out highp uvec3, out highp uvec3 lsb);"
|
||||
"void umulExtended(highp uvec4, highp uvec4, out highp uvec4, out highp uvec4 lsb);"
|
||||
|
||||
"void imulExtended(highp int, highp int, highp out int, out highp int lsb);"
|
||||
"void imulExtended(highp ivec2, highp ivec2, highp out ivec2, out highp ivec2 lsb);"
|
||||
"void imulExtended(highp ivec3, highp ivec3, highp out ivec3, out highp ivec3 lsb);"
|
||||
"void imulExtended(highp ivec4, highp ivec4, highp out ivec4, out highp ivec4 lsb);"
|
||||
"void imulExtended(highp int, highp int, out highp int, out highp int lsb);"
|
||||
"void imulExtended(highp ivec2, highp ivec2, out highp ivec2, out highp ivec2 lsb);"
|
||||
"void imulExtended(highp ivec3, highp ivec3, out highp ivec3, out highp ivec3 lsb);"
|
||||
"void imulExtended(highp ivec4, highp ivec4, out highp ivec4, out highp ivec4 lsb);"
|
||||
|
||||
" int bitfieldReverse(highp int);"
|
||||
"ivec2 bitfieldReverse(highp ivec2);"
|
||||
@@ -2638,10 +2638,10 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
);
|
||||
|
||||
stageBuiltins[EShLangFragment].append( // GL_OES_sample_variables
|
||||
"flat lowp in int gl_SampleID;"
|
||||
" mediump in vec2 gl_SamplePosition;"
|
||||
"flat highp in int gl_SampleMaskIn[];"
|
||||
" highp out int gl_SampleMask[];"
|
||||
"flat in lowp int gl_SampleID;"
|
||||
" in mediump vec2 gl_SamplePosition;"
|
||||
"flat in highp int gl_SampleMaskIn[];"
|
||||
" out highp int gl_SampleMask[];"
|
||||
"uniform lowp int gl_NumSamples;"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ TParseContext::TParseContext(TSymbolTable& symbolTable, TIntermediate& interm, b
|
||||
linkage = new TIntermAggregate;
|
||||
|
||||
// decide whether precision qualifiers should be ignored or respected
|
||||
obeyPrecisionQualifiers_ = profile == EEsProfile;
|
||||
obeyPrecisionQualifiers_ = profile == EEsProfile || spvVersion.vulkan > 0;
|
||||
setPrecisionDefaults();
|
||||
|
||||
globalUniformDefaults.clear();
|
||||
@@ -98,8 +98,11 @@ TParseContext::~TParseContext()
|
||||
// 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)
|
||||
// Set all precision defaults to EpqNone, which is correct for all types
|
||||
// when not obeying precision qualifiers, and correct for types that don't
|
||||
// have defaults (thus getting an error on use) when obeying precision
|
||||
// qualifiers.
|
||||
|
||||
for (int type = 0; type < EbtNumTypes; ++type)
|
||||
defaultPrecision[type] = EpqNone;
|
||||
|
||||
@@ -108,30 +111,35 @@ void TParseContext::setPrecisionDefaults()
|
||||
|
||||
// replace with real precision defaults for those that have them
|
||||
if (obeyPrecisionQualifiers()) {
|
||||
TSampler sampler;
|
||||
sampler.set(EbtFloat, Esd2D);
|
||||
defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
|
||||
sampler.set(EbtFloat, EsdCube);
|
||||
defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
|
||||
sampler.set(EbtFloat, Esd2D);
|
||||
sampler.external = true;
|
||||
defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
|
||||
if (profile == EEsProfile) {
|
||||
// Most don't have defaults, a few default to lowp.
|
||||
TSampler sampler;
|
||||
sampler.set(EbtFloat, Esd2D);
|
||||
defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
|
||||
sampler.set(EbtFloat, EsdCube);
|
||||
defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
|
||||
sampler.set(EbtFloat, Esd2D);
|
||||
sampler.external = true;
|
||||
defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
|
||||
} else {
|
||||
// Non-ES profile
|
||||
// All default to highp.
|
||||
for (int type = 0; type < maxSamplerIndex; ++type)
|
||||
defaultSamplerPrecision[type] = EpqHigh;
|
||||
}
|
||||
|
||||
// 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:
|
||||
if (profile == EEsProfile && language == EShLangFragment) {
|
||||
defaultPrecision[EbtInt] = EpqMedium;
|
||||
defaultPrecision[EbtUint] = EpqMedium;
|
||||
break;
|
||||
default:
|
||||
} else {
|
||||
defaultPrecision[EbtInt] = EpqHigh;
|
||||
defaultPrecision[EbtUint] = EpqHigh;
|
||||
defaultPrecision[EbtFloat] = EpqHigh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user