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 /tools/render-test/bind-location.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 'tools/render-test/bind-location.cpp')
| -rw-r--r-- | tools/render-test/bind-location.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/tools/render-test/bind-location.cpp b/tools/render-test/bind-location.cpp index 4ec590fd5..f791e56f6 100644 --- a/tools/render-test/bind-location.cpp +++ b/tools/render-test/bind-location.cpp @@ -328,6 +328,23 @@ void BindSet::calcValueLocations(const BindLocation& location, Slang::List<BindL } } +// Finds the first category from layout reflection that represents an actual value +// i.e. that is not ExistentialType or ExistentialObject. +template<typename LayoutReflectionType> +slang::ParameterCategory getFirstNonExistentialValueCategory(LayoutReflectionType* layout) +{ + slang::ParameterCategory category = slang::ParameterCategory::None; + for (UInt i = 0; i < layout->getCategoryCount(); i++) + { + auto currentCategory = layout->getCategoryByIndex((unsigned int)i); + if (currentCategory == slang::ParameterCategory::ExistentialTypeParam || + currentCategory == slang::ParameterCategory::ExistentialObjectParam) + continue; + category = currentCategory; + } + return category; +} + BindLocation BindSet::toField(const BindLocation& loc, slang::VariableLayoutReflection* field) const { const Index categoryCount = Index(field->getCategoryCount()); @@ -363,8 +380,8 @@ BindLocation BindSet::toField(const BindLocation& loc, slang::VariableLayoutRefl } else { - SLANG_ASSERT(categoryCount == 1); - auto category = field->getCategoryByIndex(0); + slang::ParameterCategory category = getFirstNonExistentialValueCategory(field); + SLANG_ASSERT(category != slang::ParameterCategory::None); // If I'm going from mixed, then I will have multiple items being tracked (so won't be here) // If I'm not, then I'm getting an inplace field. It must be relative @@ -496,8 +513,8 @@ BindLocation BindSet::toIndex(const BindLocation& loc, Index index) const } else { - SLANG_ASSERT(categoryCount == 1); - auto category = elementTypeLayout->getCategoryByIndex(0); + slang::ParameterCategory category = getFirstNonExistentialValueCategory(elementTypeLayout); + SLANG_ASSERT(category != slang::ParameterCategory::None); const auto elementStride = typeLayout->getElementStride(category); |
