From a2a7c4d988b2b7126130d9dcbe4ec94e1ce8424b Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 2 Sep 2020 12:21:28 -0700 Subject: Allow unspecialized existential shader parameters (dynamic dispatch). (#1529) * Allow unspecialized existential shader parameters (dynamic dispatch). * Fixes. * Fixes * disable cuda test --- source/slang/slang-type-layout.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/slang/slang-type-layout.cpp') 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()) + { + 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); -- cgit v1.2.3