Implement the extension GL_ARB_shader_ballot
Add new built-in variables and functions to the parser (SPIR-V tokens are missing).
This commit is contained in:
parent
97f4e0fe19
commit
574ab04caa
11 changed files with 537 additions and 6 deletions
|
|
@ -1325,6 +1325,44 @@ void TBuiltIns::initialize(int version, EProfile profile, int spv, int vulkan)
|
|||
"\n");
|
||||
}
|
||||
|
||||
// GL_ARB_shader_ballot
|
||||
if (profile != EEsProfile && version >= 450) {
|
||||
commonBuiltins.append(
|
||||
"uint64_t ballotARB(bool);"
|
||||
|
||||
"float readInvocationARB(float, uint);"
|
||||
"vec2 readInvocationARB(vec2, uint);"
|
||||
"vec3 readInvocationARB(vec3, uint);"
|
||||
"vec4 readInvocationARB(vec4, uint);"
|
||||
|
||||
"int readInvocationARB(int, uint);"
|
||||
"ivec2 readInvocationARB(ivec2, uint);"
|
||||
"ivec3 readInvocationARB(ivec3, uint);"
|
||||
"ivec4 readInvocationARB(ivec4, uint);"
|
||||
|
||||
"uint readInvocationARB(uint, uint);"
|
||||
"uvec2 readInvocationARB(uvec2, uint);"
|
||||
"uvec3 readInvocationARB(uvec3, uint);"
|
||||
"uvec4 readInvocationARB(uvec4, uint);"
|
||||
|
||||
"float readFirstInvocationARB(float);"
|
||||
"vec2 readFirstInvocationARB(vec2);"
|
||||
"vec3 readFirstInvocationARB(vec3);"
|
||||
"vec4 readFirstInvocationARB(vec4);"
|
||||
|
||||
"int readFirstInvocationARB(int);"
|
||||
"ivec2 readFirstInvocationARB(ivec2);"
|
||||
"ivec3 readFirstInvocationARB(ivec3);"
|
||||
"ivec4 readFirstInvocationARB(ivec4);"
|
||||
|
||||
"uint readFirstInvocationARB(uint);"
|
||||
"uvec2 readFirstInvocationARB(uvec2);"
|
||||
"uvec3 readFirstInvocationARB(uvec3);"
|
||||
"uvec4 readFirstInvocationARB(uvec4);"
|
||||
|
||||
"\n");
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// Prototypes for built-in functions seen by vertex shaders only.
|
||||
|
|
@ -2232,6 +2270,21 @@ void TBuiltIns::initialize(int version, EProfile profile, int spv, int vulkan)
|
|||
if (version >= 130)
|
||||
add2ndGenerationSamplingImaging(version, profile, spv, vulkan);
|
||||
|
||||
// GL_ARB_shader_ballot
|
||||
if (profile != EEsProfile && version >= 450) {
|
||||
commonBuiltins.append(
|
||||
"uniform uint gl_SubGroupSizeARB;"
|
||||
|
||||
"in uint gl_SubGroupInvocationARB;"
|
||||
"in uint64_t gl_SubGroupEqMaskARB;"
|
||||
"in uint64_t gl_SubGroupGeMaskARB;"
|
||||
"in uint64_t gl_SubGroupGtMaskARB;"
|
||||
"in uint64_t gl_SubGroupLeMaskARB;"
|
||||
"in uint64_t gl_SubGroupLtMaskARB;"
|
||||
|
||||
"\n");
|
||||
}
|
||||
|
||||
//printf("%s\n", commonBuiltins.c_str());
|
||||
//printf("%s\n", stageBuiltins[EShLangFragment].c_str());
|
||||
}
|
||||
|
|
@ -3394,7 +3447,7 @@ void IdentifyBuiltIns(int version, EProfile profile, int spv, int vulkan, EShLan
|
|||
|
||||
switch(language) {
|
||||
case EShLangVertex:
|
||||
if (profile != EEsProfile && version >= 440) {
|
||||
if (profile != EEsProfile) {
|
||||
symbolTable.setVariableExtensions("gl_BaseVertexARB", 1, &E_GL_ARB_shader_draw_parameters);
|
||||
symbolTable.setVariableExtensions("gl_BaseInstanceARB", 1, &E_GL_ARB_shader_draw_parameters);
|
||||
symbolTable.setVariableExtensions("gl_DrawIDARB", 1, &E_GL_ARB_shader_draw_parameters);
|
||||
|
|
@ -3404,6 +3457,28 @@ void IdentifyBuiltIns(int version, EProfile profile, int spv, int vulkan, EShLan
|
|||
BuiltInVariable("gl_DrawIDARB", EbvDrawId, symbolTable);
|
||||
}
|
||||
|
||||
if (profile != EEsProfile) {
|
||||
symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
|
||||
symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
|
||||
symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot);
|
||||
symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot);
|
||||
symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot);
|
||||
symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot);
|
||||
symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot);
|
||||
|
||||
symbolTable.setFunctionExtensions("ballotARB", 1, &E_GL_ARB_shader_ballot);
|
||||
symbolTable.setFunctionExtensions("readInvocationARB", 1, &E_GL_ARB_shader_ballot);
|
||||
symbolTable.setFunctionExtensions("readFirstInvocationARB", 1, &E_GL_ARB_shader_ballot);
|
||||
|
||||
BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
|
||||
BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
|
||||
BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable);
|
||||
BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable);
|
||||
BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable);
|
||||
BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
|
||||
BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
|
||||
}
|
||||
|
||||
// Compatibility variables, vertex only
|
||||
if (spv == 0) {
|
||||
BuiltInVariable("gl_Color", EbvColor, symbolTable);
|
||||
|
|
@ -3963,8 +4038,7 @@ void IdentifyBuiltIns(int version, EProfile profile, int spv, int vulkan, EShLan
|
|||
symbolTable.relateToOperator("shadow2DProjLod", EOpTextureProjLod);
|
||||
}
|
||||
|
||||
if (profile != EEsProfile)
|
||||
{
|
||||
if (profile != EEsProfile) {
|
||||
symbolTable.relateToOperator("sparseTextureARB", EOpSparseTexture);
|
||||
symbolTable.relateToOperator("sparseTextureLodARB", EOpSparseTextureLod);
|
||||
symbolTable.relateToOperator("sparseTextureOffsetARB", EOpSparseTextureOffset);
|
||||
|
|
@ -3987,6 +4061,10 @@ void IdentifyBuiltIns(int version, EProfile profile, int spv, int vulkan, EShLan
|
|||
symbolTable.relateToOperator("textureOffsetClampARB", EOpTextureOffsetClamp);
|
||||
symbolTable.relateToOperator("textureGradClampARB", EOpTextureGradClamp);
|
||||
symbolTable.relateToOperator("textureGradOffsetClampARB", EOpTextureGradOffsetClamp);
|
||||
|
||||
symbolTable.relateToOperator("ballotARB", EOpBallot);
|
||||
symbolTable.relateToOperator("readInvocationARB", EOpReadInvocation);
|
||||
symbolTable.relateToOperator("readFirstInvocationARB", EOpReadFirstInvocation);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4023,8 +4101,8 @@ void IdentifyBuiltIns(int version, EProfile profile, int spv, int vulkan, EShLan
|
|||
break;
|
||||
|
||||
case EShLangCompute:
|
||||
symbolTable.relateToOperator("memoryBarrierShared", EOpMemoryBarrierShared);
|
||||
symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier);
|
||||
symbolTable.relateToOperator("memoryBarrierShared", EOpMemoryBarrierShared);
|
||||
symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ void TParseVersions::initializeExtensionBehavior()
|
|||
extensionBehavior[E_GL_ARB_viewport_array] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_gpu_shader_int64] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_gl_spirv] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_shader_ballot] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_sparse_texture2] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_sparse_texture_clamp] = EBhDisable;
|
||||
// extensionBehavior[E_GL_ARB_cull_distance] = EBhDisable; // present for 4.5, but need extension control over block members
|
||||
|
|
@ -277,6 +278,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
|||
"#define GL_ARB_viewport_array 1\n"
|
||||
"#define GL_ARB_gpu_shader_int64 1\n"
|
||||
"#define GL_ARB_gl_spirv 1\n"
|
||||
"#define GL_ARB_shader_ballot 1\n"
|
||||
"#define GL_ARB_sparse_texture2 1\n"
|
||||
"#define GL_ARB_sparse_texture_clamp 1\n"
|
||||
// "#define GL_ARB_cull_distance 1\n" // present for 4.5, but need extension control over block members
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ const char* const E_GL_ARB_shader_texture_image_samples = "GL_ARB_shader_texture
|
|||
const char* const E_GL_ARB_viewport_array = "GL_ARB_viewport_array";
|
||||
const char* const E_GL_ARB_gpu_shader_int64 = "GL_ARB_gpu_shader_int64";
|
||||
const char* const E_GL_ARB_gl_spirv = "GL_ARB_gl_spirv";
|
||||
const char* const E_GL_ARB_shader_ballot = "GL_ARB_shader_ballot";
|
||||
const char* const E_GL_ARB_sparse_texture2 = "GL_ARB_sparse_texture2";
|
||||
const char* const E_GL_ARB_sparse_texture_clamp = "GL_ARB_sparse_texture_clamp";
|
||||
//const char* const E_GL_ARB_cull_distance = "GL_ARB_cull_distance"; // present for 4.5, but need extension control over block members
|
||||
|
|
|
|||
|
|
@ -351,6 +351,9 @@ bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node)
|
|||
|
||||
case EOpNoise: out.debug << "noise"; break;
|
||||
|
||||
case EOpBallot: out.debug << "ballot"; break;
|
||||
case EOpReadFirstInvocation: out.debug << "readFirstInvocation"; break;
|
||||
|
||||
default: out.debug.message(EPrefixError, "Bad unary op");
|
||||
}
|
||||
|
||||
|
|
@ -466,6 +469,8 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
|
|||
case EOpMemoryBarrierShared: out.debug << "MemoryBarrierShared"; break;
|
||||
case EOpGroupMemoryBarrier: out.debug << "GroupMemoryBarrier"; break;
|
||||
|
||||
case EOpReadInvocation: out.debug << "readInvocation"; break;
|
||||
|
||||
case EOpAtomicAdd: out.debug << "AtomicAdd"; break;
|
||||
case EOpAtomicMin: out.debug << "AtomicMin"; break;
|
||||
case EOpAtomicMax: out.debug << "AtomicMax"; break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue