Skip to content

Commit 13a835b

Browse files
author
devsh
committed
fix removeGeometry to actually deallocate slots in the Suballocated Descriptor sets and no null-free
1 parent adbd5f0 commit 13a835b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

common/include/nbl/examples/geometry/CSimpleDebugRenderer.hpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ 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+
uint8_t positionView = MissingView;
62+
uint8_t normalView = MissingView;
63+
uint8_t uvView = MissingView;
6364
asset::E_INDEX_TYPE indexType = asset::EIT_UNKNOWN;
6465
};
6566
//
@@ -137,7 +138,7 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
137138
// need this trifecta of flags for `SubAllocatedDescriptorSet` to accept the binding as suballocatable
138139
.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,
139140
.stageFlags = IShader::E_SHADER_STAGE::ESS_VERTEX|IShader::E_SHADER_STAGE::ESS_FRAGMENT,
140-
.count = SInstance::SPushConstants::DescriptorCount
141+
.count = SPackedGeometry::MissingView
141142
}
142143
};
143144
dsLayout = device->createDescriptorSetLayout(bindings);
@@ -249,10 +250,10 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
249250
auto allocateUTB = [&](const IGeometry<const IGPUBuffer>::SDataView& view)->uint8_t
250251
{
251252
if (!view)
252-
return SInstance::SPushConstants::DescriptorCount;
253+
return SPackedGeometry::MissingView;
253254
auto index = SubAllocatedDescriptorSet::invalid_value;
254255
if (m_params.subAllocDS->multi_allocate(VertexAttrubUTBDescBinding,1,&index)!=0)
255-
return SInstance::SPushConstants::DescriptorCount;
256+
return SPackedGeometry::MissingView;
256257
const auto retval = infos.size();
257258
infos.emplace_back().desc = device->createBufferView(view.src,view.composed.format);
258259
writes.emplace_back() = {
@@ -340,6 +341,8 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
340341
deferredFree.reserve(3);
341342
auto deallocate = [&](SubAllocatedDescriptorSet::value_type index)->void
342343
{
344+
if (index>=SPackedGeometry::MissingView)
345+
return;
343346
if (info.semaphore)
344347
deferredFree.push_back(index);
345348
else
@@ -353,9 +356,7 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
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
//

0 commit comments

Comments
 (0)