From 21d17abb0e511806b7c93effc58f37169d837766 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Fri, 15 Dec 2023 23:41:27 +0800 Subject: 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 --- source/slang/slang-check-modifier.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'source/slang/slang-check-modifier.cpp') 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(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(syntaxNode)) { - if (!isModifierAllowedOnDecl(m->astNodeType, decl)) + if (!isModifierAllowedOnDecl(getLinkage()->getAllowGLSLInput(), m->astNodeType, decl)) { getSink()->diagnose(m, Diagnostics::modifierNotAllowed, m); return m; -- cgit v1.2.3