Turn on ESSL 3.1 for most features:
- images: load/store, memory qualifiers - buffer blocks - compute shaders - atomic counters - texture gather - SSO - uniform locations - all the numeric-based version # comparisons git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@27710 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
bedb1bc2db
commit
4d57090da5
20 changed files with 500 additions and 195 deletions
|
|
@ -248,20 +248,23 @@ enum TLayoutFormat {
|
|||
// Float image
|
||||
ElfRgba32f,
|
||||
ElfRgba16f,
|
||||
ElfR32f,
|
||||
ElfRgba8,
|
||||
ElfRgba8Snorm,
|
||||
|
||||
ElfEsFloatGuard, // to help with comparisons
|
||||
|
||||
ElfRg32f,
|
||||
ElfRg16f,
|
||||
ElfR11fG11fB10f,
|
||||
ElfR32f,
|
||||
ElfR16f,
|
||||
ElfRgba16,
|
||||
ElfRgb10A2,
|
||||
ElfRgba8,
|
||||
ElfRg16,
|
||||
ElfRg8,
|
||||
ElfR16,
|
||||
ElfR8,
|
||||
ElfRgba16Snorm,
|
||||
ElfRgba8Snorm,
|
||||
ElfRg16Snorm,
|
||||
ElfRg8Snorm,
|
||||
ElfR16Snorm,
|
||||
|
|
@ -273,10 +276,13 @@ enum TLayoutFormat {
|
|||
ElfRgba32i,
|
||||
ElfRgba16i,
|
||||
ElfRgba8i,
|
||||
ElfR32i,
|
||||
|
||||
ElfEsIntGuard, // to help with comparisons
|
||||
|
||||
ElfRg32i,
|
||||
ElfRg16i,
|
||||
ElfRg8i,
|
||||
ElfR32i,
|
||||
ElfR16i,
|
||||
ElfR8i,
|
||||
|
||||
|
|
@ -286,10 +292,13 @@ enum TLayoutFormat {
|
|||
ElfRgba32ui,
|
||||
ElfRgba16ui,
|
||||
ElfRgba8ui,
|
||||
ElfR32ui,
|
||||
|
||||
ElfEsUintGuard, // to help with comparisons
|
||||
|
||||
ElfRg32ui,
|
||||
ElfRg16ui,
|
||||
ElfRg8ui,
|
||||
ElfR32ui,
|
||||
ElfR16ui,
|
||||
ElfR8ui,
|
||||
|
||||
|
|
|
|||
|
|
@ -743,7 +743,8 @@ void TBuiltIns::initialize(int version, EProfile profile)
|
|||
//
|
||||
// Atomic counter functions.
|
||||
//
|
||||
if (profile != EEsProfile && version >= 420) {
|
||||
if ((profile != EEsProfile && version >= 420) ||
|
||||
(profile == EEsProfile && version >= 310)) {
|
||||
commonBuiltins.append(
|
||||
"uint atomicCounterIncrement(atomic_uint x);"
|
||||
"uint atomicCounterDecrement(atomic_uint x);"
|
||||
|
|
@ -841,38 +842,37 @@ void TBuiltIns::initialize(int version, EProfile profile)
|
|||
|
||||
"\n");
|
||||
}
|
||||
if (profile != EEsProfile) {
|
||||
//============================================================================
|
||||
//
|
||||
// Prototypes for all control functions.
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
if (version >= 150)
|
||||
stageBuiltins[EShLangTessControl].append(
|
||||
"void barrier();"
|
||||
);
|
||||
if (version >= 430)
|
||||
stageBuiltins[EShLangCompute].append(
|
||||
"void barrier();"
|
||||
);
|
||||
|
||||
if (version >= 130)
|
||||
commonBuiltins.append(
|
||||
"void memoryBarrier();"
|
||||
);
|
||||
if (version >= 430) {
|
||||
commonBuiltins.append(
|
||||
"void memoryBarrierAtomicCounter();"
|
||||
"void memoryBarrierBuffer();"
|
||||
"void memoryBarrierImage();"
|
||||
);
|
||||
stageBuiltins[EShLangCompute].append(
|
||||
"void memoryBarrierShared();"
|
||||
"void groupMemoryBarrier();"
|
||||
);
|
||||
}
|
||||
//============================================================================
|
||||
//
|
||||
// Prototypes for all control functions.
|
||||
//
|
||||
//============================================================================
|
||||
bool esBarrier = (profile == EEsProfile && version >= 310);
|
||||
if (profile != EEsProfile && version >= 150)
|
||||
stageBuiltins[EShLangTessControl].append(
|
||||
"void barrier();"
|
||||
);
|
||||
if ((profile != EEsProfile && version >= 430) || esBarrier)
|
||||
stageBuiltins[EShLangCompute].append(
|
||||
"void barrier();"
|
||||
);
|
||||
if ((profile != EEsProfile && version >= 130) || esBarrier)
|
||||
commonBuiltins.append(
|
||||
"void memoryBarrier();"
|
||||
);
|
||||
if ((profile != EEsProfile && version >= 430) || esBarrier) {
|
||||
commonBuiltins.append(
|
||||
"void memoryBarrierAtomicCounter();"
|
||||
"void memoryBarrierBuffer();"
|
||||
"void memoryBarrierImage();"
|
||||
);
|
||||
stageBuiltins[EShLangCompute].append(
|
||||
"void memoryBarrierShared();"
|
||||
"void groupMemoryBarrier();"
|
||||
);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// Prototypes for built-in functions seen by fragment shaders only.
|
||||
|
|
@ -1088,7 +1088,8 @@ void TBuiltIns::initialize(int version, EProfile profile)
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
if (version >= 430) {
|
||||
if (profile != EEsProfile && version >= 430 ||
|
||||
profile == EEsProfile && version >= 310) {
|
||||
stageBuiltins[EShLangCompute].append(
|
||||
"in uvec3 gl_NumWorkGroups;"
|
||||
"const uvec3 gl_WorkGroupSize = uvec3(1,1,1);"
|
||||
|
|
@ -1276,11 +1277,11 @@ void TBuiltIns::initialize(int version, EProfile profile)
|
|||
"out vec4 gl_ClipVertex;"
|
||||
);
|
||||
|
||||
if (version >= 400)
|
||||
if (version >= 400 && profile != EEsProfile)
|
||||
stageBuiltins[EShLangGeometry].append(
|
||||
"in int gl_InvocationID;"
|
||||
);
|
||||
if (version >= 410)
|
||||
if (version >= 410 && profile != EEsProfile)
|
||||
stageBuiltins[EShLangGeometry].append(
|
||||
"out int gl_ViewportIndex;"
|
||||
);
|
||||
|
|
@ -1434,6 +1435,11 @@ void TBuiltIns::initialize(int version, EProfile profile)
|
|||
"flat in int gl_Layer;"
|
||||
"flat in int gl_ViewportIndex;"
|
||||
);
|
||||
|
||||
if (version >= 450)
|
||||
stageBuiltins[EShLangFragment].append(
|
||||
"bool gl_HelperInvocation;" // needs qualifier fixed later
|
||||
);
|
||||
} else {
|
||||
// ES profile
|
||||
|
||||
|
|
@ -1444,13 +1450,18 @@ void TBuiltIns::initialize(int version, EProfile profile)
|
|||
"mediump vec4 gl_FragColor;" // needs qualifier fixed later
|
||||
"mediump vec2 gl_PointCoord;" // needs qualifier fixed later
|
||||
);
|
||||
else if (version == 300)
|
||||
else if (version >= 300) {
|
||||
stageBuiltins[EShLangFragment].append(
|
||||
"highp vec4 gl_FragCoord;" // needs qualifier fixed later
|
||||
" bool gl_FrontFacing;" // needs qualifier fixed later
|
||||
"mediump vec2 gl_PointCoord;" // needs qualifier fixed later
|
||||
"highp float gl_FragDepth;" // needs qualifier fixed later
|
||||
);
|
||||
if (version >= 310)
|
||||
stageBuiltins[EShLangFragment].append(
|
||||
"bool gl_HelperInvocation;" // needs qualifier fixed later
|
||||
);
|
||||
}
|
||||
stageBuiltins[EShLangFragment].append(
|
||||
"highp float gl_FragDepthEXT;" // GL_EXT_frag_depth
|
||||
);
|
||||
|
|
@ -1554,7 +1565,7 @@ void TBuiltIns::addQueryFunctions(TSampler sampler, TString& typeName, int versi
|
|||
// textureSize
|
||||
//
|
||||
|
||||
if (version < 430 && sampler.image)
|
||||
if (sampler.image && ((profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 430)))
|
||||
return;
|
||||
|
||||
if (profile == EEsProfile)
|
||||
|
|
@ -1607,40 +1618,42 @@ void TBuiltIns::addImageFunctions(TSampler sampler, TString& typeName, int versi
|
|||
commonBuiltins.append(prefixes[sampler.type]);
|
||||
commonBuiltins.append("vec4);\n");
|
||||
|
||||
if (sampler.type == EbtInt || sampler.type == EbtUint) {
|
||||
const char* dataType = sampler.type == EbtInt ? "int" : "uint";
|
||||
if (profile != EEsProfile) {
|
||||
if (sampler.type == EbtInt || sampler.type == EbtUint) {
|
||||
const char* dataType = sampler.type == EbtInt ? "int" : "uint";
|
||||
|
||||
const int numBuiltins = 7;
|
||||
const int numBuiltins = 7;
|
||||
|
||||
static const char* atomicFunc[numBuiltins] = {
|
||||
" imageAtomicAdd(",
|
||||
" imageAtomicMin(",
|
||||
" imageAtomicMax(",
|
||||
" imageAtomicAnd(",
|
||||
" imageAtomicOr(",
|
||||
" imageAtomicXor(",
|
||||
" imageAtomicExchange("
|
||||
};
|
||||
static const char* atomicFunc[numBuiltins] = {
|
||||
" imageAtomicAdd(",
|
||||
" imageAtomicMin(",
|
||||
" imageAtomicMax(",
|
||||
" imageAtomicAnd(",
|
||||
" imageAtomicOr(",
|
||||
" imageAtomicXor(",
|
||||
" imageAtomicExchange("
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < numBuiltins; ++i) {
|
||||
commonBuiltins.append(dataType);
|
||||
commonBuiltins.append(atomicFunc[i]);
|
||||
if (version >= 450)
|
||||
commonBuiltins.append("coherent ");
|
||||
commonBuiltins.append(imageParams);
|
||||
commonBuiltins.append(", ");
|
||||
commonBuiltins.append(dataType);
|
||||
commonBuiltins.append(");\n");
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < numBuiltins; ++i) {
|
||||
commonBuiltins.append(dataType);
|
||||
commonBuiltins.append(atomicFunc[i]);
|
||||
if (version >= 450)
|
||||
commonBuiltins.append("coherent ");
|
||||
commonBuiltins.append(" imageAtomicCompSwap(");
|
||||
commonBuiltins.append(imageParams);
|
||||
commonBuiltins.append(", ");
|
||||
commonBuiltins.append(dataType);
|
||||
commonBuiltins.append(", ");
|
||||
commonBuiltins.append(dataType);
|
||||
commonBuiltins.append(");\n");
|
||||
}
|
||||
|
||||
commonBuiltins.append(dataType);
|
||||
commonBuiltins.append(" imageAtomicCompSwap(");
|
||||
commonBuiltins.append(imageParams);
|
||||
commonBuiltins.append(", ");
|
||||
commonBuiltins.append(dataType);
|
||||
commonBuiltins.append(", ");
|
||||
commonBuiltins.append(dataType);
|
||||
commonBuiltins.append(");\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1848,6 +1861,9 @@ void TBuiltIns::addGatherFunctions(TSampler sampler, TString& typeName, int vers
|
|||
|
||||
for (int offset = 0; offset < 3; ++offset) { // loop over three forms of offset in the call name: none, Offset, and Offsets
|
||||
|
||||
if (profile == EEsProfile && offset == 2)
|
||||
continue;
|
||||
|
||||
for (int comp = 0; comp < 2; ++comp) { // loop over presence of comp argument
|
||||
|
||||
if (comp > 0 && sampler.shadow)
|
||||
|
|
@ -2156,24 +2172,6 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
|
|||
s.append(builtInConstant);
|
||||
}
|
||||
|
||||
// atomic counters
|
||||
if (version >= 420) {
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounters = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounters = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounters = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounters = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentAtomicCounters = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedAtomicCounters = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxAtomicCounterBindings = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounterBuffers = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounterBuffers = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounterBuffers = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounterBuffers = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentAtomicCounterBuffers = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedAtomicCounterBuffers = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxAtomicCounterBufferSize = %d;", resources.);
|
||||
}
|
||||
|
||||
// images
|
||||
if (version >= 130) {
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxImageUnits = %d;", resources.maxImageUnits);
|
||||
|
|
@ -2198,29 +2196,6 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
|
|||
s.append(builtInConstant);
|
||||
}
|
||||
|
||||
// compute
|
||||
if (version >= 430) {
|
||||
snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupCount = {%d,%d,%d};", resources.maxComputeWorkGroupCountX,
|
||||
resources.maxComputeWorkGroupCountY,
|
||||
resources.maxComputeWorkGroupCountZ);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupSize = {%d,%d,%d};", resources.maxComputeWorkGroupSizeX,
|
||||
resources.maxComputeWorkGroupSizeY,
|
||||
resources.maxComputeWorkGroupSizeZ);
|
||||
s.append(builtInConstant);
|
||||
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxComputeUniformComponents = %d;", resources.maxComputeUniformComponents);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxComputeTextureImageUnits = %d;", resources.maxComputeTextureImageUnits);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxComputeImageUniforms = %d;", resources.maxComputeImageUniforms);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxComputeAtomicCounters = %d;", resources.maxComputeAtomicCounters);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxComputeAtomicCounterBuffers = %d;", resources.maxComputeAtomicCounterBuffers);
|
||||
s.append(builtInConstant);
|
||||
}
|
||||
|
||||
// enhanced layouts
|
||||
if (version >= 430) {
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxTransformFeedbackBuffers = %d;", resources.maxTransformFeedbackBuffers);
|
||||
|
|
@ -2230,6 +2205,50 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: atomic counters
|
||||
if (profile == EEsProfile && version >= 310 || profile != EEsProfile && version >= 420) {
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounters = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentAtomicCounters = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedAtomicCounters = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxAtomicCounterBindings = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounterBuffers = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentAtomicCounterBuffers = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedAtomicCounterBuffers = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxAtomicCounterBufferSize = %d;", resources.);
|
||||
}
|
||||
if (profile != EEsProfile && version >= 420) {
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounters = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounters = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounters = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounterBuffers = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounterBuffers = %d;", resources.);
|
||||
//snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounterBuffers = %d;", resources.);
|
||||
}
|
||||
|
||||
|
||||
// compute
|
||||
if ((profile == EEsProfile && version >= 310) || (profile != EEsProfile && version >= 430)) {
|
||||
snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupCount = ivec3(%d,%d,%d);", resources.maxComputeWorkGroupCountX,
|
||||
resources.maxComputeWorkGroupCountY,
|
||||
resources.maxComputeWorkGroupCountZ);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupSize = ivec3(%d,%d,%d);", resources.maxComputeWorkGroupSizeX,
|
||||
resources.maxComputeWorkGroupSizeY,
|
||||
resources.maxComputeWorkGroupSizeZ);
|
||||
s.append(builtInConstant);
|
||||
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxComputeUniformComponents = %d;", resources.maxComputeUniformComponents);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxComputeTextureImageUnits = %d;", resources.maxComputeTextureImageUnits);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxComputeImageUniforms = %d;", resources.maxComputeImageUniforms);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxComputeAtomicCounters = %d;", resources.maxComputeAtomicCounters);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxComputeAtomicCounterBuffers = %d;", resources.maxComputeAtomicCounterBuffers);
|
||||
s.append(builtInConstant);
|
||||
}
|
||||
|
||||
s.append("\n");
|
||||
}
|
||||
|
||||
|
|
@ -2284,12 +2303,13 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
|
|||
break;
|
||||
|
||||
case EShLangFragment:
|
||||
SpecialQualifier("gl_FrontFacing", EvqFace, symbolTable);
|
||||
SpecialQualifier("gl_FragCoord", EvqFragCoord, symbolTable);
|
||||
SpecialQualifier("gl_PointCoord", EvqPointCoord, symbolTable);
|
||||
SpecialQualifier("gl_FragColor", EvqFragColor, symbolTable);
|
||||
SpecialQualifier("gl_FragDepth", EvqFragDepth, symbolTable);
|
||||
SpecialQualifier("gl_FragDepthEXT", EvqFragDepth, symbolTable);
|
||||
SpecialQualifier("gl_FrontFacing", EvqFace, symbolTable);
|
||||
SpecialQualifier("gl_FragCoord", EvqFragCoord, symbolTable);
|
||||
SpecialQualifier("gl_PointCoord", EvqPointCoord, symbolTable);
|
||||
SpecialQualifier("gl_FragColor", EvqFragColor, symbolTable);
|
||||
SpecialQualifier("gl_FragDepth", EvqFragDepth, symbolTable);
|
||||
SpecialQualifier("gl_FragDepthEXT", EvqFragDepth, symbolTable);
|
||||
SpecialQualifier("gl_HelperInvocation", EvqIn, symbolTable);
|
||||
if (version == 100) {
|
||||
symbolTable.setFunctionExtensions("dFdx", 1, &GL_OES_standard_derivatives);
|
||||
symbolTable.setFunctionExtensions("dFdy", 1, &GL_OES_standard_derivatives);
|
||||
|
|
@ -2339,7 +2359,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
|
|||
}
|
||||
|
||||
// GL_ARB_shader_image_load_store
|
||||
if (version < 420)
|
||||
if (profile != EEsProfile && version < 420)
|
||||
symbolTable.setFunctionExtensions("memoryBarrier", 1, &GL_ARB_shader_image_load_store);
|
||||
// All the image access functions are protected by checks on the type of the first argument.
|
||||
|
||||
|
|
@ -2495,7 +2515,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
|
|||
//
|
||||
void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources)
|
||||
{
|
||||
if (version >= 430 && version < 440) {
|
||||
if (profile != EEsProfile && version >= 430 && version < 440) {
|
||||
symbolTable.setVariableExtensions("gl_MaxTransformFeedbackBuffers", 1, &GL_ARB_enhanced_layouts);
|
||||
symbolTable.setVariableExtensions("gl_MaxTransformFeedbackInterleavedComponents", 1, &GL_ARB_enhanced_layouts);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,15 +82,16 @@ TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, bool pb,
|
|||
case EShLangFragment:
|
||||
defaultPrecision[EbtInt] = EpqMedium;
|
||||
defaultPrecision[EbtUint] = EpqMedium;
|
||||
defaultPrecision[EbtSampler] = EpqLow;
|
||||
break;
|
||||
default:
|
||||
defaultPrecision[EbtInt] = EpqHigh;
|
||||
defaultPrecision[EbtUint] = EpqHigh;
|
||||
defaultPrecision[EbtFloat] = EpqHigh;
|
||||
defaultPrecision[EbtSampler] = EpqLow;
|
||||
break;
|
||||
}
|
||||
|
||||
defaultPrecision[EbtSampler] = EpqLow;
|
||||
defaultPrecision[EbtAtomicUint] = EpqHigh;
|
||||
}
|
||||
|
||||
globalUniformDefaults.clear();
|
||||
|
|
@ -1216,7 +1217,7 @@ void TParseContext::nonOpBuiltInCheck(TSourceLoc loc, const TFunction& fnCandida
|
|||
if (fnCandidate.getName().compare(0, 13, "textureGather") == 0) {
|
||||
TString featureString = fnCandidate.getName() + "(...)";
|
||||
const char* feature = featureString.c_str();
|
||||
requireProfile(loc, ~EEsProfile, feature);
|
||||
profileRequires(loc, EEsProfile, 310, 0, feature);
|
||||
|
||||
int compArg = -1; // track which argument, if any, is the constant component argument
|
||||
if (fnCandidate.getName().compare("textureGatherOffset") == 0) {
|
||||
|
|
@ -2067,7 +2068,9 @@ void TParseContext::mergeQualifiers(TSourceLoc loc, TQualifier& dst, const TQual
|
|||
error(loc, "can only have one interpolation qualifier (flat, smooth, noperspective)", "", "");
|
||||
|
||||
// Ordering
|
||||
if (! force && version < 420 && ! extensionsTurnedOn(1, &GL_ARB_shading_language_420pack)) {
|
||||
if (! force && ((profile != EEsProfile && version < 420) ||
|
||||
profile == EEsProfile && version < 310)
|
||||
&& ! extensionsTurnedOn(1, &GL_ARB_shading_language_420pack)) {
|
||||
// non-function parameters
|
||||
if (src.invariant && (dst.isInterpolation() || dst.isAuxiliary() || dst.storage != EvqTemporary || dst.precision != EpqNone))
|
||||
error(loc, "invariant qualifier must appear first", "", "");
|
||||
|
|
@ -2173,7 +2176,10 @@ void TParseContext::precisionQualifierCheck(TSourceLoc loc, TPublicType& publicT
|
|||
if (profile != EEsProfile || parsingBuiltins)
|
||||
return;
|
||||
|
||||
if (publicType.basicType == EbtFloat || publicType.basicType == EbtUint || publicType.basicType == EbtInt || publicType.basicType == EbtSampler) {
|
||||
if (publicType.basicType == EbtAtomicUint && publicType.qualifier.precision != EpqNone && publicType.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 (messages & EShMsgRelaxedErrors)
|
||||
warn(loc, "type requires declaration of default precision qualifier", TType::getBasicString(publicType.basicType), "substituting 'mediump'");
|
||||
|
|
@ -2262,10 +2268,21 @@ void TParseContext::arraySizeRequiredCheck(TSourceLoc loc, int size)
|
|||
}
|
||||
}
|
||||
|
||||
void TParseContext::structArrayCheck(TSourceLoc loc, TType* type)
|
||||
{
|
||||
const TTypeList& structure = *type->getStruct();
|
||||
for (int m = 0; m < (int)structure.size(); ++m) {
|
||||
const TType& member = *structure[m].type;
|
||||
if (member.isArray() && ! member.isExplicitlySizedArray())
|
||||
arraySizeRequiredCheck(structure[m].loc, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void TParseContext::arrayDimError(TSourceLoc loc)
|
||||
{
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, "arrays of arrays");
|
||||
requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, "arrays of arrays");
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, 0, "arrays of arrays");
|
||||
profileRequires(loc, EEsProfile, 310, 0, "arrays of arrays");
|
||||
}
|
||||
|
||||
void TParseContext::arrayDimCheck(TSourceLoc loc, TArraySizes* sizes1, TArraySizes* sizes2)
|
||||
|
|
@ -2955,15 +2972,20 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
|
|||
return;
|
||||
}
|
||||
if (id == TQualifier::getLayoutPackingString(ElpStd430)) {
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, "std430");
|
||||
requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, "std430");
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, 0, "std430");
|
||||
profileRequires(loc, EEsProfile, 310, 0, "std430");
|
||||
publicType.qualifier.layoutPacking = ElpStd430;
|
||||
return;
|
||||
}
|
||||
for (TLayoutFormat format = (TLayoutFormat)(ElfNone + 1); format < ElfCount; format = (TLayoutFormat)(format + 1)) {
|
||||
if (id == TQualifier::getLayoutFormatString(format)) {
|
||||
requireProfile(loc, ENoProfile | ECoreProfile | ECompatibilityProfile, "image load store");
|
||||
if ((format > ElfEsFloatGuard && format < ElfFloatGuard) ||
|
||||
(format > ElfEsIntGuard && format < ElfIntGuard) ||
|
||||
(format > ElfEsUintGuard && format < ElfCount))
|
||||
requireProfile(loc, ENoProfile | ECoreProfile | ECompatibilityProfile, "image load-store format");
|
||||
profileRequires(loc, ENoProfile | ECoreProfile | ECompatibilityProfile, 420, GL_ARB_shader_image_load_store, "image load store");
|
||||
profileRequires(loc, EEsProfile, 310, GL_ARB_shader_image_load_store, "image load store");
|
||||
publicType.qualifier.layoutFormat = format;
|
||||
return;
|
||||
}
|
||||
|
|
@ -3097,8 +3119,9 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
|
|||
|
||||
if (id == "offset") {
|
||||
const char* feature = "uniform buffer-member offset";
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, feature);
|
||||
requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, feature);
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, GL_ARB_enhanced_layouts, feature);
|
||||
profileRequires(loc, EEsProfile, 310, 0, feature);
|
||||
publicType.qualifier.layoutOffset = value;
|
||||
return;
|
||||
} else if (id == "align") {
|
||||
|
|
@ -3121,8 +3144,8 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
|
|||
publicType.qualifier.layoutLocation = value;
|
||||
return;
|
||||
} else if (id == "binding") {
|
||||
requireProfile(loc, ~EEsProfile, "binding");
|
||||
profileRequires(loc, ~EEsProfile, 420, GL_ARB_shading_language_420pack, "binding");
|
||||
profileRequires(loc, EEsProfile, 310, 0, "binding");
|
||||
if ((unsigned int)value >= TQualifier::layoutBindingEnd)
|
||||
error(loc, "binding is too large", id.c_str(), "");
|
||||
else
|
||||
|
|
@ -3460,35 +3483,44 @@ void TParseContext::layoutQualifierCheck(TSourceLoc loc, const TQualifier& quali
|
|||
case EvqVaryingIn:
|
||||
{
|
||||
const char* feature = "location qualifier on input";
|
||||
if (profile == EEsProfile)
|
||||
if (profile == EEsProfile && version < 310)
|
||||
requireStage(loc, EShLangVertex, feature);
|
||||
requireStage(loc, (EShLanguageMask)~EShLangComputeMask, feature);
|
||||
else
|
||||
requireStage(loc, (EShLanguageMask)~EShLangComputeMask, feature);
|
||||
if (language == EShLangVertex) {
|
||||
const char* exts[2] = { GL_ARB_separate_shader_objects, GL_ARB_explicit_attrib_location };
|
||||
profileRequires(loc, ~EEsProfile, 330, 2, exts, feature);
|
||||
} else
|
||||
profileRequires(loc, EEsProfile, 300, 0, feature);
|
||||
} else {
|
||||
profileRequires(loc, ~EEsProfile, 410, GL_ARB_separate_shader_objects, feature);
|
||||
profileRequires(loc, EEsProfile, 310, 0, feature);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EvqVaryingOut:
|
||||
{
|
||||
const char* feature = "location qualifier on output";
|
||||
if (profile == EEsProfile)
|
||||
if (profile == EEsProfile && version < 310)
|
||||
requireStage(loc, EShLangFragment, feature);
|
||||
requireStage(loc, (EShLanguageMask)~EShLangComputeMask, feature);
|
||||
else
|
||||
requireStage(loc, (EShLanguageMask)~EShLangComputeMask, feature);
|
||||
if (language == EShLangFragment) {
|
||||
const char* exts[2] = { GL_ARB_separate_shader_objects, GL_ARB_explicit_attrib_location };
|
||||
profileRequires(loc, ~EEsProfile, 330, 2, exts, feature);
|
||||
} else
|
||||
profileRequires(loc, EEsProfile, 300, 0, feature);
|
||||
} else {
|
||||
profileRequires(loc, ~EEsProfile, 410, GL_ARB_separate_shader_objects, feature);
|
||||
profileRequires(loc, EEsProfile, 310, 0, feature);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EvqUniform:
|
||||
case EvqBuffer:
|
||||
{
|
||||
const char* feature = "location qualifier on uniform or buffer";
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, feature);
|
||||
requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, feature);
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, 0, feature);
|
||||
profileRequires(loc, EEsProfile, 310, 0, feature);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -4155,8 +4187,9 @@ void TParseContext::declareBlock(TSourceLoc loc, TTypeList& typeList, const TStr
|
|||
profileRequires(loc, ENoProfile, 140, 0, "uniform block");
|
||||
break;
|
||||
case EvqBuffer:
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, "buffer block");
|
||||
requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, "buffer block");
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, 0, "buffer block");
|
||||
profileRequires(loc, EEsProfile, 310, 0, "buffer block");
|
||||
break;
|
||||
case EvqVaryingIn:
|
||||
requireProfile(loc, ~EEsProfile, "input block");
|
||||
|
|
@ -4186,6 +4219,8 @@ void TParseContext::declareBlock(TSourceLoc loc, TTypeList& typeList, const TStr
|
|||
error(memberLoc, "member of uniform or buffer block cannot have an auxiliary or interpolation qualifier", memberType.getFieldName().c_str(), "");
|
||||
if (memberType.isRuntimeSizedArray() && member < typeList.size() - 1)
|
||||
error(memberLoc, "only the last member of a buffer block can be run-time sized", memberType.getFieldName().c_str(), "");
|
||||
if (memberType.isImplicitlySizedArray())
|
||||
requireProfile(memberLoc, ~EEsProfile, "implicitly-sized array in a block");
|
||||
|
||||
TBasicType basicType = memberType.getBasicType();
|
||||
if (basicType == EbtSampler)
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ public:
|
|||
void arraySizeCheck(TSourceLoc, TIntermTyped* expr, int& size);
|
||||
bool arrayQualifierError(TSourceLoc, const TQualifier&);
|
||||
void arraySizeRequiredCheck(TSourceLoc, int size);
|
||||
void structArrayCheck(TSourceLoc, TType* structure);
|
||||
void arrayDimError(TSourceLoc);
|
||||
void arrayDimCheck(TSourceLoc, TArraySizes* sizes1, TArraySizes* sizes2);
|
||||
void arrayDimCheck(TSourceLoc, const TType*, TArraySizes*);
|
||||
|
|
|
|||
|
|
@ -668,18 +668,25 @@ int TScanContext::tokenizeIdentifier()
|
|||
return keyword;
|
||||
|
||||
case BUFFER:
|
||||
if (parseContext.version < 430)
|
||||
if ((parseContext.profile == EEsProfile && parseContext.version < 310) ||
|
||||
(parseContext.profile != EEsProfile && parseContext.version < 430))
|
||||
return identifierOrType();
|
||||
return keyword;
|
||||
|
||||
case ATOMIC_UINT:
|
||||
return es30ReservedFromGLSL(420);
|
||||
if (parseContext.profile == EEsProfile && parseContext.version >= 310)
|
||||
return keyword;
|
||||
else
|
||||
return es30ReservedFromGLSL(420);
|
||||
|
||||
case COHERENT:
|
||||
case RESTRICT:
|
||||
case READONLY:
|
||||
case WRITEONLY:
|
||||
return es30ReservedFromGLSL(parseContext.extensionsTurnedOn(1, &GL_ARB_shader_image_load_store) ? 130 : 420);
|
||||
if (parseContext.profile == EEsProfile && parseContext.version >= 310)
|
||||
return keyword;
|
||||
else
|
||||
return es30ReservedFromGLSL(parseContext.extensionsTurnedOn(1, &GL_ARB_shader_image_load_store) ? 130 : 420);
|
||||
|
||||
case VOLATILE:
|
||||
if (! parseContext.symbolTable.atBuiltInLevel() && (parseContext.profile == EEsProfile || (parseContext.version < 420 && ! parseContext.extensionsTurnedOn(1, &GL_ARB_shader_image_load_store))))
|
||||
|
|
@ -743,28 +750,30 @@ int TScanContext::tokenizeIdentifier()
|
|||
case IMAGE1D:
|
||||
case IIMAGE1D:
|
||||
case UIMAGE1D:
|
||||
case IMAGE1DARRAY:
|
||||
case IIMAGE1DARRAY:
|
||||
case UIMAGE1DARRAY:
|
||||
case IMAGE2DRECT:
|
||||
case IIMAGE2DRECT:
|
||||
case UIMAGE2DRECT:
|
||||
case IMAGEBUFFER:
|
||||
case IIMAGEBUFFER:
|
||||
case UIMAGEBUFFER:
|
||||
return firstGenerationImage(false);
|
||||
|
||||
case IMAGE2D:
|
||||
case IIMAGE2D:
|
||||
case UIMAGE2D:
|
||||
case IMAGE3D:
|
||||
case IIMAGE3D:
|
||||
case UIMAGE3D:
|
||||
case IMAGE2DRECT:
|
||||
case IIMAGE2DRECT:
|
||||
case UIMAGE2DRECT:
|
||||
case IMAGECUBE:
|
||||
case IIMAGECUBE:
|
||||
case UIMAGECUBE:
|
||||
case IMAGEBUFFER:
|
||||
case IIMAGEBUFFER:
|
||||
case UIMAGEBUFFER:
|
||||
case IMAGE1DARRAY:
|
||||
case IIMAGE1DARRAY:
|
||||
case UIMAGE1DARRAY:
|
||||
case IMAGE2DARRAY:
|
||||
case IIMAGE2DARRAY:
|
||||
case UIMAGE2DARRAY:
|
||||
return firstGenerationImage();
|
||||
return firstGenerationImage(true);
|
||||
|
||||
case IMAGECUBEARRAY:
|
||||
case IIMAGECUBEARRAY:
|
||||
|
|
@ -1068,11 +1077,13 @@ int TScanContext::dMat()
|
|||
return identifierOrType();
|
||||
}
|
||||
|
||||
int TScanContext::firstGenerationImage()
|
||||
int TScanContext::firstGenerationImage(bool inEs310)
|
||||
{
|
||||
afterType = true;
|
||||
|
||||
if (parseContext.symbolTable.atBuiltInLevel() || (parseContext.profile != EEsProfile && (parseContext.version >= 420 || parseContext.extensionsTurnedOn(1, &GL_ARB_shader_image_load_store))))
|
||||
if (parseContext.symbolTable.atBuiltInLevel() ||
|
||||
(parseContext.profile != EEsProfile && (parseContext.version >= 420 || parseContext.extensionsTurnedOn(1, &GL_ARB_shader_image_load_store))) ||
|
||||
(inEs310 && parseContext.profile == EEsProfile && parseContext.version >= 310))
|
||||
return keyword;
|
||||
|
||||
if ((parseContext.profile == EEsProfile && parseContext.version >= 300) ||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ protected:
|
|||
int precisionKeyword();
|
||||
int matNxM();
|
||||
int dMat();
|
||||
int firstGenerationImage();
|
||||
int firstGenerationImage(bool inEs310);
|
||||
int secondGenerationImage();
|
||||
|
||||
TParseContext& parseContext;
|
||||
|
|
|
|||
|
|
@ -78,11 +78,13 @@ int MapVersionToIndex(int version)
|
|||
case 420: return 10;
|
||||
case 430: return 11;
|
||||
case 440: return 12;
|
||||
case 310: return 13;
|
||||
case 450: return 14;
|
||||
default: // |
|
||||
return 0; // |
|
||||
} // |
|
||||
} // V
|
||||
const int VersionCount = 13; // number of case statements above
|
||||
const int VersionCount = 15; // number of case statements above
|
||||
|
||||
int MapProfileToIndex(EProfile profile)
|
||||
{
|
||||
|
|
@ -197,7 +199,8 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
|
|||
}
|
||||
if (profile != EEsProfile && version >= 150)
|
||||
InitializeStageSymbolTable(builtIns, version, profile, EShLangGeometry, infoSink, commonTable, symbolTables);
|
||||
if (profile != EEsProfile && version >= 430)
|
||||
if ((profile != EEsProfile && version >= 430) ||
|
||||
(profile == EEsProfile && version >= 310))
|
||||
InitializeStageSymbolTable(builtIns, version, profile, EShLangCompute, infoSink, commonTable, symbolTables);
|
||||
|
||||
return true;
|
||||
|
|
@ -303,9 +306,9 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
|
|||
|
||||
// Get a good profile...
|
||||
if (profile == ENoProfile) {
|
||||
if (version == 300) {
|
||||
if (version == 300 || version == 310) {
|
||||
correct = false;
|
||||
infoSink.info.message(EPrefixError, "#version: version 300 requires specifying the 'es' profile");
|
||||
infoSink.info.message(EPrefixError, "#version: versions 300 and 310 require specifying the 'es' profile");
|
||||
profile = EEsProfile;
|
||||
} else if (version == 100)
|
||||
profile = EEsProfile;
|
||||
|
|
@ -322,16 +325,16 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
|
|||
profile = EEsProfile;
|
||||
else
|
||||
profile = ENoProfile;
|
||||
} else if (version == 300) {
|
||||
} else if (version == 300 || version == 310) {
|
||||
if (profile != EEsProfile) {
|
||||
correct = false;
|
||||
infoSink.info.message(EPrefixError, "#version: version 300 supports only the es profile");
|
||||
infoSink.info.message(EPrefixError, "#version: versions 300 and 310 support only the es profile");
|
||||
}
|
||||
profile = EEsProfile;
|
||||
} else {
|
||||
if (profile == EEsProfile) {
|
||||
correct = false;
|
||||
infoSink.info.message(EPrefixError, "#version: only version 300 supports the es profile");
|
||||
infoSink.info.message(EPrefixError, "#version: only version 300 and 310 support the es profile");
|
||||
if (version >= FirstProfileVersion)
|
||||
profile = ECoreProfile;
|
||||
else
|
||||
|
|
@ -361,10 +364,11 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
|
|||
}
|
||||
break;
|
||||
case EShLangCompute:
|
||||
if (version < 430 || (profile != ECoreProfile && profile != ECompatibilityProfile)) {
|
||||
if ((profile == EEsProfile && version < 310) ||
|
||||
(profile != EEsProfile && version < 430)) {
|
||||
correct = false;
|
||||
infoSink.info.message(EPrefixError, "#version: compute shaders require non-es profile and version 430 or above");
|
||||
version = 430;
|
||||
infoSink.info.message(EPrefixError, "#version: compute shaders require es profile with version 310 or above, or non-es profile with version 430 or above");
|
||||
version = profile == EEsProfile ? 310 : 430;
|
||||
profile = ECoreProfile;
|
||||
}
|
||||
break;
|
||||
|
|
@ -395,9 +399,21 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
|
|||
// versions are complete
|
||||
break;
|
||||
|
||||
default:
|
||||
case 310:
|
||||
case 330:
|
||||
case 400:
|
||||
case 410:
|
||||
case 420:
|
||||
case 430:
|
||||
case 440:
|
||||
case 450:
|
||||
infoSink.info << "Warning, version " << version << " is not yet complete; most version-specific features are present, but some are missing.\n";
|
||||
break;
|
||||
|
||||
default:
|
||||
infoSink.info << "Warning, version " << version << " is unknown.\n";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return correct;
|
||||
|
|
|
|||
|
|
@ -1216,8 +1216,8 @@ storage_qualifier
|
|||
$$.qualifier.storage = EvqBuffer;
|
||||
}
|
||||
| SHARED {
|
||||
parseContext.requireProfile($1.loc, ~EEsProfile, "shared");
|
||||
parseContext.profileRequires($1.loc, ECoreProfile, 430, 0, "shared");
|
||||
parseContext.profileRequires($1.loc, ECoreProfile | ECompatibilityProfile, 430, 0, "shared");
|
||||
parseContext.profileRequires($1.loc, EEsProfile, 310, 0, "shared");
|
||||
parseContext.requireStage($1.loc, EShLangCompute, "shared");
|
||||
$$.init($1.loc);
|
||||
$$.qualifier.storage = EvqShared;
|
||||
|
|
@ -1964,6 +1964,7 @@ precision_qualifier
|
|||
struct_specifier
|
||||
: STRUCT IDENTIFIER LEFT_BRACE { parseContext.nestedStructCheck($1.loc); } struct_declaration_list RIGHT_BRACE {
|
||||
TType* structure = new TType($5, *$2.string);
|
||||
parseContext.structArrayCheck($2.loc, structure);
|
||||
TVariable* userTypeDef = new TVariable($2.string, *structure, true);
|
||||
if (! parseContext.symbolTable.insert(*userTypeDef))
|
||||
parseContext.error($2.loc, "redefinition", $2.string->c_str(), "struct");
|
||||
|
|
@ -2055,8 +2056,6 @@ struct_declarator
|
|||
$$.type->setFieldName(*$1.string);
|
||||
}
|
||||
| IDENTIFIER array_specifier {
|
||||
if (parseContext.profile == EEsProfile)
|
||||
parseContext.arraySizeRequiredCheck($2.loc, $2.arraySizes->getSize());
|
||||
parseContext.arrayDimCheck($1.loc, $2.arraySizes, 0);
|
||||
|
||||
$$.type = new TType(EbtVoid);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue