@@ -66,11 +66,12 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
6666 // TODO: Find a workaround for this
6767 inline void operator ()()
6868 {
69- core::vector<IGPUDescriptorSet::SDropDescriptorSet> nulls (m_addresses->size ());
70- auto ptr = nulls.data ();
71- operator ()(ptr);
72- auto size = ptr - nulls.data ();
73- m_composed->m_logicalDevice ->nullifyDescriptors ({nulls.data (),size_type (size)});
69+ assert (false ); // This should not be called, timeline needs to be drained before destructor
70+ // core::vector<IGPUDescriptorSet::SDropDescriptorSet> nulls(m_addresses->size());
71+ // auto ptr = nulls.data();
72+ // operator()(ptr);
73+ // auto size = ptr - nulls.data();
74+ // m_composed->m_logicalDevice->nullifyDescriptors({nulls.data(),size_type(size)});
7475 }
7576
7677 // Takes count of allocations we want to free up as reference, true is returned if
@@ -102,20 +103,31 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
102103 std::unique_ptr<AddressAllocator> addressAllocator = nullptr ;
103104 std::unique_ptr<ReservedAllocator> reservedAllocator = nullptr ;
104105 size_t reservedSize = 0 ;
106+ asset::IDescriptor::E_TYPE descriptorType = asset::IDescriptor::E_TYPE::ET_COUNT;
105107
106108 SubAllocDescriptorSetRange (
107109 std::unique_ptr<AddressAllocator>&& inAddressAllocator,
108110 std::unique_ptr<ReservedAllocator>&& inReservedAllocator,
109- size_t inReservedSize) :
111+ size_t inReservedSize,
112+ asset::IDescriptor::E_TYPE inDescriptorType) :
110113 eventHandler ({}), addressAllocator(std::move(inAddressAllocator)),
111- reservedAllocator (std::move(inReservedAllocator)), reservedSize(inReservedSize) {}
114+ reservedAllocator (std::move(inReservedAllocator)),
115+ reservedSize(inReservedSize),
116+ descriptorType(inDescriptorType) {}
112117 SubAllocDescriptorSetRange () {}
113118
114119 SubAllocDescriptorSetRange& operator =(SubAllocDescriptorSetRange&& other)
115120 {
116121 addressAllocator = std::move (other.addressAllocator );
117122 reservedAllocator = std::move (other.reservedAllocator );
118123 reservedSize = other.reservedSize ;
124+ descriptorType = other.descriptorType ;
125+
126+ // Nullify other
127+ other.addressAllocator = nullptr ;
128+ other.reservedAllocator = nullptr ;
129+ other.reservedSize = 0u ;
130+ other.descriptorType = asset::IDescriptor::E_TYPE::ET_COUNT;
119131 return *this ;
120132 }
121133 };
@@ -164,7 +176,7 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
164176 MinDescriptorSetAllocationSize
165177 ));
166178
167- m_allocatableRanges[binding.data ] = SubAllocDescriptorSetRange (std::move (addressAllocator), std::move (reservedAllocator), reservedSize);
179+ m_allocatableRanges[binding.data ] = SubAllocDescriptorSetRange (std::move (addressAllocator), std::move (reservedAllocator), reservedSize, descType );
168180 }
169181 }
170182 }
@@ -261,7 +273,7 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
261273 nulls.resize (m_totalDeferredFrees);
262274 auto outNulls = nulls.data ();
263275 eventHandler.wait (maxWaitPoint, unallocatedSize, outNulls);
264- m_logicalDevice->nullifyDescriptors ({nulls.data (),outNulls} );
276+ m_logicalDevice->nullifyDescriptors ({ nulls.data (),outNulls }, range-> second . descriptorType );
265277
266278 // always call with the same parameters, otherwise this turns into a mess with the non invalid_address gaps
267279 unallocatedSize = try_multi_allocate (binding,count,outAddresses);
@@ -325,7 +337,9 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
325337 {
326338 core::vector<IGPUDescriptorSet::SDropDescriptorSet> nulls (count);
327339 auto actualEnd = multi_deallocate (nulls.data (), binding, count, addr);
328- m_logicalDevice->nullifyDescriptors ({nulls.data (),actualEnd});
340+ // This is checked to be valid above
341+ auto range = m_allocatableRanges.find (binding);
342+ m_logicalDevice->nullifyDescriptors ({nulls.data (),actualEnd}, range->second .descriptorType );
329343 }
330344 }
331345
@@ -340,8 +354,9 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
340354 {
341355 auto & it = m_allocatableRanges[i];
342356 frees += it.eventHandler .poll (outNulls).eventsLeft ;
357+ // TODO: this could be optimized to be put outside the loop
358+ m_logicalDevice->nullifyDescriptors ({nulls.data (),outNulls}, it.descriptorType );
343359 }
344- m_logicalDevice->nullifyDescriptors ({nulls.data (),outNulls});
345360 return frees;
346361 }
347362};
0 commit comments