Finish virtually all of the remaining atomic counter functionality. Still need offset collision detection.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@27712 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
3dd035b68b
commit
265f5fb80e
16 changed files with 191 additions and 37 deletions
|
|
@ -523,6 +523,7 @@ public:
|
|||
return hasMatrix() ||
|
||||
hasPacking() ||
|
||||
hasOffset() ||
|
||||
hasBinding() ||
|
||||
hasAlign();
|
||||
}
|
||||
bool hasMatrix() const
|
||||
|
|
|
|||
|
|
@ -743,7 +743,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
|
|||
//
|
||||
// Atomic counter functions.
|
||||
//
|
||||
if ((profile != EEsProfile && version >= 420) ||
|
||||
if ((profile != EEsProfile && version >= 300) ||
|
||||
(profile == EEsProfile && version >= 310)) {
|
||||
commonBuiltins.append(
|
||||
"uint atomicCounterIncrement(atomic_uint x);"
|
||||
|
|
@ -2205,24 +2205,37 @@ 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.);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounters = %d;", resources. maxVertexAtomicCounters);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentAtomicCounters = %d;", resources. maxFragmentAtomicCounters);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedAtomicCounters = %d;", resources. maxCombinedAtomicCounters);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxAtomicCounterBindings = %d;", resources. maxAtomicCounterBindings);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounterBuffers = %d;", resources. maxVertexAtomicCounterBuffers);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentAtomicCounterBuffers = %d;", resources. maxFragmentAtomicCounterBuffers);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedAtomicCounterBuffers = %d;", resources. maxCombinedAtomicCounterBuffers);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxAtomicCounterBufferSize = %d;", resources. maxAtomicCounterBufferSize);
|
||||
s.append(builtInConstant);
|
||||
}
|
||||
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.);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounters = %d;", resources. maxTessControlAtomicCounters);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounters = %d;", resources. maxTessEvaluationAtomicCounters);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounters = %d;", resources. maxGeometryAtomicCounters);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounterBuffers = %d;", resources. maxTessControlAtomicCounterBuffers);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounterBuffers = %d;", resources. maxTessEvaluationAtomicCounterBuffers);
|
||||
s.append(builtInConstant);
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounterBuffers = %d;", resources. maxGeometryAtomicCounterBuffers);
|
||||
s.append(builtInConstant);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2363,6 +2376,13 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
|
|||
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.
|
||||
|
||||
// GL_ARB_shader_atomic_counters
|
||||
if (profile != EEsProfile && version < 420) {
|
||||
symbolTable.setFunctionExtensions("atomicCounterIncrement", 1, &GL_ARB_shader_atomic_counters);
|
||||
symbolTable.setFunctionExtensions("atomicCounterDecrement", 1, &GL_ARB_shader_atomic_counters);
|
||||
symbolTable.setFunctionExtensions("atomicCounter" , 1, &GL_ARB_shader_atomic_counters);
|
||||
}
|
||||
|
||||
symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &GL_EXT_frag_depth);
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -386,6 +386,7 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
switch (node->getBasicType()) {
|
||||
case EbtVoid:
|
||||
return 0;
|
||||
case EbtAtomicUint:
|
||||
case EbtSampler:
|
||||
if (op != EOpFunctionCall)
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -3118,9 +3118,10 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
|
|||
std::transform(id.begin(), id.end(), id.begin(), ::tolower);
|
||||
|
||||
if (id == "offset") {
|
||||
const char* feature = "uniform buffer-member offset";
|
||||
const char* feature = "uniform offset";
|
||||
requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, feature);
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, GL_ARB_enhanced_layouts, feature);
|
||||
const char* exts[2] = { GL_ARB_enhanced_layouts, GL_ARB_shader_atomic_counters };
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 420, 2, exts, feature);
|
||||
profileRequires(loc, EEsProfile, 310, 0, feature);
|
||||
publicType.qualifier.layoutOffset = value;
|
||||
return;
|
||||
|
|
@ -3342,8 +3343,12 @@ void TParseContext::layoutObjectCheck(TSourceLoc loc, const TSymbol& symbol)
|
|||
if (qualifier.hasPacking())
|
||||
error(loc, "cannot specify packing on a variable declaration", "layout", "");
|
||||
// "The offset qualifier can only be used on block members of blocks..."
|
||||
if (qualifier.hasOffset())
|
||||
if (qualifier.hasOffset() && type.getBasicType() != EbtAtomicUint)
|
||||
error(loc, "cannot specify on a variable declaration", "offset", "");
|
||||
if (qualifier.hasOffset() && ! qualifier.hasBinding() && type.getBasicType() == EbtAtomicUint)
|
||||
error(loc, "a binding is required", "offset", "");
|
||||
if (qualifier.hasBinding() && qualifier.layoutBinding >= resources.maxAtomicCounterBindings && type.getBasicType() == EbtAtomicUint)
|
||||
error(loc, "cannot be greater-than-or-equal to gl_MaxAtomicCounterBindings", "binding", "");
|
||||
// "The align qualifier can only be used on blocks or block members..."
|
||||
if (qualifier.hasAlign())
|
||||
error(loc, "cannot specify on a variable declaration", "align", "");
|
||||
|
|
@ -3356,7 +3361,7 @@ void TParseContext::layoutObjectCheck(TSourceLoc loc, const TSymbol& symbol)
|
|||
}
|
||||
}
|
||||
|
||||
// Do error layout error checking with respect to a type.
|
||||
// Do layout error checking with respect to a type.
|
||||
void TParseContext::layoutTypeCheck(TSourceLoc loc, const TType& type)
|
||||
{
|
||||
const TQualifier& qualifier = type.getQualifier();
|
||||
|
|
@ -3440,10 +3445,10 @@ void TParseContext::layoutTypeCheck(TSourceLoc loc, const TType& type)
|
|||
}
|
||||
}
|
||||
|
||||
// "The offset qualifier can only be used on block members of blocks..."
|
||||
// "The offset qualifier can only be used on block members of blocks..."
|
||||
if (qualifier.hasOffset()) {
|
||||
if (type.getBasicType() == EbtBlock)
|
||||
error(loc, "only applies to block members, not blocks", "offset", "");
|
||||
error(loc, "only applies to block members, not blocks", "offset", "");
|
||||
}
|
||||
|
||||
// Image format
|
||||
|
|
@ -4221,6 +4226,10 @@ void TParseContext::declareBlock(TSourceLoc loc, TTypeList& typeList, const TStr
|
|||
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");
|
||||
if (memberQualifier.hasOffset()) {
|
||||
requireProfile(memberLoc, ~EEsProfile, "offset on block member");
|
||||
profileRequires(memberLoc, ~EEsProfile, 440, GL_ARB_enhanced_layouts, "offset on block member");
|
||||
}
|
||||
|
||||
TBasicType basicType = memberType.getBasicType();
|
||||
if (basicType == EbtSampler)
|
||||
|
|
|
|||
|
|
@ -674,7 +674,8 @@ int TScanContext::tokenizeIdentifier()
|
|||
return keyword;
|
||||
|
||||
case ATOMIC_UINT:
|
||||
if (parseContext.profile == EEsProfile && parseContext.version >= 310)
|
||||
if (parseContext.profile == EEsProfile && parseContext.version >= 310 ||
|
||||
parseContext.extensionsTurnedOn(1, &GL_ARB_shader_atomic_counters))
|
||||
return keyword;
|
||||
else
|
||||
return es30ReservedFromGLSL(420);
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ void TParseContext::initializeExtensionBehavior()
|
|||
extensionBehavior[GL_ARB_shader_texture_lod] = EBhDisable;
|
||||
extensionBehavior[GL_ARB_explicit_attrib_location] = EBhDisablePartial; // "index" for fragment outputs is missing
|
||||
extensionBehavior[GL_ARB_shader_image_load_store] = EBhDisable;
|
||||
extensionBehavior[GL_ARB_shader_atomic_counters] = EBhDisable;
|
||||
}
|
||||
|
||||
// Get code that is not part of a shared symbol table, is specific to this shader,
|
||||
|
|
@ -205,7 +206,8 @@ const char* TParseContext::getPreamble()
|
|||
"#define GL_ARB_texture_cube_map_array 1\n"
|
||||
"#define GL_ARB_shader_texture_lod 1\n"
|
||||
"#define GL_ARB_explicit_attrib_location 1\n"
|
||||
"#define GL_ARB_shader_image_load_store 1\n";
|
||||
"#define GL_ARB_shader_image_load_store 1\n"
|
||||
"#define GL_ARB_shader_atomic_counters 1\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ const char* const GL_ARB_texture_cube_map_array = "GL_ARB_texture_cube_map_arr
|
|||
const char* const GL_ARB_shader_texture_lod = "GL_ARB_shader_texture_lod";
|
||||
const char* const GL_ARB_explicit_attrib_location = "GL_ARB_explicit_attrib_location";
|
||||
const char* const GL_ARB_shader_image_load_store = "GL_ARB_shader_image_load_store";
|
||||
const char* const GL_ARB_shader_atomic_counters = "GL_ARB_shader_atomic_counters";
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue