summaryrefslogtreecommitdiff
path: root/source/slang/slang-legalize-types.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-04-24 16:23:35 -0700
committerGitHub <noreply@github.com>2024-04-24 16:23:35 -0700
commitd3ed08ec3073c3cb9ac24fa3670784dd6e97a164 (patch)
tree8589874c7dd2c1698a5dcbe22d7a2bd74fa29abf /source/slang/slang-legalize-types.cpp
parentfc4c242442510fb97c3cfbf04d7582ebbc3bb0ed (diff)
Parameter layout and reflection for Metal bindings. (#4022)
Diffstat (limited to 'source/slang/slang-legalize-types.cpp')
-rw-r--r--source/slang/slang-legalize-types.cpp41
1 files changed, 26 insertions, 15 deletions
diff --git a/source/slang/slang-legalize-types.cpp b/source/slang/slang-legalize-types.cpp
index fc0947c62..393b34e68 100644
--- a/source/slang/slang-legalize-types.cpp
+++ b/source/slang/slang-legalize-types.cpp
@@ -1156,23 +1156,34 @@ LegalType legalizeTypeImpl(
auto originalElementType = uniformBufferType->getElementType();
// Legalize the element type to see what we are working with.
- auto legalElementType = legalizeType(context,
- originalElementType);
-
- // As a bit of a corner case, if the user requested something
- // like `ConstantBuffer<Texture2D>` the element type would
- // legalize to a "simple" type, and that would be interpreted
- // as an *ordinary* type, but we really need to notice the
- // case when the element type is simple, but *special*.
- //
- if( context->isSpecialType(originalElementType) )
+ LegalType legalElementType;
+
+ if (isMetalTarget(context->targetProgram->getTargetReq()) &&
+ as<IRParameterBlockType>(uniformBufferType))
+ {
+ // On Metal, we do not need to legalize the element type of
+ // a parameter block because we can translate it directly into
+ // an argument buffer.
+ legalElementType = LegalType::simple(originalElementType);
+ }
+ else
{
- // Anything that has a special element type needs to
- // be handled by the pass-specific logic in the context.
+ legalElementType = legalizeType(context, originalElementType);
+ // As a bit of a corner case, if the user requested something
+ // like `ConstantBuffer<Texture2D>` the element type would
+ // legalize to a "simple" type, and that would be interpreted
+ // as an *ordinary* type, but we really need to notice the
+ // case when the element type is simple, but *special*.
//
- return context->createLegalUniformBufferType(
- uniformBufferType->getOp(),
- legalElementType);
+ if( context->isSpecialType(originalElementType) )
+ {
+ // Anything that has a special element type needs to
+ // be handled by the pass-specific logic in the context.
+ //
+ return context->createLegalUniformBufferType(
+ uniformBufferType->getOp(),
+ legalElementType);
+ }
}
// Note that even when legalElementType.flavor == Simple