Skip to content

Commit 738ba75

Browse files
committed
fix bug with multi allocation timeout, call multi_deallocate right after multi_allocate, don't try to map MDI memory range in case its unmapped at .render
1 parent 1f19c37 commit 738ba75

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/nbl/ext/ImGui/ImGui.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ namespace nbl::ext::imgui
816816

817817
auto mdiBuffer = smart_refctd_ptr<IGPUBuffer>(m_mdi.streamingTDBufferST->getBuffer());
818818
{
819-
std::chrono::steady_clock::time_point timeout(std::chrono::seconds(0x45));
819+
auto timeout(std::chrono::steady_clock::now() + std::chrono::seconds(1u));
820820

821821
size_t unallocatedSize = m_mdi.streamingTDBufferST->multi_allocate(timeout, MDI_ALLOCATION_COUNT, multiAllocParams.offsets.data(), multiAllocParams.byteSizes.data(), MDI_ALIGNMENTS.data());
822822

@@ -846,16 +846,14 @@ namespace nbl::ext::imgui
846846
exit(0x45); // TODO: handle OOB memory requests, probably need to extend the mdi buffer/let user pass more size at init
847847
}
848848
}
849+
850+
auto waitInfo = info.getFutureScratchSemaphore();
851+
m_mdi.streamingTDBufferST->multi_deallocate(MDI_ALLOCATION_COUNT, multiAllocParams.offsets.data(), multiAllocParams.byteSizes.data(), waitInfo);
849852
}
850853

851854
const uint32_t drawCount = multiAllocParams.byteSizes[MDI::EBC_DRAW_INDIRECT_STRUCTURES] / sizeof(VkDrawIndexedIndirectCommand);
852855
{
853856
auto binding = mdiBuffer->getBoundMemory();
854-
855-
if(!binding.memory->isCurrentlyMapped())
856-
if (!binding.memory->map({ 0ull, binding.memory->getAllocationSize() }, IDeviceMemoryAllocation::EMCAF_READ))
857-
logger->log("Could not map device memory!", system::ILogger::ELL_WARNING);
858-
859857
assert(binding.memory->isCurrentlyMapped());
860858

861859
auto* const indirectsMappedPointer = reinterpret_cast<VkDrawIndexedIndirectCommand*>(reinterpret_cast<uint8_t*>(m_mdi.streamingTDBufferST->getBufferPointer()) + multiAllocParams.offsets[MDI::EBC_DRAW_INDIRECT_STRUCTURES]);
@@ -996,9 +994,6 @@ namespace nbl::ext::imgui
996994
// TODO: handle them?
997995
exit(0x45);
998996
}
999-
1000-
auto waitInfo = info.getFutureScratchSemaphore();
1001-
m_mdi.streamingTDBufferST->multi_deallocate(MDI_ALLOCATION_COUNT, multiAllocParams.offsets.data(), multiAllocParams.byteSizes.data(), waitInfo);
1002997
}
1003998

1004999
return true;

0 commit comments

Comments
 (0)