diff options
| author | Yong He <yonghe@outlook.com> | 2020-09-04 10:18:44 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-04 10:18:44 -0700 |
| commit | 8f962894fd38edb47d782d303ac9ff87b3a3bb6a (patch) | |
| tree | 449d0d58ca7d90a11759372c9dc82650a565f96a /source/slang/slang-type-layout.cpp | |
| parent | 5e10f1b4f0654515af1fcb29e8d1f35e691c8aa3 (diff) | |
Allow mixing unspecialized and specialized existential parameters. (#1533)
* Allow mixing unspecialized and specialized existential parameters.
* Fixes.
Diffstat (limited to 'source/slang/slang-type-layout.cpp')
| -rw-r--r-- | source/slang/slang-type-layout.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp index fd0b126e8..d4c6a7016 100644 --- a/source/slang/slang-type-layout.cpp +++ b/source/slang/slang-type-layout.cpp @@ -3662,9 +3662,10 @@ static TypeLayoutResult _createTypeLayout( typeLayout->rules = rules; LayoutSize fixedExistentialValueSize = 0; - bool useFixedSizedExistentialValue = + bool targetSupportsPointer = isCPUTarget(context.targetReq) || isCUDATarget(context.targetReq); - if (useFixedSizedExistentialValue) + + if (targetSupportsPointer) { fixedExistentialValueSize = 16; if (auto anyValueAttr = @@ -3672,7 +3673,9 @@ static TypeLayoutResult _createTypeLayout( { fixedExistentialValueSize = anyValueAttr->size; } - typeLayout->addResourceUsage(LayoutResourceKind::Uniform, fixedExistentialValueSize + 16); + // Append 16 bytes to accommodate RTTI pointer and witness table pointer. + auto uniformSlotSize = fixedExistentialValueSize + 16; + typeLayout->addResourceUsage(LayoutResourceKind::Uniform, uniformSlotSize); } typeLayout->addResourceUsage(LayoutResourceKind::ExistentialTypeParam, 1); typeLayout->addResourceUsage(LayoutResourceKind::ExistentialObjectParam, 1); @@ -3695,17 +3698,14 @@ static TypeLayoutResult _createTypeLayout( // the existential value. We should remove this special case logic // and always use anyValueRule once we implement the correct loading // code gen logic for these targets. - if (!(isCPUTarget(context.targetReq) || isCUDATarget(context.targetReq))) + if (!targetSupportsPointer) anyValueRules = context.rules; RefPtr<TypeLayout> concreteTypeLayout = createTypeLayout(context.with(anyValueRules), concreteType); - auto uniformLayoutInfo = - concreteTypeLayout->FindResourceInfo(LayoutResourceKind::Uniform); - if (!useFixedSizedExistentialValue || - (uniformLayoutInfo && uniformLayoutInfo->count > fixedExistentialValueSize)) + if (!targetSupportsPointer) { - // TODO: for targets that supports pointers, oversized existential values + // For targets that supports pointers, oversized existential values // should be placed in an overflow region and only a pointer is needed in // the place of the fixed sized uniform slot. // We only need the "pending layout" mechanism for targets that does not |
