• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "node_context_descriptor_set_manager.h"
17 
18 #include <algorithm>
19 #include <cstddef>
20 #include <cstdint>
21 
22 #include <base/containers/vector.h>
23 #include <base/math/mathf.h>
24 #include <render/device/pipeline_state_desc.h>
25 #include <render/namespace.h>
26 
27 #include "device/device.h"
28 #include "device/gpu_resource_handle_util.h"
29 #include "nodecontext/pipeline_descriptor_set_binder.h"
30 #include "util/log.h"
31 
32 using namespace BASE_NS;
33 
34 RENDER_BEGIN_NAMESPACE()
35 namespace {
36 #if (RENDER_VALIDATION_ENABLED == 1)
ReduceAndValidateDescriptorCounts(const DescriptorType descriptorType,const uint32_t descriptorCount,NodeContextDescriptorSetManager::DescriptorCountValidation & countValidation)37 void ReduceAndValidateDescriptorCounts(const DescriptorType descriptorType, const uint32_t descriptorCount,
38     NodeContextDescriptorSetManager::DescriptorCountValidation& countValidation)
39 {
40     auto& valRef = countValidation.typeToCount[static_cast<uint32_t>(descriptorType)];
41     valRef -= descriptorCount;
42     if (valRef < 0) {
43         string typeName;
44         if (descriptorType == CORE_DESCRIPTOR_TYPE_SAMPLER) {
45             typeName = "CORE_DESCRIPTOR_TYPE_SAMPLER";
46         } else if (descriptorType == CORE_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) {
47             typeName = "CORE_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER";
48         } else if (descriptorType == CORE_DESCRIPTOR_TYPE_SAMPLED_IMAGE) {
49             typeName = "CORE_DESCRIPTOR_TYPE_SAMPLED_IMAGE";
50         } else if (descriptorType == CORE_DESCRIPTOR_TYPE_STORAGE_IMAGE) {
51             typeName = "CORE_DESCRIPTOR_TYPE_STORAGE_IMAGE";
52         } else if (descriptorType == CORE_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) {
53             typeName = "CORE_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER";
54         } else if (descriptorType == CORE_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER) {
55             typeName = "CORE_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER";
56         } else if (descriptorType == CORE_DESCRIPTOR_TYPE_UNIFORM_BUFFER) {
57             typeName = "CORE_DESCRIPTOR_TYPE_UNIFORM_BUFFER";
58         } else if (descriptorType == CORE_DESCRIPTOR_TYPE_STORAGE_BUFFER) {
59             typeName = "CORE_DESCRIPTOR_TYPE_STORAGE_BUFFER";
60         } else if (descriptorType == CORE_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) {
61             typeName = "CORE_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC";
62         } else if (descriptorType == CORE_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC) {
63             typeName = "CORE_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC";
64         } else if (descriptorType == CORE_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) {
65             typeName = "CORE_DESCRIPTOR_TYPE_INPUT_ATTACHMENT";
66         } else if (descriptorType == CORE_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE) {
67             typeName = "CORE_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE";
68         }
69         PLUGIN_LOG_E(
70             "RENDER_VALIDATION: Not enough descriptors available (count: %i) (type: %s)", valRef, typeName.c_str());
71     }
72 }
73 #endif
74 
CopyAndProcessBuffers(const DescriptorSetLayoutBindingResources & src,const GpuQueue & gpuQueue,NodeContextDescriptorSetManager::CpuDescriptorSet & dst)75 void CopyAndProcessBuffers(const DescriptorSetLayoutBindingResources& src, const GpuQueue& gpuQueue,
76     NodeContextDescriptorSetManager::CpuDescriptorSet& dst)
77 {
78     const uint32_t maxCount = static_cast<uint32_t>(Math::min(src.buffers.size(), dst.buffers.size()));
79     dst.buffers.clear();
80     dst.buffers.insert(dst.buffers.end(), src.buffers.begin(), src.buffers.begin() + maxCount);
81     uint32_t dynamicOffsetIndex = 0;
82     for (uint32_t idx = 0; idx < maxCount; ++idx) {
83         auto& dstRef = dst.buffers[idx];
84         dstRef.state.gpuQueue = gpuQueue;
85         if (RenderHandleUtil::IsDynamicResource(dstRef.resource.handle)) {
86             dst.hasDynamicBarrierResources = true;
87         }
88         if (NodeContextDescriptorSetManager::IsDynamicDescriptor(dstRef.binding.descriptorType)) {
89             PLUGIN_ASSERT(dynamicOffsetIndex < (uint32_t)dst.dynamicOffsetDescriptors.size());
90             dst.dynamicOffsetDescriptors[dynamicOffsetIndex++] = dstRef.resource.handle;
91         }
92     }
93 }
94 
CopyAndProcessImages(const DescriptorSetLayoutBindingResources & src,const GpuQueue & gpuQueue,NodeContextDescriptorSetManager::CpuDescriptorSet & dst)95 void CopyAndProcessImages(const DescriptorSetLayoutBindingResources& src, const GpuQueue& gpuQueue,
96     NodeContextDescriptorSetManager::CpuDescriptorSet& dst)
97 {
98     const uint32_t maxCount = static_cast<uint32_t>(Math::min(src.images.size(), dst.images.size()));
99     dst.images.clear();
100     dst.images.insert(dst.images.end(), src.images.begin(), src.images.begin() + maxCount);
101     for (uint32_t idx = 0; idx < maxCount; ++idx) {
102         auto& dstRef = dst.images[idx];
103         dstRef.state.gpuQueue = gpuQueue;
104         if (RenderHandleUtil::IsDynamicResource(dstRef.resource.handle)) {
105             dst.hasDynamicBarrierResources = true;
106         }
107         if (RenderHandleUtil::IsPlatformConversionResource(dstRef.resource.handle)) {
108             dst.hasPlatformConversionBindings = true;
109 #if (RENDER_VALIDATION_ENABLED == 1)
110             if (dstRef.binding.descriptorType != DescriptorType::CORE_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) {
111                 PLUGIN_LOG_ONCE_W("core_validation_plat_conv_desc_set",
112                     "RENDER_VALIDATION: automatic platform conversion only supported for "
113                     "CORE_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER");
114             }
115             if (dstRef.binding.descriptorCount > 1) {
116                 PLUGIN_LOG_ONCE_W("core_validation_plat_conv_desc_set_arr",
117                     "RENDER_VALIDATION: array of platform special image formats not supported");
118             }
119 #endif
120         }
121     }
122 }
123 } // namespace
124 
ResetAndReserve(const DescriptorCounts & descriptorCounts)125 void NodeContextDescriptorSetManager::ResetAndReserve(const DescriptorCounts& descriptorCounts)
126 {
127     // method
128     // prepare and create descriptor set pool
129     maxSets_ = 0;
130     auto& cpuDescriptorSets = cpuDescriptorSets_[DESCRIPTOR_SET_INDEX_TYPE_STATIC];
131     cpuDescriptorSets.clear();
132 #if (RENDER_VALIDATION_ENABLED == 1)
133     descriptorCountValidation_ = {};
134 #endif
135     for (const auto& ref : descriptorCounts.counts) {
136         maxSets_ += ref.count;
137 #if (RENDER_VALIDATION_ENABLED == 1)
138         auto& valRef = descriptorCountValidation_.typeToCount[static_cast<uint32_t>(ref.type)];
139         valRef += static_cast<int32_t>(ref.count);
140 #endif
141     }
142 
143     if (maxSets_ > 0) {
144         // usually there are less descriptor sets than max sets count
145         // due to maxsets count has been calculated for single descriptors
146         // (one descriptor set has multiple descriptors)
147         const uint32_t reserveCount = maxSets_ / 2u;
148         cpuDescriptorSets.reserve(reserveCount);
149     }
150 }
151 
BeginFrame()152 void NodeContextDescriptorSetManager::BeginFrame()
153 {
154     cpuDescriptorSets_[DESCRIPTOR_SET_INDEX_TYPE_ONE_FRAME].clear();
155     hasPlatformConversionBindings_ = false;
156 }
157 
CreateDescriptorSets(const array_view<const DescriptorSetLayoutBindings> descriptorSetsLayoutBindings)158 vector<RenderHandle> NodeContextDescriptorSetManager::CreateDescriptorSets(
159     const array_view<const DescriptorSetLayoutBindings> descriptorSetsLayoutBindings)
160 {
161     vector<RenderHandle> handles;
162     handles.reserve(descriptorSetsLayoutBindings.size());
163     for (const auto& ref : descriptorSetsLayoutBindings) {
164 #if (RENDER_VALIDATION_ENABLED == 1)
165         for (const auto& bindingRef : ref.binding) {
166             ReduceAndValidateDescriptorCounts(
167                 bindingRef.descriptorType, bindingRef.descriptorCount, descriptorCountValidation_);
168         }
169 #endif
170         handles.emplace_back(CreateDescriptorSet(ref.binding));
171     }
172     return handles;
173 }
174 
CreateDescriptorSet(const uint32_t set,const PipelineLayout & pipelineLayout)175 RenderHandle NodeContextDescriptorSetManager::CreateDescriptorSet(
176     const uint32_t set, const PipelineLayout& pipelineLayout)
177 {
178     if (set < pipelineLayout.descriptorSetCount) {
179         const auto& ref = pipelineLayout.descriptorSetLayouts[set];
180         if (ref.set == set) {
181 #if (RENDER_VALIDATION_ENABLED == 1)
182             for (const auto& bindingRef : ref.bindings) {
183                 ReduceAndValidateDescriptorCounts(
184                     bindingRef.descriptorType, bindingRef.descriptorCount, descriptorCountValidation_);
185             }
186 #endif
187             return CreateDescriptorSet(ref.bindings);
188         } else {
189             PLUGIN_LOG_E("CreateDescriptorSet: sets needs to be sorted in PipelineLayout");
190         }
191     }
192     PLUGIN_LOG_E("set index needs to be valid in PipelineLayout");
193     return {};
194 }
195 
CreateOneFrameDescriptorSets(const array_view<const DescriptorSetLayoutBindings> descriptorSetsLayoutBindings)196 vector<RenderHandle> NodeContextDescriptorSetManager::CreateOneFrameDescriptorSets(
197     const array_view<const DescriptorSetLayoutBindings> descriptorSetsLayoutBindings)
198 {
199     vector<RenderHandle> handles;
200     handles.reserve(descriptorSetsLayoutBindings.size());
201     for (const auto& ref : descriptorSetsLayoutBindings) {
202         handles.emplace_back(CreateOneFrameDescriptorSet(ref.binding));
203     }
204     return handles;
205 }
206 
CreateOneFrameDescriptorSet(const uint32_t set,const PipelineLayout & pipelineLayout)207 RenderHandle NodeContextDescriptorSetManager::CreateOneFrameDescriptorSet(
208     const uint32_t set, const PipelineLayout& pipelineLayout)
209 {
210     if (set < pipelineLayout.descriptorSetCount) {
211         const auto& ref = pipelineLayout.descriptorSetLayouts[set];
212         if (ref.set == set) {
213             return CreateOneFrameDescriptorSet(ref.bindings);
214         } else {
215             PLUGIN_LOG_E("CreateOneFrameDescriptorSet: sets needs to be sorted in PipelineLayout");
216         }
217     }
218     PLUGIN_LOG_E("set index needs to be valid in PipelineLayout");
219     return {};
220 }
221 
CreateDescriptorSetBinder(const RenderHandle handle,const array_view<const DescriptorSetLayoutBinding> descriptorSetLayoutBindings)222 IDescriptorSetBinder::Ptr NodeContextDescriptorSetManager::CreateDescriptorSetBinder(
223     const RenderHandle handle, const array_view<const DescriptorSetLayoutBinding> descriptorSetLayoutBindings)
224 {
225     return IDescriptorSetBinder::Ptr { new DescriptorSetBinder(handle, descriptorSetLayoutBindings) };
226 }
227 
CreatePipelineDescriptorSetBinder(const PipelineLayout & pipelineLayout)228 IPipelineDescriptorSetBinder::Ptr NodeContextDescriptorSetManager::CreatePipelineDescriptorSetBinder(
229     const PipelineLayout& pipelineLayout)
230 {
231     uint32_t setCount = 0;
232     DescriptorSetLayoutBindings descriptorSetLayoutBindings[PipelineLayoutConstants::MAX_DESCRIPTOR_SET_COUNT];
233     for (uint32_t idx = 0; idx < PipelineLayoutConstants::MAX_DESCRIPTOR_SET_COUNT; ++idx) {
234         if (pipelineLayout.descriptorSetLayouts[idx].set < PipelineLayoutConstants::MAX_DESCRIPTOR_SET_COUNT) {
235             descriptorSetLayoutBindings[setCount++] = { pipelineLayout.descriptorSetLayouts[idx].bindings };
236         }
237     }
238     // handles
239     RenderHandle handles[PipelineLayoutConstants::MAX_DESCRIPTOR_SET_COUNT];
240     for (uint32_t idx = 0; idx < setCount; ++idx) {
241 #if (RENDER_VALIDATION_ENABLED == 1)
242         for (const auto& bindingRef : descriptorSetLayoutBindings[idx].binding) {
243             ReduceAndValidateDescriptorCounts(
244                 bindingRef.descriptorType, bindingRef.descriptorCount, descriptorCountValidation_);
245         }
246 #endif
247         handles[idx] = CreateDescriptorSet(descriptorSetLayoutBindings[idx].binding);
248     }
249     return IPipelineDescriptorSetBinder::Ptr { new PipelineDescriptorSetBinder(
250         pipelineLayout, { handles, setCount }, { descriptorSetLayoutBindings, setCount }) };
251 }
252 
CreatePipelineDescriptorSetBinder(const PipelineLayout & pipelineLayout,const array_view<const RenderHandle> handles,const array_view<const DescriptorSetLayoutBindings> descriptorSetsLayoutBindings)253 IPipelineDescriptorSetBinder::Ptr NodeContextDescriptorSetManager::CreatePipelineDescriptorSetBinder(
254     const PipelineLayout& pipelineLayout, const array_view<const RenderHandle> handles,
255     const array_view<const DescriptorSetLayoutBindings> descriptorSetsLayoutBindings)
256 {
257     return IPipelineDescriptorSetBinder::Ptr { new PipelineDescriptorSetBinder(
258         pipelineLayout, handles, descriptorSetsLayoutBindings) };
259 }
260 
GetCpuDescriptorSetData(const RenderHandle handle) const261 DescriptorSetLayoutBindingResources NodeContextDescriptorSetManager::GetCpuDescriptorSetData(
262     const RenderHandle handle) const
263 {
264     const uint32_t arrayIndex = RenderHandleUtil::GetIndexPart(handle);
265     const uint32_t oneFrameDescBit = RenderHandleUtil::GetAdditionalData(handle);
266     const uint32_t descSetIdx = (oneFrameDescBit == ONE_FRAME_DESC_SET_BIT) ? DESCRIPTOR_SET_INDEX_TYPE_ONE_FRAME
267                                                                             : DESCRIPTOR_SET_INDEX_TYPE_STATIC;
268     const auto& cpuDescSets = cpuDescriptorSets_[descSetIdx];
269     return GetCpuDescriptorSetDataImpl(arrayIndex, cpuDescSets);
270 }
271 
GetDynamicOffsetDescriptors(const RenderHandle handle) const272 DynamicOffsetDescriptors NodeContextDescriptorSetManager::GetDynamicOffsetDescriptors(const RenderHandle handle) const
273 {
274     const uint32_t arrayIndex = RenderHandleUtil::GetIndexPart(handle);
275     const uint32_t oneFrameDescBit = RenderHandleUtil::GetAdditionalData(handle);
276     const uint32_t descSetIdx = (oneFrameDescBit == ONE_FRAME_DESC_SET_BIT) ? DESCRIPTOR_SET_INDEX_TYPE_ONE_FRAME
277                                                                             : DESCRIPTOR_SET_INDEX_TYPE_STATIC;
278     const auto& cpuDescSets = cpuDescriptorSets_[descSetIdx];
279     return GetDynamicOffsetDescriptorsImpl(arrayIndex, cpuDescSets);
280 }
281 
HasDynamicBarrierResources(const RenderHandle handle) const282 bool NodeContextDescriptorSetManager::HasDynamicBarrierResources(const RenderHandle handle) const
283 {
284     const uint32_t arrayIndex = RenderHandleUtil::GetIndexPart(handle);
285     const uint32_t oneFrameDescBit = RenderHandleUtil::GetAdditionalData(handle);
286     const uint32_t descSetIdx = (oneFrameDescBit == ONE_FRAME_DESC_SET_BIT) ? DESCRIPTOR_SET_INDEX_TYPE_ONE_FRAME
287                                                                             : DESCRIPTOR_SET_INDEX_TYPE_STATIC;
288     const auto& cpuDescSets = cpuDescriptorSets_[descSetIdx];
289     return HasDynamicBarrierResourcesImpl(arrayIndex, cpuDescSets);
290 }
291 
GetDynamicOffsetDescriptorCount(const RenderHandle handle) const292 uint32_t NodeContextDescriptorSetManager::GetDynamicOffsetDescriptorCount(const RenderHandle handle) const
293 {
294     const uint32_t arrayIndex = RenderHandleUtil::GetIndexPart(handle);
295     const uint32_t oneFrameDescBit = RenderHandleUtil::GetAdditionalData(handle);
296     const uint32_t descSetIdx = (oneFrameDescBit == ONE_FRAME_DESC_SET_BIT) ? DESCRIPTOR_SET_INDEX_TYPE_ONE_FRAME
297                                                                             : DESCRIPTOR_SET_INDEX_TYPE_STATIC;
298     const auto& cpuDescSets = cpuDescriptorSets_[descSetIdx];
299     return GetDynamicOffsetDescriptorCountImpl(arrayIndex, cpuDescSets);
300 }
301 
HasPlatformBufferBindings(const RenderHandle handle) const302 bool NodeContextDescriptorSetManager::HasPlatformBufferBindings(const RenderHandle handle) const
303 {
304     const uint32_t arrayIndex = RenderHandleUtil::GetIndexPart(handle);
305     const uint32_t oneFrameDescBit = RenderHandleUtil::GetAdditionalData(handle);
306     const uint32_t descSetIdx = (oneFrameDescBit == ONE_FRAME_DESC_SET_BIT) ? DESCRIPTOR_SET_INDEX_TYPE_ONE_FRAME
307                                                                             : DESCRIPTOR_SET_INDEX_TYPE_STATIC;
308     const auto& cpuDescSets = cpuDescriptorSets_[descSetIdx];
309     return HasPlatformBufferBindingsImpl(arrayIndex, cpuDescSets);
310 }
311 
UpdateCpuDescriptorSet(const RenderHandle handle,const DescriptorSetLayoutBindingResources & bindingResources,const GpuQueue & gpuQueue)312 void NodeContextDescriptorSetManager::UpdateCpuDescriptorSet(
313     const RenderHandle handle, const DescriptorSetLayoutBindingResources& bindingResources, const GpuQueue& gpuQueue)
314 {
315     const uint32_t arrayIndex = RenderHandleUtil::GetIndexPart(handle);
316     const uint32_t oneFrameDescBit = RenderHandleUtil::GetAdditionalData(handle);
317     const uint32_t descSetIdx = (oneFrameDescBit == ONE_FRAME_DESC_SET_BIT) ? DESCRIPTOR_SET_INDEX_TYPE_ONE_FRAME
318                                                                             : DESCRIPTOR_SET_INDEX_TYPE_STATIC;
319     auto& cpuDescSets = cpuDescriptorSets_[descSetIdx];
320     UpdateCpuDescriptorSetImpl(arrayIndex, bindingResources, gpuQueue, cpuDescSets);
321 }
322 
UpdateCpuDescriptorSetImpl(const uint32_t index,const DescriptorSetLayoutBindingResources & bindingResources,const GpuQueue & gpuQueue,vector<CpuDescriptorSet> & cpuDescriptorSets)323 void NodeContextDescriptorSetManager::UpdateCpuDescriptorSetImpl(const uint32_t index,
324     const DescriptorSetLayoutBindingResources& bindingResources, const GpuQueue& gpuQueue,
325     vector<CpuDescriptorSet>& cpuDescriptorSets)
326 {
327     if (index < (uint32_t)cpuDescriptorSets.size()) {
328         auto& refCpuSet = cpuDescriptorSets[index];
329 #if (RENDER_VALIDATION_ENABLED == 1)
330         if (refCpuSet.bindings.size() != bindingResources.bindings.size()) {
331             PLUGIN_LOG_E("RENDER_VALIDATION: sizes must match; update all bindings always in a single set");
332         }
333 #endif
334         PLUGIN_ASSERT(bindingResources.buffers.size() == refCpuSet.buffers.size());
335         PLUGIN_ASSERT(bindingResources.images.size() == refCpuSet.images.size());
336         PLUGIN_ASSERT(bindingResources.samplers.size() == refCpuSet.samplers.size());
337 
338         refCpuSet.isDirty = true;
339         refCpuSet.hasDynamicBarrierResources = false;
340         refCpuSet.hasPlatformConversionBindings = false;
341 
342         // NOTE: GPU queue patching could be moved to render graph
343         // copy from src to dst and check flags
344         CopyAndProcessBuffers(bindingResources, gpuQueue, refCpuSet);
345         CopyAndProcessImages(bindingResources, gpuQueue, refCpuSet);
346         // samplers don't have state and dynamic resources
347         refCpuSet.samplers.clear();
348         std::copy(bindingResources.samplers.cbegin().ptr(), bindingResources.samplers.cend().ptr(),
349             std::back_inserter(refCpuSet.samplers));
350 
351         for (size_t idx = 0; idx < bindingResources.bindings.size(); ++idx) {
352             const DescriptorSetLayoutBindingResource& refBinding = bindingResources.bindings[idx];
353             // the actual binding index is not important here (refBinding.binding.binding)
354             PLUGIN_ASSERT(idx < refCpuSet.bindings.size());
355             DescriptorSetLayoutBindingResource& refCpuBinding = refCpuSet.bindings[idx];
356             refCpuBinding.resourceIndex = refBinding.resourceIndex;
357         }
358         hasPlatformConversionBindings_ = (hasPlatformConversionBindings_ || refCpuSet.hasPlatformConversionBindings);
359     } else {
360 #if (RENDER_VALIDATION_ENABLED == 1)
361         PLUGIN_LOG_E("RENDER_VALIDATION: invalid handle to UpdateCpuDescriptorSet");
362 #endif
363     }
364 }
365 
GetCpuDescriptorSetDataImpl(const uint32_t index,const vector<CpuDescriptorSet> & cpuDescriptorSet) const366 DescriptorSetLayoutBindingResources NodeContextDescriptorSetManager::GetCpuDescriptorSetDataImpl(
367     const uint32_t index, const vector<CpuDescriptorSet>& cpuDescriptorSet) const
368 {
369     if (index < cpuDescriptorSet.size()) {
370         return DescriptorSetLayoutBindingResources {
371             cpuDescriptorSet[index].bindings,
372             cpuDescriptorSet[index].buffers,
373             cpuDescriptorSet[index].images,
374             cpuDescriptorSet[index].samplers,
375         };
376     } else {
377 #if (RENDER_VALIDATION_ENABLED == 1)
378         PLUGIN_LOG_E("RENDER_VALIDATION: invalid handle to GetCpuDescriptorSetData");
379 #endif
380         return {};
381     }
382 }
383 
GetDynamicOffsetDescriptorsImpl(const uint32_t index,const vector<CpuDescriptorSet> & cpuDescriptorSet) const384 DynamicOffsetDescriptors NodeContextDescriptorSetManager::GetDynamicOffsetDescriptorsImpl(
385     const uint32_t index, const vector<CpuDescriptorSet>& cpuDescriptorSet) const
386 {
387     if (index < cpuDescriptorSet.size()) {
388         return DynamicOffsetDescriptors {
389             array_view<const RenderHandle>(cpuDescriptorSet[index].dynamicOffsetDescriptors.data(),
390                 cpuDescriptorSet[index].dynamicOffsetDescriptors.size()),
391         };
392     } else {
393 #if (RENDER_VALIDATION_ENABLED == 1)
394         PLUGIN_LOG_E("RENDER_VALIDATION: invalid handle to GetDynamicOffsetDescriptors");
395 #endif
396         return {};
397     }
398 }
399 
HasDynamicBarrierResourcesImpl(const uint32_t index,const vector<CpuDescriptorSet> & cpuDescriptorSet) const400 bool NodeContextDescriptorSetManager::HasDynamicBarrierResourcesImpl(
401     const uint32_t index, const vector<CpuDescriptorSet>& cpuDescriptorSet) const
402 {
403     if (index < (uint32_t)cpuDescriptorSet.size()) {
404         return cpuDescriptorSet[index].hasDynamicBarrierResources;
405     } else {
406 #if (RENDER_VALIDATION_ENABLED == 1)
407         PLUGIN_LOG_E("RENDER_VALIDATION: invalid handle to HasDynamicBarrierResources");
408 #endif
409         return false;
410     }
411 }
412 
HasPlatformBufferBindingsImpl(const uint32_t index,const vector<CpuDescriptorSet> & cpuDescriptorSet) const413 bool NodeContextDescriptorSetManager::HasPlatformBufferBindingsImpl(
414     const uint32_t index, const vector<CpuDescriptorSet>& cpuDescriptorSet) const
415 {
416     if (index < (uint32_t)cpuDescriptorSet.size()) {
417         return cpuDescriptorSet[index].hasPlatformConversionBindings;
418     } else {
419 #if (RENDER_VALIDATION_ENABLED == 1)
420         PLUGIN_LOG_E("RENDER_VALIDATION: invalid handle to HasPlatformBufferBindingsImpl");
421 #endif
422         return false;
423     }
424 }
425 
GetDynamicOffsetDescriptorCountImpl(const uint32_t index,const vector<CpuDescriptorSet> & cpuDescriptorSet) const426 uint32_t NodeContextDescriptorSetManager::GetDynamicOffsetDescriptorCountImpl(
427     const uint32_t index, const vector<CpuDescriptorSet>& cpuDescriptorSet) const
428 {
429     if (index < (uint32_t)cpuDescriptorSet.size()) {
430         return (uint32_t)cpuDescriptorSet[index].dynamicOffsetDescriptors.size();
431     } else {
432 #if (RENDER_VALIDATION_ENABLED == 1)
433         PLUGIN_LOG_E("RENDER_VALIDATION: invalid handle to GetDynamicOffsetDescriptorCount");
434 #endif
435         return 0;
436     }
437 }
438 
439 #if ((RENDER_VALIDATION_ENABLED == 1) || (RENDER_VULKAN_VALIDATION_ENABLED == 1))
SetValidationDebugName(const string_view debugName)440 void NodeContextDescriptorSetManager::SetValidationDebugName(const string_view debugName)
441 {
442     debugName_ = debugName;
443 }
444 #endif
445 RENDER_END_NAMESPACE()
446