summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-10-11 14:14:08 -0400
committerGitHub <noreply@github.com>2019-10-11 14:14:08 -0400
commit9c17d0be79834a8ebe2888aed8905bae355cb674 (patch)
treef0ebf7d256f43af686f63c6375f2a53bd12dc1a3 /source
parentdeeb8647012fc6362f1bb33842cf0842e16f13b7 (diff)
Support for unbounded array of arrays (#1078)
* WIP: Unsized arrays on CPU. * unbounded-array-of-array working on CPU. * Remove some left over comments.
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-emit-cpp.cpp10
-rw-r--r--source/slang/slang-type-layout.cpp19
2 files changed, 29 insertions, 0 deletions
diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp
index 2aea0cae9..479359d6b 100644
--- a/source/slang/slang-emit-cpp.cpp
+++ b/source/slang/slang-emit-cpp.cpp
@@ -544,6 +544,16 @@ SlangResult CPPSourceEmitter::_calcTypeName(IRType* type, CodeGenTarget target,
out << ", " << elementCount << ">";
return SLANG_OK;
}
+ case kIROp_UnsizedArrayType:
+ {
+ auto arrayType = static_cast<IRUnsizedArrayType*>(type);
+ auto elementType = arrayType->getElementType();
+
+ out << "Array<";
+ SLANG_RETURN_ON_FAIL(_calcTypeName(elementType, target, out));
+ out << ">";
+ return SLANG_OK;
+ }
default:
{
if (isNominalOp(type->op))
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp
index 9551cfe4e..ff1f2c147 100644
--- a/source/slang/slang-type-layout.cpp
+++ b/source/slang/slang-type-layout.cpp
@@ -366,6 +366,25 @@ struct CPULayoutRulesImpl : DefaultLayoutRulesImpl
}
}
+ SimpleArrayLayoutInfo GetArrayLayout( SimpleLayoutInfo elementInfo, LayoutSize elementCount) override
+ {
+ if (elementCount.isInfinite())
+ {
+ // This is an unsized array, get information for element
+ auto info = Super::GetArrayLayout(elementInfo, LayoutSize(1));
+
+ // So it is actually a Array<T> on CPU which is a pointer and a size
+ info.size = sizeof(void*) * 2;
+ info.alignment = sizeof(void*);
+
+ return info;
+ }
+ else
+ {
+ return Super::GetArrayLayout(elementInfo, elementCount);
+ }
+ }
+
UniformLayoutInfo BeginStructLayout() override
{
return Super::BeginStructLayout();