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-expr.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'source/slang/slang-check-expr.cpp') diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp index 59f7f2aa1..3aaeade74 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -299,21 +299,25 @@ namespace Slang static bool isMutableGLSLBufferBlockVarExpr(Expr* expr) { - if(const auto varExpr = as(expr)) - { - if(const auto declRefType = as(varExpr->type->getCanonicalType())) - { - if(declRefType->getDeclRef().getDecl()->isDerivedFrom(ASTNodeType::GLSLInterfaceBlockDecl)) - { - const auto d = varExpr->declRef.getDecl(); - if(d->hasModifier() && !d->hasModifier()) - { - return true; - } - } - } - } - return false; + const auto derefExpr = as(expr); + if(!derefExpr) + return false; + const auto varExpr = as(derefExpr->base); + // Check the declaration type + if(!varExpr) + return false; + + const auto varExprType = varExpr->type->getCanonicalType(); + const auto ssbt = as(varExprType); + if(!ssbt) + return false; + + // Check the modifiers on the declaration + const auto d = varExpr->declRef.getDecl(); + if(d->hasModifier()) + return false; + + return true; } DeclRefExpr* SemanticsVisitor::ConstructDeclRefExpr( -- cgit v1.2.3