diff options
| author | Yong He <yonghe@outlook.com> | 2023-07-27 16:58:32 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-27 16:58:32 -0700 |
| commit | 8bfdc39259d0a401a33d3be69b22c8dd9b576683 (patch) | |
| tree | 44fd5af8ab348aca24b5100508371d10b8b41865 /source/slang/slang-check-decl.cpp | |
| parent | 04f72443d717ca7b8304f893452c471fc6b6dc8f (diff) | |
Fix push constant on global variables. (#3034)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
| -rw-r--r-- | source/slang/slang-check-decl.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
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<NoDiffModifier>()); } } + + + if (as<NamespaceDeclBase>(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<ConstantBufferType>(varDecl->type)) + { + if (varDecl->findModifier<PushConstantAttribute>()) + { + varDecl->type.type = m_astBuilder->getConstantBufferType(varDecl->type); + } + } + } } void SemanticsDeclHeaderVisitor::visitStructDecl(StructDecl* structDecl) |
