Skip to content

Commit 28611be

Browse files
committed
Use pool address allocator
1 parent e1282c7 commit 28611be

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

include/nbl/video/alloc/SubAllocatedDescriptorSet.h

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
1717
public:
1818
// address allocator gives offsets
1919
// reserved allocator allocates memory to keep the address allocator state inside
20-
using AddressAllocator = core::GeneralpurposeAddressAllocator<uint32_t>;
20+
using AddressAllocator = core::PoolAddressAllocator<uint32_t>;
2121
using ReservedAllocator = core::allocator<uint8_t>;
2222
using size_type = typename AddressAllocator::size_type;
2323
using value_type = typename AddressAllocator::size_type;
@@ -102,16 +102,27 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
102102
// main methods
103103

104104
//! Warning `outAddresses` needs to be primed with `invalid_value` values, otherwise no allocation happens for elements not equal to `invalid_value`
105-
template<typename... Args>
106-
inline void multi_allocate(uint32_t binding, uint32_t count, value_type* outAddresses, const size_type* sizes, const Args&... args)
105+
inline void multi_allocate(uint32_t binding, uint32_t count, value_type* outAddresses)
107106
{
108-
core::address_allocator_traits<AddressAllocator>::multi_alloc_addr(getBindingAllocator(binding), count, outAddresses, sizes, 1, args...);
107+
auto& allocator = getBindingAllocator(binding);
108+
for (uint32_t i=0; i<count; i++)
109+
{
110+
if (outAddresses[i]!=AddressAllocator::invalid_address)
111+
continue;
112+
113+
outAddresses[i] = allocator.alloc_addr(1,1);
114+
}
109115
}
110-
inline void multi_deallocate(uint32_t binding, uint32_t count, const size_type* addr, const size_type* sizes)
116+
inline void multi_deallocate(uint32_t binding, uint32_t count, const size_type* addr)
111117
{
112-
auto& range = m_allocatableRanges[binding];
113-
assert(range.reservedSize); // Check if this binding has an allocator
114-
core::address_allocator_traits<AddressAllocator>::multi_free_addr(getBindingAllocator(binding), count, addr, sizes);
118+
auto& allocator = getBindingAllocator(binding);
119+
for (uint32_t i=0; i<count; i++)
120+
{
121+
if (addr[i]==AddressAllocator::invalid_address)
122+
continue;
123+
124+
allocator.free_addr(addr[i],1);
125+
}
115126
}
116127
};
117128

0 commit comments

Comments
 (0)