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
// those must be allocated within single block for content - even though its possible to tell vkCmdDrawIndexedIndirect about stride we cannot guarantee each one will be the same size with our allocation strategy
37
36
enumclassTightContent : uint16_t
@@ -1151,46 +1150,53 @@ namespace nbl::ext::imgui
1151
1150
for (mdi_size_t uploadedSize = 0ull; uploadedSize < mdiLimits.totalByteSizeRequest;)
1152
1151
{
1153
1152
bigChunkRequestState.offset = InvalidAddress;
1154
-
bigChunkRequestState.size = streamingBuffer->max_size(); //request available block memory size which we can try to allocate
1153
+
bigChunkRequestState.size = streamingBuffer->max_size(); //TODO: divide by 2 request strategy on fail
1155
1154
1156
1155
constexprauto StreamingAllocationCount = 1u;
1157
1156
constsize_t unallocatedSize = m_mdi.compose->multi_allocate(std::chrono::steady_clock::now() + std::chrono::microseconds(100u), StreamingAllocationCount, &bigChunkRequestState.offset, &bigChunkRequestState.size, &MdiMaxAlignment); //! (*) note we request single tight chunk of memory with fixed max alignment - big address space from which we fill try to suballocate to fill data
1158
1157
1159
1158
if (bigChunkRequestState.offset == InvalidAddress)
1160
-
continue;// failed? lets try again, TODO: should I here have my "blockMemoryFactor =* 0.5" and apply to bigChunkRequestState.size?
1159
+
continue;
1161
1160
else
1162
1161
{
1163
-
constexprautoAlignOffsetNeeded = 0u;
1164
-
SMdiBuffer::suballocator_traits_t::allocator_type fillSubAllocator(mdiData, bigChunkRequestState.offset, AlignOffsetNeeded, 32u/* we care about vertex struct which is MdiMaxSize (20) bytes */, bigChunkRequestState.size); //! (*) we create linear suballocator to fill the allocated chunk of memory (some of at least)
SMdiBuffer::suballocator_traits_t::allocator_type fillSubAllocator(mdiData, bigChunkRequestState.offset, alignOffsetNeeded, MdiMaxAlignment, bigChunkRequestState.size); //! (*) we create linear suballocator to fill the allocated chunk of memory (some of at least)
1165
1164
SMdiBuffer::suballocator_traits_t::multi_alloc_addr(fillSubAllocator, allocation.offsets.size(), allocation.offsets.data(), mdiLimits.sizes.data(), mdiLimits.alignments.data()); //! (*) we suballocate memory regions from the allocated chunk with required alignments - multi request all with single traits call
1166
1165
1167
1166
auto upload = [&]() -> size_t
1168
1167
{
1169
1168
size_t uploaded = {};
1170
1169
1171
-
// they are very small & negligible in size compared to buffers, but this small pool which we will conditionally fill on successfull object buffer suballocations is required to not complicate things (if we cannot allocate all mdiLimits.totalIndirectDrawCount object buffers then simply those coresponding structures wont be filled, we treat both components as arrays)
1170
+
auto updateSuballocation = [&](constuint32_t allocationIx) -> size_t
// they are very small & negligible in size compared to buffers, but this small pool which we will conditionally fill on successfull object buffer suballocations is required to not complicate things (if we cannot allocate all mdiLimits.totalIndirectDrawCount object buffers then simply those coresponding structures will be filled with dummy params making it an invocation with 0u indices, we treat both components as arrays)
allocation.filled[(uint32_t)TightContent::INDIRECT_STRUCTURES] = true; // I make a assumption here since I can access them later - but I don't guarantee all of them will be present since we can fail other suballocations which are required for the struct, note that in reality we fill them below & conditionally
1183
-
}
1184
-
1185
-
if (!allocation.filled[(uint32_t)TightContent::ELEMENT_STRUCTURES])
allocation.filled[(uint32_t)TightContent::ELEMENT_STRUCTURES] = true; // I make a assumption here since I can access them later - but I don't guarantee all of them will be present since we can fail other suballocations which are required for the struct, note that in reality we fill them below & conditionally
1189
-
}
1192
+
// I make a assumption here since I can access them later but I don't guarantee all of them will be present,
1193
+
// we can fail other suballocations which are required for the struct, note that in reality we fill them below & conditionally
for (uint32_t j = 0; j < commandList->CmdBuffer.Size; j++)
1243
+
1244
+
for (uint32_t j = 0u; j < commandList->CmdBuffer.Size; j++)
1231
1245
{
1232
1246
constauto* cmd = &commandList->CmdBuffer[j];
1233
1247
auto* indirect = indirectStructures + drawID;
1234
1248
auto* element = elementStructures + drawID;
1235
1249
1236
-
// we will make a trick to keep indirect & element structs in the mdi iteration but explicitly execute dummy null invocation if we don't have vertex or index buffer for the struct (suballocation failed for any of those 2 buffers).
1250
+
// we make a trick to keep indirect & element structs in the mdi iteration but explicitly execute dummy null invocation if we don't have vertex or index buffer for the struct (suballocation failed for any of those 2 buffers).
1237
1251
// TODO: we could make the current structs pool "dynamic" in size and treat as simple stack instead (trying it first to make things easier)
// starting to wonder, for some reason imgui decided to keep single vertex & index shared between cmds within cmd list
1244
1258
// but maybe we should cut current [vertexBuffer, indexBuffer] with respect to cmd->IdxOffset & cmd->VtxOffset (therefore we could have even smaller alloc requests, now a few structs can point to the same buffer but with different offsets [indirect])
1245
-
// though not sure if I don't double some data then
1259
+
// though not sure if I don't double some data then <- EDIT: YES, turns out we may double some data
1246
1260
indirect->vertexOffset = vtxGlobalObjectOffset + cmd->VtxOffset; // safe to assume due to indirect->indexCount depending on buffersSuballocated
1247
1261
indirect->firstIndex = idxGlobalObjectOffset + cmd->IdxOffset; // safe to assume due to indirect->indexCount depending on buffersSuballocated
1248
1262
@@ -1272,15 +1286,14 @@ namespace nbl::ext::imgui
1272
1286
}
1273
1287
}
1274
1288
}
1275
-
1276
1289
return uploaded;
1277
1290
};
1278
1291
1279
1292
uploadedSize += upload();
1280
1293
}
1281
1294
streamingBuffer->multi_deallocate(StreamingAllocationCount, &bigChunkRequestState.offset, &bigChunkRequestState.size, waitInfo); //! (*) block allocated, we just latch offsets deallocation to keep it alive as long as required
0 commit comments