summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ast-builder.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-11-21 14:07:23 -0800
committerGitHub <noreply@github.com>2024-11-21 14:07:23 -0800
commitfdf061e278720ec066a1fac8f1f35a22e817bf2d (patch)
treedb6cc05613afacdb9c67a26695355ff1b0086d79 /source/slang/slang-ast-builder.cpp
parentdcc7c6f009afc0f55e79ced050b772ea9d3b25ae (diff)
Add datalayout for constant buffers. (#5608)
* Add datalayout for constant buffers. * Fixes. * Fix test. * Fix glsl codegen. * Update spirv-specific doc. * Fix test. * Fix binding in the presense of specialization constants. * address comments. * Add a test for constant buffer layout.
Diffstat (limited to 'source/slang/slang-ast-builder.cpp')
-rw-r--r--source/slang/slang-ast-builder.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp
index 575c7268b..6ffaee7db 100644
--- a/source/slang/slang-ast-builder.cpp
+++ b/source/slang/slang-ast-builder.cpp
@@ -146,6 +146,16 @@ Type* SharedASTBuilder::getDiffInterfaceType()
return m_diffInterfaceType;
}
+Type* SharedASTBuilder::getIBufferDataLayoutType()
+{
+ if (!m_IBufferDataLayoutType)
+ {
+ auto decl = findMagicDecl("IBufferDataLayoutType");
+ m_IBufferDataLayoutType = DeclRefType::create(m_astBuilder, makeDeclRef<Decl>(decl));
+ }
+ return m_IBufferDataLayoutType;
+}
+
Type* SharedASTBuilder::getErrorType()
{
if (!m_errorType)
@@ -296,6 +306,23 @@ PtrType* ASTBuilder::getPtrType(Type* valueType, AddressSpace addrSpace)
return dynamicCast<PtrType>(getPtrType(valueType, addrSpace, "PtrType"));
}
+Type* ASTBuilder::getDefaultLayoutType()
+{
+ return getSpecializedBuiltinType({}, "DefaultDataLayoutType");
+}
+Type* ASTBuilder::getStd140LayoutType()
+{
+ return getSpecializedBuiltinType({}, "Std140DataLayoutType");
+}
+Type* ASTBuilder::getStd430LayoutType()
+{
+ return getSpecializedBuiltinType({}, "Std430DataLayoutType");
+}
+Type* ASTBuilder::getScalarLayoutType()
+{
+ return getSpecializedBuiltinType({}, "ScalarDataLayoutType");
+}
+
// Construct the type `Out<valueType>`
OutType* ASTBuilder::getOutType(Type* valueType)
{
@@ -358,9 +385,15 @@ ArrayExpressionType* ASTBuilder::getArrayType(Type* elementType, IntVal* element
getSpecializedBuiltinType(makeArrayView(args), "ArrayExpressionType"));
}
-ConstantBufferType* ASTBuilder::getConstantBufferType(Type* elementType)
+ConstantBufferType* ASTBuilder::getConstantBufferType(
+ Type* elementType,
+ Type* layoutType,
+ Val* layoutWitness)
{
- return as<ConstantBufferType>(getSpecializedBuiltinType(elementType, "ConstantBufferType"));
+ Val* args[] = {elementType, layoutType, layoutWitness};
+
+ return as<ConstantBufferType>(
+ getSpecializedBuiltinType(makeArrayView(args), "ConstantBufferType"));
}
ParameterBlockType* ASTBuilder::getParameterBlockType(Type* elementType)