summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-type-layout.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-09-02 12:21:28 -0700
committerGitHub <noreply@github.com>2020-09-02 12:21:28 -0700
commita2a7c4d988b2b7126130d9dcbe4ec94e1ce8424b (patch)
tree5e9559abd79b9e2f7d4f22f65a77daaaae3eed16 /source/slang/slang-type-layout.cpp
parent7f567df6937b33c653c424af3abb20d32eb80561 (diff)
Allow unspecialized existential shader parameters (dynamic dispatch). (#1529)
* Allow unspecialized existential shader parameters (dynamic dispatch). * Fixes. * Fixes * disable cuda test
Diffstat (limited to 'source/slang/slang-type-layout.cpp')
-rw-r--r--source/slang/slang-type-layout.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp
index 9b00fc88c..dbdfaf79c 100644
--- a/source/slang/slang-type-layout.cpp
+++ b/source/slang/slang-type-layout.cpp
@@ -3613,6 +3613,22 @@ static TypeLayoutResult _createTypeLayout(
typeLayout->type = type;
typeLayout->rules = rules;
+ if (isCPUTarget(context.targetReq) || isCUDATarget(context.targetReq))
+ {
+ LayoutSize fixedSize = 16;
+ if (auto anyValueAttr =
+ interfaceDeclRef.getDecl()->findModifier<AnyValueSizeAttribute>())
+ {
+ fixedSize += anyValueAttr->size;
+ }
+ else
+ {
+ // The interface type does not have an `[anyValueSize]` attribute,
+ // assume a default of 8 bytes.
+ fixedSize += 8;
+ }
+ typeLayout->addResourceUsage(LayoutResourceKind::Uniform, fixedSize);
+ }
typeLayout->addResourceUsage(LayoutResourceKind::ExistentialTypeParam, 1);
typeLayout->addResourceUsage(LayoutResourceKind::ExistentialObjectParam, 1);