Skip to content

Commit b8db8c9

Browse files
committed
Work on sub allocated descriptor set
1 parent ef4b779 commit b8db8c9

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

include/nbl/core/alloc/address_allocator_traits.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ namespace nbl::core
5353
}
5454
}
5555

56+
static inline void multi_alloc_addr(AddressAlloc& alloc, uint32_t count, size_type* outAddresses, const size_type* bytes,
57+
const size_type alignment, const size_type* hint=nullptr) noexcept
58+
{
59+
for (uint32_t i=0; i<count; i++)
60+
{
61+
if (outAddresses[i]!=AddressAlloc::invalid_address)
62+
continue;
63+
64+
outAddresses[i] = alloc.alloc_addr(bytes[i],alignment,hint ? hint[i]:0ull);
65+
}
66+
}
67+
5668
static inline void multi_free_addr(AddressAlloc& alloc, uint32_t count, const size_type* addr, const size_type* bytes) noexcept
5769
{
5870
for (uint32_t i=0; i<count; i++)
@@ -186,6 +198,14 @@ namespace nbl::core
186198
alloc,std::min(count-i,maxMultiOps),outAddresses+i,bytes+i,alignment+i,hint ? (hint+i):nullptr);
187199
}
188200

201+
static inline void multi_alloc_addr(AddressAlloc& alloc, uint32_t count, size_type* outAddresses,
202+
const size_type* bytes, const size_type alignment, const size_type* hint=nullptr) noexcept
203+
{
204+
for (uint32_t i=0; i<count; i+=maxMultiOps)
205+
impl::address_allocator_traits_base<AddressAlloc,has_func_multi_alloc_addr<AddressAlloc>::value>::multi_alloc_addr(
206+
alloc,std::min(count-i,maxMultiOps),outAddresses+i,bytes+i,alignment,hint ? (hint+i):nullptr);
207+
}
208+
189209
static inline void multi_free_addr(AddressAlloc& alloc, uint32_t count, const size_type* addr, const size_type* bytes) noexcept
190210
{
191211
for (uint32_t i=0; i<count; i+=maxMultiOps)

include/nbl/video/alloc/SubAllocatedDescriptorSet.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
4949

5050
m_addressAllocator = AddrAllocator(
5151
_reservedAllocator.allocate(AddressAllocator::reserved_size(maxAllocatableAlignment, static_cast<size_type>(allocatableDescriptors), args...), _NBL_SIMD_ALIGNMENT),
52-
static_cast<size_type>(allocatableDescriptors), 0u, maxAllocatableAlignment, static_cast<size_type>(allocatableDescriptors), std::forward<Args>(args)...
52+
static_cast<size_type>(0), 0u, maxAllocatableAlignment, static_cast<size_type>(allocatableDescriptors), std::forward<Args>(args)...
5353
);
5454
m_reservedAllocator = ReservedAllocator(std::move(_reservedAllocator));
5555
m_reservedSize = allocatableDescriptors;
@@ -77,14 +77,13 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
7777

7878
//! Warning `outAddresses` needs to be primed with `invalid_value` values, otherwise no allocation happens for elements not equal to `invalid_value`
7979
template<typename... Args>
80-
inline void multi_allocate(uint32_t count, value_type* outAddresses, const size_type* byteSizes, const size_type* alignments, const Args&... args)
80+
inline void multi_allocate(uint32_t count, value_type* outAddresses, const size_type* sizes, const Args&... args)
8181
{
82-
core::address_allocator_traits<AddressAllocator>::multi_alloc_addr(m_addressAllocator,count,outAddresses,byteSizes,alignments,args...);
82+
core::address_allocator_traits<AddressAllocator>::multi_alloc_addr(m_addressAllocator,count,outAddresses,sizes,1,args...);
8383
}
84-
template<typename... Args>
85-
inline void multi_deallocate(Args&&... args)
84+
inline void multi_deallocate(uint32_t count, const size_type* addr, const size_type* sizes)
8685
{
87-
core::address_allocator_traits<AddressAllocator>::multi_free_addr(m_addressAllocator,std::forward<Args>(args)...);
86+
core::address_allocator_traits<AddressAllocator>::multi_free_addr(m_addressAllocator,count,addr,sizes);
8887
}
8988

9089
// to conform to IBufferAllocator concept

0 commit comments

Comments
 (0)