88#include " Lux/Platform/Vulkan/VulkanShader.h"
99
1010#include < set>
11+ #include < vector>
1112
1213namespace Lux {
1314
@@ -17,8 +18,7 @@ namespace Lux {
1718
1819 struct RenderPassInput
1920 {
20- static constexpr uint32_t MAX_ARRAY_ELEMENTS = 32 ;
21- using InputArray = nvrhi::static_vector<Ref<RefCounted>, MAX_ARRAY_ELEMENTS >;
21+ using InputArray = std::vector<Ref<RefCounted>>;
2222
2323 RenderResourceType Type = RenderResourceType::None;
2424 bool IsWriteable = false ;
@@ -64,57 +64,73 @@ namespace Lux {
6464 void Set (Ref<UniformBuffer> uniformBuffer, uint32_t arrayIndex = 0 )
6565 {
6666 Type = RenderResourceType::UniformBuffer;
67+ EnsureSize (arrayIndex);
6768 Input[arrayIndex] = uniformBuffer;
6869 }
6970
7071 void Set (Ref<UniformBufferSet> uniformBufferSet, uint32_t arrayIndex = 0 )
7172 {
7273 Type = RenderResourceType::UniformBufferSet;
74+ EnsureSize (arrayIndex);
7375 Input[arrayIndex] = uniformBufferSet;
7476 }
7577
7678 void Set (Ref<StorageBuffer> storageBuffer, uint32_t arrayIndex = 0 )
7779 {
7880 Type = RenderResourceType::StorageBuffer;
81+ EnsureSize (arrayIndex);
7982 Input[arrayIndex] = storageBuffer;
8083 }
8184
8285 void Set (Ref<StorageBufferSet> storageBufferSet, uint32_t arrayIndex = 0 )
8386 {
8487 Type = RenderResourceType::StorageBufferSet;
88+ EnsureSize (arrayIndex);
8589 Input[arrayIndex] = storageBufferSet;
8690 }
8791
8892 void Set (Ref<Texture2D> texture, uint32_t arrayIndex = 0 )
8993 {
9094 Type = RenderResourceType::Texture2D;
95+ EnsureSize (arrayIndex);
9196 Input[arrayIndex] = texture;
9297 }
9398
9499 void Set (Ref<TextureCube> texture, uint32_t arrayIndex = 0 )
95100 {
96101 Type = RenderResourceType::TextureCube;
102+ EnsureSize (arrayIndex);
97103 Input[arrayIndex] = texture;
98104 }
99105
100106 void Set (Ref<Image2D> image, uint32_t arrayIndex = 0 )
101107 {
102108 Type = RenderResourceType::Image2D;
109+ EnsureSize (arrayIndex);
103110 Input[arrayIndex] = image;
104111 }
105112
106113 void Set (Ref<ImageView> image, uint32_t arrayIndex = 0 )
107114 {
108115 Type = RenderResourceType::Image2D;
116+ EnsureSize (arrayIndex);
109117 Input[arrayIndex] = image;
110118 }
111119
112120 void Set (Ref<Sampler> sampler, uint32_t arrayIndex = 0 )
113121 {
114122 Type = RenderResourceType::Sampler;
123+ EnsureSize (arrayIndex);
115124 Input[arrayIndex] = sampler;
116125 }
117126
127+ private:
128+ void EnsureSize (uint32_t arrayIndex)
129+ {
130+ if (Input.size () <= arrayIndex)
131+ Input.resize ((size_t )arrayIndex + 1 );
132+ }
133+
118134 };
119135
120136 inline bool IsCompatibleInput (RenderResourceType inputResource, RenderInputType inputType)
@@ -240,8 +256,7 @@ namespace Lux {
240256 // Per-frame in flight
241257 nvrhi::static_vector<nvrhi::static_vector<nvrhi::BindingSetHandle, nvrhi::c_MaxBindingLayouts>, 3 > m_BindingSets;
242258 // Frame->set->binding
243- static constexpr uint32_t MAX_ARRAY_ELEMENTS = 32 ;
244- nvrhi::static_vector<std::map<uint32_t , std::map<uint32_t , nvrhi::static_vector<nvrhi::ResourceHandle, MAX_ARRAY_ELEMENTS >>>, 3 > m_BindingSetHandles;
259+ nvrhi::static_vector<std::map<uint32_t , std::map<uint32_t , std::vector<nvrhi::ResourceHandle>>>, 3 > m_BindingSetHandles;
245260
246261 };
247262
0 commit comments