summaryrefslogtreecommitdiff
path: root/source/slang/slang-ast-builder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ast-builder.cpp')
-rw-r--r--source/slang/slang-ast-builder.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp
index 6249d7825..819fe7d25 100644
--- a/source/slang/slang-ast-builder.cpp
+++ b/source/slang/slang-ast-builder.cpp
@@ -345,6 +345,35 @@ bool ASTBuilder::isDifferentiableInterfaceAvailable()
return (m_sharedASTBuilder->tryFindMagicDecl("DifferentiableType") != nullptr);
}
+MeshOutputType* ASTBuilder::getMeshOutputTypeFromModifier(
+ HLSLMeshShaderOutputModifier* modifier,
+ Type* elementType,
+ IntVal* maxElementCount)
+{
+ SLANG_ASSERT(modifier);
+ SLANG_ASSERT(elementType);
+ SLANG_ASSERT(maxElementCount);
+
+ const char* declName
+ = as<HLSLVerticesModifier>(modifier) ? "VerticesType"
+ : as<HLSLIndicesModifier>(modifier) ? "IndicesType"
+ : as<HLSLPrimitivesModifier>(modifier) ? "PrimitivesType"
+ : (SLANG_UNEXPECTED("Unhandled mesh output modifier"), nullptr);
+ auto genericDecl = dynamicCast<GenericDecl>(m_sharedASTBuilder->findMagicDecl(declName));
+
+ auto typeDecl = genericDecl->inner;
+
+ auto substitutions = getOrCreate<GenericSubstitution>(
+ genericDecl,
+ elementType,
+ maxElementCount);
+
+ auto declRef = DeclRef<Decl>(typeDecl, substitutions);
+ auto rsType = DeclRefType::create(this, declRef);
+
+ return as<MeshOutputType>(rsType);
+}
+
DeclRef<Decl> ASTBuilder::getBuiltinDeclRef(const char* builtinMagicTypeName, Val* genericArg)
{
DeclRef<Decl> declRef;