summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-type-layout.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-01-10 10:57:04 -0800
committerGitHub <noreply@github.com>2025-01-10 10:57:04 -0800
commit5290c580632cfb56847b863a32dc020a21d1c93e (patch)
tree4c543f28d13f62a1dc3293b76151dda7585743ab /source/slang/slang-type-layout.cpp
parent4cfae806a6f9c0203ce44c4ce04df5ad66cdc8a2 (diff)
Initial implementation of SP#015 `DescriptorHandle<T>`. (#6028)
* Initial implementation of `ResourcePtr<T>`. * Update docs * Fix build error. * Add more discussion. * Update documentation. * Update TOC. * Fix. * Fix. * Add test case for custom `getResourceFromBindlessHandle`. * Add namehint to generated descriptor heap param. * Fix. * Fix. * format code * Rename to `DescriptorHandle`, and add `T.Handle` alias. * Fix compiler error. * Fix. * Fix build. * Renames. * Fix documentation. * Documentation fix. --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-type-layout.cpp')
-rw-r--r--source/slang/slang-type-layout.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp
index 98a324d96..d7b303535 100644
--- a/source/slang/slang-type-layout.cpp
+++ b/source/slang/slang-type-layout.cpp
@@ -2523,7 +2523,7 @@ SourceLanguage getIntermediateSourceLanguageForTarget(TargetProgram* targetProgr
bool areResourceTypesBindlessOnTarget(TargetRequest* targetReq)
{
- return isCPUTarget(targetReq) || isCUDATarget(targetReq);
+ return isCPUTarget(targetReq) || isCUDATarget(targetReq) || isMetalTarget(targetReq);
}
static bool isD3D11Target(TargetRequest*)
@@ -4802,6 +4802,15 @@ static TypeLayoutResult _createTypeLayout(TypeLayoutContext& context, Type* type
type,
rules);
}
+ else if (auto resPtrType = as<DescriptorHandleType>(type))
+ {
+ if (areResourceTypesBindlessOnTarget(context.targetReq))
+ return _createTypeLayout(context, resPtrType->getElementType());
+ auto uint2Type = context.astBuilder->getVectorType(
+ context.astBuilder->getUIntType(),
+ context.astBuilder->getIntVal(context.astBuilder->getIntType(), 2));
+ return _createTypeLayout(context, uint2Type);
+ }
else if (auto optionalType = as<OptionalType>(type))
{
// OptionalType should be laid out the same way as Tuple<T, bool>.