summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorJulius Ikkala <julius.ikkala@gmail.com>2024-12-27 20:24:19 +0200
committerGitHub <noreply@github.com>2024-12-27 18:24:19 +0000
commit478be540a6f93ffcb552e496c41fe1c278ae054e (patch)
tree9887274543c973cc19e59d8a54a77676a0315621 /source/slang
parent7cecc518e753a90d9b638e8dd1140730ab010ca7 (diff)
Fix parsing GLSL SSBO arrays / bindless descriptors (#5932)
* Fix parsing GLSL SSBO arrays / bindless descriptors * Clean up SSBO array parsing * Fix mutable SSBO arrays not being detected as such * Allow sized SSBO arrays * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-check-expr.cpp9
-rw-r--r--source/slang/slang-parser.cpp10
2 files changed, 17 insertions, 2 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp
index 1f2776ba0..7972e2d81 100644
--- a/source/slang/slang-check-expr.cpp
+++ b/source/slang/slang-check-expr.cpp
@@ -312,12 +312,17 @@ static bool isMutableGLSLBufferBlockVarExpr(Expr* expr)
const auto derefExpr = as<DerefExpr>(expr);
if (!derefExpr)
return false;
- const auto varExpr = as<VarExpr>(derefExpr->base);
+
+ // For SSBO arrays, derefExpr is expected to be IndexExpr instead of VarExpr
+ const auto indexExpr = as<IndexExpr>(derefExpr->base);
+
+ const auto varExpr =
+ indexExpr ? as<VarExpr>(indexExpr->baseExpression) : as<VarExpr>(derefExpr->base);
// Check the declaration type
if (!varExpr)
return false;
- const auto varExprType = varExpr->type->getCanonicalType();
+ const auto varExprType = (indexExpr ? indexExpr->type : varExpr->type)->getCanonicalType();
const auto ssbt = as<GLSLShaderStorageBufferType>(varExprType);
if (!ssbt)
return false;
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp
index 8a4ba55eb..1aa313fa8 100644
--- a/source/slang/slang-parser.cpp
+++ b/source/slang/slang-parser.cpp
@@ -3360,6 +3360,16 @@ static Decl* ParseBufferBlockDecl(
reflectionNameModifier->nameAndLoc = bufferVarDecl->nameAndLoc;
parser->ReadToken(TokenType::Semicolon);
}
+ else if (
+ parser->options.allowGLSLInput && parser->LookAheadToken(TokenType::Identifier) &&
+ parser->LookAheadToken(TokenType::LBracket, 1))
+ {
+ // GLSL bindless buffers are denoted with [] after the name.
+ bufferVarDecl->nameAndLoc = ParseDeclName(parser);
+ bufferVarDecl->type.exp = parseBracketTypeSuffix(parser, bufferVarDecl->type.exp);
+ reflectionNameModifier->nameAndLoc = bufferVarDecl->nameAndLoc;
+ parser->ReadToken(TokenType::Semicolon);
+ }
else
{
// Otherwise, we need to generate a name for the buffer variable.