summaryrefslogtreecommitdiff
path: root/source/slang/lower-to-ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/lower-to-ir.cpp')
-rw-r--r--source/slang/lower-to-ir.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/slang/lower-to-ir.cpp b/source/slang/lower-to-ir.cpp
index bf5aeff24..18d42feab 100644
--- a/source/slang/lower-to-ir.cpp
+++ b/source/slang/lower-to-ir.cpp
@@ -3,6 +3,7 @@
#include "../../slang.h"
+#include "check.h"
#include "ir.h"
#include "ir-constexpr.h"
#include "ir-insts.h"
@@ -3828,8 +3829,41 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
return false;
}
+ LoweredValInfo lowerGlobalShaderParam(VarDeclBase* decl)
+ {
+ IRType* paramType = lowerType(context, decl->getType());
+
+ auto builder = getBuilder();
+
+ auto irParam = builder->createGlobalParam(paramType);
+ auto paramVal = LoweredValInfo::simple(irParam);
+
+ addLinkageDecoration(context, irParam, decl);
+ addNameHint(context, irParam, decl);
+ maybeSetRate(context, irParam, decl);
+ addVarDecorations(context, irParam, decl);
+
+ if (decl)
+ {
+ builder->addHighLevelDeclDecoration(irParam, decl);
+ }
+
+ // A global variable's SSA value is a *pointer* to
+ // the underlying storage.
+ setGlobalValue(context, decl, paramVal);
+
+ irParam->moveToEnd();
+
+ return paramVal;
+ }
+
LoweredValInfo lowerGlobalVarDecl(VarDeclBase* decl)
{
+ if(isGlobalShaderParameter(decl))
+ {
+ return lowerGlobalShaderParam(decl);
+ }
+
IRType* varType = lowerType(context, decl->getType());
auto builder = getBuilder();