You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it had to be my previous streaming buffer *which uses general purpose under the hood* as it was but with linear suballocator & more clever block upstream loop; update the code, make it work
Copy file name to clipboardExpand all lines: include/nbl/ext/ImGui/ImGui.h
+2-7Lines changed: 2 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -11,8 +11,7 @@ class UI final : public core::IReferenceCounted
11
11
public:
12
12
structMDI
13
13
{
14
-
using COMPOSE_T = nbl::video::IGPUBuffer; //! composes memory available for the allocator which allocates submemory ranges
15
-
using ALLOCATOR_TRAITS_T = nbl::core::address_allocator_traits<nbl::core::GeneralpurposeAddressAllocator<uint32_t>>; //! traits for MDI buffer allocator - requests memory range from the compose memory
14
+
using COMPOSE_T = nbl::video::StreamingTransientDataBufferST<nbl::core::allocator<uint8_t>>; //! composes memory available for the general purpose allocator to suballocate memory ranges
16
15
using SUBALLOCATOR_TRAITS_T = nbl::core::address_allocator_traits<nbl::core::LinearAddressAllocatorST<uint32_t>>; //! traits for MDI buffer suballocator - fills the data given the mdi allocator memory request
17
16
18
17
enum E_BUFFER_CONTENT : uint8_t
@@ -25,7 +24,6 @@ class UI final : public core::IReferenceCounted
@@ -93,7 +91,7 @@ class UI final : public core::IReferenceCounted
93
91
boolupdate(const S_UPDATE_PARAMETERS& params);
94
92
95
93
//! updates mapped mdi buffer & records *gpu* draw command, you are required to bind UI's graphics pipeline & descriptor sets before calling this function - use getPipeline() to get the pipeline & getCreationParameters() to get info about your set resources
std::make_pair(buffer->getCreationParams().usage.hasFlags(MDI::MDI_BUFFER_REQUIRED_USAGE_FLAGS), "MDI buffer must be created with IBuffer::EUF_INDIRECT_BUFFER_BIT | IBuffer::EUF_INDEX_BUFFER_BIT | IBuffer::EUF_VERTEX_BUFFER_BIT | IBuffer::EUF_SHADER_DEVICE_ADDRESS_BIT enabled!"),
requestState.multiAllocationSize = m_mdi.allocator.max_size(); // first we will try with single allocation request given max free block size from the allocator
1040
1034
1041
1035
//! we must upload entire MDI buffer data to our streaming buffer, but we cannot guarantee allocation can be done in single request
1042
-
for (typename MDI::ALLOCATOR_TRAITS_T::size_type uploadedSize = 0ull; uploadedSize < mdiParams.totalByteSizeRequest;)
1036
+
for (MDI_SIZE_TYPE uploadedSize = 0ull; uploadedSize < mdiParams.totalByteSizeRequest;)
1043
1037
{
1044
1038
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start);
constsize_t unallocatedSize = m_mdi.buffer->multi_allocate(std::chrono::steady_clock::now() + std::chrono::microseconds(100u), STREAMING_ALLOCATION_COUNT, &requestState.offset, &requestState.multiAllocationSize, &MDI_MAX_ALIGNMENT); //! (*) note we request single tight chunk of memory with max alignment instead of MDI::E_BUFFER_CONTENT separate chunks
1051
+
1052
+
if (requestState.offset == INVALID_ADDRESS)
1053
+
continue; // failed? lets try again, TODO: should I here have my "blockMemoryFactor =* 0.5" and apply to requestState.multiAllocationSize?
MDI::SUBALLOCATOR_TRAITS_T::allocator_type fillSubAllocator(mdiData, requestState.offset, ALIGN_OFFSET_NEEDED, MDI_MAX_ALIGNMENT, requestState.multiAllocationSize);//! (*) we create linear suballocator to fill the chunk memory (some of at least) with MDI::E_BUFFER_CONTENT data
MDI::SUBALLOCATOR_TRAITS_T::multi_alloc_addr(fillSubAllocator, offsets.size(), offsets.data(), mdiParams.bytesToFill.data(), MDI_ALIGNMENTS.data());//! (*) we suballocate memory regions from the allocated chunk with required alignment per MDI::E_BUFFER_CONTENT block
1067
1062
1068
1063
//! linear allocator is used to fill the mdi data within suballocation memory range,
1069
1064
//! there are a few restrictions regarding how MDI::E_BUFFER_CONTENT(s) can be packed,
@@ -1073,9 +1068,9 @@ namespace nbl::ext::imgui
1073
1068
1074
1069
auto fillDrawBuffers = [&]<MDI::E_BUFFER_CONTENT type>()
streamingBuffer->multi_deallocate(STREAMING_ALLOCATION_COUNT, &requestState.offset, &requestState.multiAllocationSize, waitInfo); //! (*) block allocated, we just latch offsets deallocation to keep it alive as long as required
1177
1171
}
1178
1172
}
1179
1173
1180
1174
assert([&mdiOffsets]() -> bool
1181
1175
{
1182
1176
for (constauto& offset : mdiOffsets)
1183
-
if (offset == MDI::ALLOCATOR_TRAITS_T::allocator_type::invalid_address)
1177
+
if (offset == INVALID_ADDRESS)
1184
1178
returnfalse; // we should never hit this at this point
1185
1179
1186
1180
returntrue;
1187
1181
}()); // debug check only
1188
1182
1183
+
auto mdiBuffer = smart_refctd_ptr<IGPUBuffer>(m_mdi.buffer->getBuffer());
0 commit comments