Add support for extension GL_ARB_shader_storage_buffer_object (#2184)
Enable below features for GL Core version 420: * layout qualifier "std430" * storage qualifier "buffer" * atomic memory functions
This commit is contained in:
parent
02c70ad10e
commit
7d65f09b83
@ -17,3 +17,26 @@ uniform writeonly image2D i2D;
|
||||
ivec2 iv2dim = imageSize(i2D); // ERROR: imageSize called without enabling GL_ARB_shader_image_size extension
|
||||
#extension GL_ARB_shader_image_size : enable
|
||||
ivec2 iv2dim1 = imageSize(i2D);
|
||||
|
||||
#extension GL_ARB_shader_storage_buffer_object : enable
|
||||
|
||||
layout(binding = 0,std430) buffer Buffer
|
||||
{
|
||||
int atomi;
|
||||
uint atomu;
|
||||
};
|
||||
|
||||
void atomicOpPass()
|
||||
{
|
||||
int origi = atomicAdd(atomi, 3);
|
||||
uint origu = atomicAnd(atomu, 7u);
|
||||
origi = atomicExchange(atomi, 4);
|
||||
origu = atomicCompSwap(atomu, 10u, 8u);
|
||||
}
|
||||
|
||||
#extension GL_ARB_shader_storage_buffer_object : disable
|
||||
|
||||
layout(binding = 1,std430) buffer BufferFail // Error std430 and "buffer" block support disabled
|
||||
{
|
||||
int atom1i;
|
||||
};
|
||||
|
@ -4,11 +4,14 @@ ERROR: 0:11: 'layout qualifier' : can only apply depth layout to gl_FragDepth
|
||||
ERROR: 0:12: 'gl_FragDepth' : cannot redeclare after use
|
||||
ERROR: 0:14: 'atomic_uint' : array must be explicitly sized
|
||||
ERROR: 0:17: 'imageSize' : required extension not requested: GL_ARB_shader_image_size
|
||||
ERROR: 5 compilation errors. No code generated.
|
||||
ERROR: 0:39: 'std430' : not supported for this version or the enabled extensions
|
||||
ERROR: 0:39: '' : syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON
|
||||
ERROR: 7 compilation errors. No code generated.
|
||||
|
||||
|
||||
Shader version: 420
|
||||
Requested GL_ARB_shader_image_size
|
||||
Requested GL_ARB_shader_storage_buffer_object
|
||||
using depth_any
|
||||
ERROR: node is still EOpNull!
|
||||
0:6 Function Definition: main( ( global void)
|
||||
@ -28,6 +31,49 @@ ERROR: node is still EOpNull!
|
||||
0:19 'iv2dim1' ( global 2-component vector of int)
|
||||
0:19 imageQuerySize ( global 2-component vector of int)
|
||||
0:19 'i2D' ( writeonly uniform image2D)
|
||||
0:29 Function Definition: atomicOpPass( ( global void)
|
||||
0:29 Function Parameters:
|
||||
0:31 Sequence
|
||||
0:31 Sequence
|
||||
0:31 move second child to first child ( temp int)
|
||||
0:31 'origi' ( temp int)
|
||||
0:31 AtomicAdd ( global int)
|
||||
0:31 atomi: direct index for structure (layout( column_major std430 offset=0) buffer int)
|
||||
0:31 'anon@0' (layout( binding=0 column_major std430) buffer block{layout( column_major std430 offset=0) buffer int atomi, layout( column_major std430 offset=4) buffer uint atomu})
|
||||
0:31 Constant:
|
||||
0:31 0 (const uint)
|
||||
0:31 Constant:
|
||||
0:31 3 (const int)
|
||||
0:32 Sequence
|
||||
0:32 move second child to first child ( temp uint)
|
||||
0:32 'origu' ( temp uint)
|
||||
0:32 AtomicAnd ( global uint)
|
||||
0:32 atomu: direct index for structure (layout( column_major std430 offset=4) buffer uint)
|
||||
0:32 'anon@0' (layout( binding=0 column_major std430) buffer block{layout( column_major std430 offset=0) buffer int atomi, layout( column_major std430 offset=4) buffer uint atomu})
|
||||
0:32 Constant:
|
||||
0:32 1 (const uint)
|
||||
0:32 Constant:
|
||||
0:32 7 (const uint)
|
||||
0:33 move second child to first child ( temp int)
|
||||
0:33 'origi' ( temp int)
|
||||
0:33 AtomicExchange ( global int)
|
||||
0:33 atomi: direct index for structure (layout( column_major std430 offset=0) buffer int)
|
||||
0:33 'anon@0' (layout( binding=0 column_major std430) buffer block{layout( column_major std430 offset=0) buffer int atomi, layout( column_major std430 offset=4) buffer uint atomu})
|
||||
0:33 Constant:
|
||||
0:33 0 (const uint)
|
||||
0:33 Constant:
|
||||
0:33 4 (const int)
|
||||
0:34 move second child to first child ( temp uint)
|
||||
0:34 'origu' ( temp uint)
|
||||
0:34 AtomicCompSwap ( global uint)
|
||||
0:34 atomu: direct index for structure (layout( column_major std430 offset=4) buffer uint)
|
||||
0:34 'anon@0' (layout( binding=0 column_major std430) buffer block{layout( column_major std430 offset=0) buffer int atomi, layout( column_major std430 offset=4) buffer uint atomu})
|
||||
0:34 Constant:
|
||||
0:34 1 (const uint)
|
||||
0:34 Constant:
|
||||
0:34 10 (const uint)
|
||||
0:34 Constant:
|
||||
0:34 8 (const uint)
|
||||
0:? Linker Objects
|
||||
0:? 'gl_FragDepth' ( gl_FragDepth float FragDepth)
|
||||
0:? 'depth' ( smooth in float)
|
||||
@ -35,6 +81,7 @@ ERROR: node is still EOpNull!
|
||||
0:? 'i2D' ( writeonly uniform image2D)
|
||||
0:? 'iv2dim' ( global 2-component vector of int)
|
||||
0:? 'iv2dim1' ( global 2-component vector of int)
|
||||
0:? 'anon@0' (layout( binding=0 column_major std430) buffer block{layout( column_major std430 offset=0) buffer int atomi, layout( column_major std430 offset=4) buffer uint atomu})
|
||||
|
||||
|
||||
Linked fragment stage:
|
||||
@ -42,6 +89,7 @@ Linked fragment stage:
|
||||
|
||||
Shader version: 420
|
||||
Requested GL_ARB_shader_image_size
|
||||
Requested GL_ARB_shader_storage_buffer_object
|
||||
using depth_any
|
||||
ERROR: node is still EOpNull!
|
||||
0:6 Function Definition: main( ( global void)
|
||||
@ -68,4 +116,5 @@ ERROR: node is still EOpNull!
|
||||
0:? 'i2D' ( writeonly uniform image2D)
|
||||
0:? 'iv2dim' ( global 2-component vector of int)
|
||||
0:? 'iv2dim1' ( global 2-component vector of int)
|
||||
0:? 'anon@0' (layout( binding=0 column_major std430) buffer block{layout( column_major std430 offset=0) buffer int atomi, layout( column_major std430 offset=4) buffer uint atomu})
|
||||
|
||||
|
@ -153,6 +153,11 @@ EProfile EDesktopProfile = static_cast<EProfile>(ENoProfile | ECoreProfile | ECo
|
||||
{ EBadProfile } };
|
||||
const Versioning* Es300Desktop130 = &Es300Desktop130Version[0];
|
||||
|
||||
const Versioning Es310Desktop420Version[] = { { EEsProfile, 0, 310, 0, nullptr },
|
||||
{ EDesktopProfile, 0, 420, 0, nullptr },
|
||||
{ EBadProfile } };
|
||||
const Versioning* Es310Desktop420 = &Es310Desktop420Version[0];
|
||||
|
||||
const Versioning Es310Desktop430Version[] = { { EEsProfile, 0, 310, 0, nullptr },
|
||||
{ EDesktopProfile, 0, 430, 0, nullptr },
|
||||
{ EBadProfile } };
|
||||
@ -256,14 +261,14 @@ const BuiltInFunction BaseFunctions[] = {
|
||||
{ EOpGreaterThanEqual, "greaterThanEqual", 2, TypeU, ClassBNS, Es300Desktop130 },
|
||||
{ EOpVectorEqual, "equal", 2, TypeU, ClassBNS, Es300Desktop130 },
|
||||
{ EOpVectorNotEqual, "notEqual", 2, TypeU, ClassBNS, Es300Desktop130 },
|
||||
{ EOpAtomicAdd, "atomicAdd", 2, TypeIU, ClassV1FIOCV, Es310Desktop430 },
|
||||
{ EOpAtomicMin, "atomicMin", 2, TypeIU, ClassV1FIOCV, Es310Desktop430 },
|
||||
{ EOpAtomicMax, "atomicMax", 2, TypeIU, ClassV1FIOCV, Es310Desktop430 },
|
||||
{ EOpAtomicAnd, "atomicAnd", 2, TypeIU, ClassV1FIOCV, Es310Desktop430 },
|
||||
{ EOpAtomicOr, "atomicOr", 2, TypeIU, ClassV1FIOCV, Es310Desktop430 },
|
||||
{ EOpAtomicXor, "atomicXor", 2, TypeIU, ClassV1FIOCV, Es310Desktop430 },
|
||||
{ EOpAtomicExchange, "atomicExchange", 2, TypeIU, ClassV1FIOCV, Es310Desktop430 },
|
||||
{ EOpAtomicCompSwap, "atomicCompSwap", 3, TypeIU, ClassV1FIOCV, Es310Desktop430 },
|
||||
{ EOpAtomicAdd, "atomicAdd", 2, TypeIU, ClassV1FIOCV, Es310Desktop420 },
|
||||
{ EOpAtomicMin, "atomicMin", 2, TypeIU, ClassV1FIOCV, Es310Desktop420 },
|
||||
{ EOpAtomicMax, "atomicMax", 2, TypeIU, ClassV1FIOCV, Es310Desktop420 },
|
||||
{ EOpAtomicAnd, "atomicAnd", 2, TypeIU, ClassV1FIOCV, Es310Desktop420 },
|
||||
{ EOpAtomicOr, "atomicOr", 2, TypeIU, ClassV1FIOCV, Es310Desktop420 },
|
||||
{ EOpAtomicXor, "atomicXor", 2, TypeIU, ClassV1FIOCV, Es310Desktop420 },
|
||||
{ EOpAtomicExchange, "atomicExchange", 2, TypeIU, ClassV1FIOCV, Es310Desktop420 },
|
||||
{ EOpAtomicCompSwap, "atomicCompSwap", 3, TypeIU, ClassV1FIOCV, Es310Desktop420 },
|
||||
#ifndef GLSLANG_WEB
|
||||
{ EOpMix, "mix", 3, TypeB, ClassRegular, Es310Desktop450 },
|
||||
{ EOpMix, "mix", 3, TypeIU, ClassLB, Es310Desktop450 },
|
||||
@ -7827,6 +7832,18 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
symbolTable.setFunctionExtensions("imageSize", 1, &E_GL_ARB_shader_image_size);
|
||||
}
|
||||
|
||||
// GL_ARB_shader_storage_buffer_object
|
||||
if (profile != EEsProfile && version < 430 ) {
|
||||
symbolTable.setFunctionExtensions("atomicAdd", 1, &E_GL_ARB_shader_storage_buffer_object);
|
||||
symbolTable.setFunctionExtensions("atomicMin", 1, &E_GL_ARB_shader_storage_buffer_object);
|
||||
symbolTable.setFunctionExtensions("atomicMax", 1, &E_GL_ARB_shader_storage_buffer_object);
|
||||
symbolTable.setFunctionExtensions("atomicAnd", 1, &E_GL_ARB_shader_storage_buffer_object);
|
||||
symbolTable.setFunctionExtensions("atomicOr", 1, &E_GL_ARB_shader_storage_buffer_object);
|
||||
symbolTable.setFunctionExtensions("atomicXor", 1, &E_GL_ARB_shader_storage_buffer_object);
|
||||
symbolTable.setFunctionExtensions("atomicExchange", 1, &E_GL_ARB_shader_storage_buffer_object);
|
||||
symbolTable.setFunctionExtensions("atomicCompSwap", 1, &E_GL_ARB_shader_storage_buffer_object);
|
||||
}
|
||||
|
||||
symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
|
||||
BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
|
||||
symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview);
|
||||
|
@ -4899,7 +4899,7 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
|
||||
#ifndef GLSLANG_WEB
|
||||
if (id == TQualifier::getLayoutPackingString(ElpStd430)) {
|
||||
requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, "std430");
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, nullptr, "std430");
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, E_GL_ARB_shader_storage_buffer_object, "std430");
|
||||
profileRequires(loc, EEsProfile, 310, nullptr, "std430");
|
||||
publicType.qualifier.layoutPacking = ElpStd430;
|
||||
return;
|
||||
@ -7669,7 +7669,7 @@ void TParseContext::blockStageIoCheck(const TSourceLoc& loc, const TQualifier& q
|
||||
break;
|
||||
case EvqBuffer:
|
||||
requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, "buffer block");
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, nullptr, "buffer block");
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, E_GL_ARB_shader_storage_buffer_object, "buffer block");
|
||||
profileRequires(loc, EEsProfile, 310, nullptr, "buffer block");
|
||||
break;
|
||||
case EvqVaryingIn:
|
||||
|
@ -917,7 +917,8 @@ int TScanContext::tokenizeIdentifier()
|
||||
case BUFFER:
|
||||
afterBuffer = true;
|
||||
if ((parseContext.isEsProfile() && parseContext.version < 310) ||
|
||||
(!parseContext.isEsProfile() && parseContext.version < 430))
|
||||
(!parseContext.isEsProfile() && (parseContext.version < 430 &&
|
||||
!parseContext.extensionTurnedOn(E_GL_ARB_shader_storage_buffer_object))))
|
||||
return identifierOrType();
|
||||
return keyword;
|
||||
|
||||
|
@ -199,6 +199,7 @@ void TParseVersions::initializeExtensionBehavior()
|
||||
extensionBehavior[E_GL_ARB_sample_shading] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_shader_bit_encoding] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_shader_image_size] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_shader_storage_buffer_object] = EBhDisable;
|
||||
|
||||
extensionBehavior[E_GL_KHR_shader_subgroup_basic] = EBhDisable;
|
||||
extensionBehavior[E_GL_KHR_shader_subgroup_vote] = EBhDisable;
|
||||
@ -413,6 +414,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
||||
"#define GL_ARB_fragment_shader_interlock 1\n"
|
||||
"#define GL_ARB_uniform_buffer_object 1\n"
|
||||
"#define GL_ARB_shader_bit_encoding 1\n"
|
||||
"#define GL_ARB_shader_storage_buffer_object 1\n"
|
||||
"#define GL_EXT_shader_non_constant_global_initializers 1\n"
|
||||
"#define GL_EXT_shader_image_load_formatted 1\n"
|
||||
"#define GL_EXT_post_depth_coverage 1\n"
|
||||
|
@ -154,6 +154,7 @@ const char* const E_GL_ARB_uniform_buffer_object = "GL_ARB_uniform_buffer
|
||||
const char* const E_GL_ARB_sample_shading = "GL_ARB_sample_shading";
|
||||
const char* const E_GL_ARB_shader_bit_encoding = "GL_ARB_shader_bit_encoding";
|
||||
const char* const E_GL_ARB_shader_image_size = "GL_ARB_shader_image_size";
|
||||
const char* const E_GL_ARB_shader_storage_buffer_object = "GL_ARB_shader_storage_buffer_object";
|
||||
|
||||
const char* const E_GL_KHR_shader_subgroup_basic = "GL_KHR_shader_subgroup_basic";
|
||||
const char* const E_GL_KHR_shader_subgroup_vote = "GL_KHR_shader_subgroup_vote";
|
||||
|
Loading…
x
Reference in New Issue
Block a user