diff options
| author | Yong He <yonghe@outlook.com> | 2020-09-14 12:26:54 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-14 12:26:54 -0700 |
| commit | 03050997b90b6c07bfdc5ca9c0c08cd278b1b1dd (patch) | |
| tree | 9cbfece387e960bedc3df3236eaaf0236c7bff0b /source/slang/slang-type-layout.cpp | |
| parent | 2e3688af574738650c2753680ce9f417fb22e5e7 (diff) | |
Support shader parameters that are an array of existential type. (#1542)
* Support shader parameters that are an array of existential type.
* Rename to getFirstNonExistentialValueCategory
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-type-layout.cpp')
| -rw-r--r-- | source/slang/slang-type-layout.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp index 46a521f79..88ec5f4f7 100644 --- a/source/slang/slang-type-layout.cpp +++ b/source/slang/slang-type-layout.cpp @@ -3489,6 +3489,13 @@ static TypeLayoutResult _createTypeLayout( { arrayResourceCount = elementResourceInfo.count; } + // The second exception to this is arrays of an existential type + // where the entire array should be specialized to a single concrete type. + // + else if (elementResourceInfo.kind == LayoutResourceKind::ExistentialTypeParam) + { + arrayResourceCount = elementResourceInfo.count; + } // // The next big exception is when we are forming an unbounded-size // array and the element type got "adjusted," because that means @@ -3677,6 +3684,7 @@ static TypeLayoutResult _createTypeLayout( typeLayout->rules = rules; LayoutSize fixedExistentialValueSize = 0; + LayoutSize uniformSlotSize = 0; bool targetSupportsPointer = isCPUTarget(context.targetReq) || isCUDATarget(context.targetReq); @@ -3689,7 +3697,7 @@ static TypeLayoutResult _createTypeLayout( fixedExistentialValueSize = anyValueAttr->size; } // Append 16 bytes to accommodate RTTI pointer and witness table pointer. - auto uniformSlotSize = fixedExistentialValueSize + 16; + uniformSlotSize = fixedExistentialValueSize + 16; typeLayout->addResourceUsage(LayoutResourceKind::Uniform, uniformSlotSize); } typeLayout->addResourceUsage(LayoutResourceKind::ExistentialTypeParam, 1); @@ -3736,8 +3744,9 @@ static TypeLayoutResult _createTypeLayout( typeLayout->pendingDataTypeLayout = concreteTypeLayout; } } - - return TypeLayoutResult(typeLayout, SimpleLayoutInfo()); + // Interface type occupies a uniform slot for the fixed size storage, with alignment of 4 bytes. + return TypeLayoutResult( + typeLayout, SimpleLayoutInfo(LayoutResourceKind::Uniform, uniformSlotSize, 4)); } else if( auto enumDeclRef = declRef.as<EnumDecl>() ) { |
