diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2023-12-15 23:41:27 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-15 23:41:27 +0800 |
| commit | 21d17abb0e511806b7c93effc58f37169d837766 (patch) | |
| tree | a39b8bc015d5f0a5e6fd12b6a31a92f162aaad44 /source/slang/slang-check-modifier.cpp | |
| parent | 34f04a4670f86e64d4b35ce720281a6f0e72f733 (diff) | |
GLSL SSBO Support (#3400)
* Squash warnings and fix build with SLANG_EMBED_STDLIB
* Add GLSLShaderStorageBuffer magic wrapper
* Make GLSLSSBO not a uniform type
* Buffers are global variables
* Allow creating ssbo aggregate types
* Allow reading from RWSB using builder
* Nicer debug printing for ssbos
* Lower SSBO to RWSB
* Parse interface blocks into wrapped structs
* Lower Interface Block Decls to structs
* remove comment
* Two simple ssbo tests
* Move ssbo pass earlier
* Correct mutable buffer detection
* Do not replace ssbo usages outside of blocks
* Treat GLSLSSBO as a mutable buffer for type layouts
* regenerate vs projects
* Correctly detect ssbo types
* Diagnose illegal ssbo
* remove unreachable code
* neaten
* ci wobble
* Make GLSLSSBO ast handling more uniform
* Add modifier cases for glsl
* Use empty val info for unhandled interface blocks
necessary for ./tests/glsl/out-binding-redeclaration.slang
* more sophisticated modifier check
* Correct ssbo wrapper name
Diffstat (limited to 'source/slang/slang-check-modifier.cpp')
| -rw-r--r-- | source/slang/slang-check-modifier.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/source/slang/slang-check-modifier.cpp b/source/slang/slang-check-modifier.cpp index a9a8c19da..c9800b325 100644 --- a/source/slang/slang-check-modifier.cpp +++ b/source/slang/slang-check-modifier.cpp @@ -999,16 +999,15 @@ namespace Slang } } - bool isModifierAllowedOnDecl(ASTNodeType modifierType, Decl* decl) + bool isModifierAllowedOnDecl(bool isGLSLInput, ASTNodeType modifierType, Decl* decl) { switch (modifierType) { - // Allowed only on parameters and global variables. + // In addition to the above cases, these are also present on empty + // global declarations, for instance + // layout(local_size_x=1) in; case ASTNodeType::InModifier: - case ASTNodeType::OutModifier: case ASTNodeType::InOutModifier: - case ASTNodeType::RefModifier: - case ASTNodeType::ConstRefModifier: case ASTNodeType::GLSLLayoutModifier: case ASTNodeType::GLSLParsedLayoutModifier: case ASTNodeType::GLSLConstantIDLayoutModifier: @@ -1017,6 +1016,16 @@ namespace Slang case ASTNodeType::GLSLLayoutModifierGroupMarker: case ASTNodeType::GLSLLayoutModifierGroupBegin: case ASTNodeType::GLSLLayoutModifierGroupEnd: + // If we are in GLSL mode, also allow these but otherwise fall to + // the regular check + if(isGLSLInput && as<EmptyDecl>(decl) && isGlobalDecl(decl)) + return true; + [[fallthrough]]; + + // Allowed only on parameters and global variables. + case ASTNodeType::OutModifier: + case ASTNodeType::RefModifier: + case ASTNodeType::ConstRefModifier: case ASTNodeType::GLSLBufferModifier: case ASTNodeType::GLSLWriteOnlyModifier: case ASTNodeType::GLSLReadOnlyModifier: @@ -1114,7 +1123,7 @@ namespace Slang if (auto decl = as<Decl>(syntaxNode)) { - if (!isModifierAllowedOnDecl(m->astNodeType, decl)) + if (!isModifierAllowedOnDecl(getLinkage()->getAllowGLSLInput(), m->astNodeType, decl)) { getSink()->diagnose(m, Diagnostics::modifierNotAllowed, m); return m; |
