@@ -57,9 +57,9 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
5757 asset::SBufferBinding<const video::IGPUBuffer> indexBuffer = {};
5858 uint32_t elementCount = 0 ;
5959 // indices into the descriptor set
60- uint8_t positionView = 0 ;
61- uint8_t normalView = 0 ;
62- uint8_t uvView = 0 ;
60+ constexpr static inline auto MissingView = hlsl::examples::geometry_creator_scene::SPushConstants::DescriptorCount ;
61+ uint16_t positionView = MissingView ;
62+ uint16_t normalView = MissingView ;
6363 asset::E_INDEX_TYPE indexType = asset::EIT_UNKNOWN;
6464 };
6565 //
@@ -72,8 +72,7 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
7272 return {
7373 .matrices = viewParams.computeForInstance (world),
7474 .positionView = packedGeo->positionView ,
75- .normalView = packedGeo->normalView ,
76- .uvView = packedGeo->uvView
75+ .normalView = packedGeo->normalView
7776 };
7877 }
7978
@@ -137,7 +136,7 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
137136 // need this trifecta of flags for `SubAllocatedDescriptorSet` to accept the binding as suballocatable
138137 .createFlags = binding_flags_t ::ECF_UPDATE_AFTER_BIND_BIT|binding_flags_t ::ECF_UPDATE_UNUSED_WHILE_PENDING_BIT |binding_flags_t ::ECF_PARTIALLY_BOUND_BIT,
139138 .stageFlags = IShader::E_SHADER_STAGE::ESS_VERTEX|IShader::E_SHADER_STAGE::ESS_FRAGMENT,
140- .count = SInstance::SPushConstants::DescriptorCount
139+ .count = SPackedGeometry::MissingView
141140 }
142141 };
143142 dsLayout = device->createDescriptorSetLayout (bindings);
@@ -161,7 +160,7 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
161160
162161 // create pipeline layout
163162 const SPushConstantRange ranges[] = {{
164- .stageFlags = hlsl::ShaderStage::ESS_VERTEX,
163+ .stageFlags = hlsl::ShaderStage::ESS_VERTEX|hlsl::ShaderStage::ESS_FRAGMENT ,
165164 .offset = 0 ,
166165 .size = sizeof (SInstance::SPushConstants),
167166 }};
@@ -246,24 +245,30 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
246245
247246 core::vector<IGPUDescriptorSet::SWriteDescriptorSet> writes;
248247 core::vector<IGPUDescriptorSet::SDescriptorInfo> infos;
249- auto allocateUTB = [&](const IGeometry<const IGPUBuffer>::SDataView& view)->uint8_t
248+ bool anyFailed = false ;
249+ auto allocateUTB = [&](const IGeometry<const IGPUBuffer>::SDataView& view)->decltype (SubAllocatedDescriptorSet::invalid_value)
250250 {
251251 if (!view)
252- return SInstance::SPushConstants::DescriptorCount ;
252+ return SPackedGeometry::MissingView ;
253253 auto index = SubAllocatedDescriptorSet::invalid_value;
254254 if (m_params.subAllocDS ->multi_allocate (VertexAttrubUTBDescBinding,1 ,&index)!=0 )
255- return SInstance::SPushConstants::DescriptorCount;
256- const auto retval = infos.size ();
255+ {
256+ anyFailed = true ;
257+ return SPackedGeometry::MissingView;
258+ }
259+ const auto infosOffset = infos.size ();
257260 infos.emplace_back ().desc = device->createBufferView (view.src ,view.composed .format );
258261 writes.emplace_back () = {
259262 .dstSet = m_params.subAllocDS ->getDescriptorSet (),
260263 .binding = VertexAttrubUTBDescBinding,
261264 .arrayElement = index,
262265 .count = 1 ,
263- .info = reinterpret_cast <const IGPUDescriptorSet::SDescriptorInfo*>(retval )
266+ .info = reinterpret_cast <const IGPUDescriptorSet::SDescriptorInfo*>(infosOffset )
264267 };
265- return retval ;
268+ return index ;
266269 };
270+ if (anyFailed)
271+ device->getLogger ()->log (" Failed to allocate a UTB for some geometries, probably ran out of space in Descriptor Set!" ,system::ILogger::ELL_ERROR);
267272
268273 auto sizeToSet = m_geoms.size ();
269274 auto resetGeoms = core::makeRAIIExiter ([&]()->void
@@ -308,9 +313,6 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
308313 out.elementCount = geom->getVertexReferenceCount ();
309314 out.positionView = allocateUTB (geom->getPositionView ());
310315 out.normalView = allocateUTB (geom->getNormalView ());
311- // the first view is usually the UV
312- if (const auto & auxViews = geom->getAuxAttributeViews (); !auxViews.empty ())
313- out.uvView = allocateUTB (auxViews.front ());
314316 }
315317
316318 // no geometry
@@ -340,6 +342,8 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
340342 deferredFree.reserve (3 );
341343 auto deallocate = [&](SubAllocatedDescriptorSet::value_type index)->void
342344 {
345+ if (index>=SPackedGeometry::MissingView)
346+ return ;
343347 if (info.semaphore )
344348 deferredFree.push_back (index);
345349 else
@@ -348,14 +352,11 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
348352 auto geo = m_geoms.begin () + ix;
349353 deallocate (geo->positionView );
350354 deallocate (geo->normalView );
351- deallocate (geo->uvView );
352355 m_geoms.erase (geo);
353356
354357 if (deferredFree.empty ())
355358 return ;
356-
357- core::vector<IGPUDescriptorSet::SDropDescriptorSet> nullify (deferredFree.size ());
358- const_cast <ILogicalDevice*>(m_params.layout ->getOriginDevice ())->nullifyDescriptors (nullify);
359+ m_params.subAllocDS ->multi_deallocate (VertexAttrubUTBDescBinding,deferredFree.size (),deferredFree.data (),info);
359360 }
360361
361362 //
@@ -386,7 +387,7 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
386387 const auto * geo = instance.packedGeo ;
387388 cmdbuf->bindGraphicsPipeline (geo->pipeline .get ());
388389 const auto pc = instance.computePushConstants (viewParams);
389- cmdbuf->pushConstants (layout,hlsl::ShaderStage::ESS_VERTEX,0 ,sizeof (pc),&pc);
390+ cmdbuf->pushConstants (layout,hlsl::ShaderStage::ESS_VERTEX|hlsl::ShaderStage::ESS_FRAGMENT ,0 ,sizeof (pc),&pc);
390391 if (geo->indexBuffer )
391392 {
392393 cmdbuf->bindIndexBuffer (geo->indexBuffer ,geo->indexType );
0 commit comments