From 8bfdc39259d0a401a33d3be69b22c8dd9b576683 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 27 Jul 2023 16:58:32 -0700 Subject: Fix push constant on global variables. (#3034) Co-authored-by: Yong He --- source/slang/slang-check-decl.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/slang/slang-check-decl.cpp') diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 2d009c28c..b1dd2d533 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -1300,6 +1300,21 @@ namespace Slang addModifier(varDecl, m_astBuilder->getOrCreate()); } } + + + if (as(varDecl->parentDecl)) + { + // If this is a global variable with [vk::push_constant] attribute, + // we need to make sure to wrap it in a `ConstantBuffer`. + + if (!as(varDecl->type)) + { + if (varDecl->findModifier()) + { + varDecl->type.type = m_astBuilder->getConstantBufferType(varDecl->type); + } + } + } } void SemanticsDeclHeaderVisitor::visitStructDecl(StructDecl* structDecl) -- cgit v1.2.3