Skip to content

Commit 46a5039

Browse files
committed
cull_frees with streaming buffer, handle failed allocation and make it work (Erfan thank you for help), update examples_tests submodule
1 parent 4fbf379 commit 46a5039

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

examples_tests

src/nbl/ext/ImGui/ImGui.cpp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -790,29 +790,34 @@ namespace nbl::ext::imgui
790790
{
791791
std::chrono::steady_clock::time_point timeout(std::chrono::seconds(0x45));
792792

793-
const size_t unallocatedSize = m_mdi.streamingTDBufferST->multi_allocate(timeout, MDI_ALLOCATION_COUNT, multiAllocParams.offsets.data(), multiAllocParams.byteSizes.data(), MDI_ALIGNMENTS.data());
793+
size_t unallocatedSize = m_mdi.streamingTDBufferST->multi_allocate(timeout, MDI_ALLOCATION_COUNT, multiAllocParams.offsets.data(), multiAllocParams.byteSizes.data(), MDI_ALIGNMENTS.data());
794794

795-
const bool ok = unallocatedSize == 0u;
796-
797-
if (!ok)
795+
if (unallocatedSize != 0u)
798796
{
799-
logger->log("Could not multi alloc mdi buffer!", system::ILogger::ELL_ERROR);
797+
// retry
798+
m_mdi.streamingTDBufferST->cull_frees();
799+
unallocatedSize = m_mdi.streamingTDBufferST->multi_allocate(timeout, MDI_ALLOCATION_COUNT, multiAllocParams.offsets.data(), multiAllocParams.byteSizes.data(), MDI_ALIGNMENTS.data());
800800

801-
auto getOffsetStr = [&](const MDI::COMPOSE_T::value_type offset) -> std::string
801+
if (unallocatedSize != 0u)
802802
{
803-
return offset == MDI::COMPOSE_T::invalid_value ? "invalid_value" : std::to_string(offset);
804-
};
803+
logger->log("Could not multi alloc mdi buffer!", system::ILogger::ELL_ERROR);
804+
805+
auto getOffsetStr = [&](const MDI::COMPOSE_T::value_type offset) -> std::string
806+
{
807+
return offset == MDI::COMPOSE_T::invalid_value ? "invalid_value" : std::to_string(offset);
808+
};
805809

806-
logger->log("[mdi streaming buffer] = \"%s\" bytes", system::ILogger::ELL_ERROR, std::to_string(mdiBuffer->getSize()).c_str());
807-
logger->log("[requested] = \"%s\" bytes", system::ILogger::ELL_ERROR, std::to_string(mdiBufferByteSize).c_str());
808-
logger->log("[unallocated] = \"%s\" bytes", system::ILogger::ELL_ERROR, std::to_string(unallocatedSize).c_str());
810+
logger->log("[mdi streaming buffer] = \"%s\" bytes", system::ILogger::ELL_ERROR, std::to_string(mdiBuffer->getSize()).c_str());
811+
logger->log("[requested] = \"%s\" bytes", system::ILogger::ELL_ERROR, std::to_string(mdiBufferByteSize).c_str());
812+
logger->log("[unallocated] = \"%s\" bytes", system::ILogger::ELL_ERROR, std::to_string(unallocatedSize).c_str());
809813

810-
logger->log("[MDI::EBC_DRAW_INDIRECT_STRUCTURES offset] = \"%s\" bytes", system::ILogger::ELL_ERROR, getOffsetStr(multiAllocParams.offsets[MDI::EBC_DRAW_INDIRECT_STRUCTURES]).c_str());
811-
logger->log("[MDI::EBC_ELEMENT_STRUCTURES offset] = \"%s\" bytes", system::ILogger::ELL_ERROR, getOffsetStr(multiAllocParams.offsets[MDI::EBC_ELEMENT_STRUCTURES]).c_str());
812-
logger->log("[MDI::EBC_INDEX_BUFFERS offset] = \"%s\" bytes", system::ILogger::ELL_ERROR, getOffsetStr(multiAllocParams.offsets[MDI::EBC_INDEX_BUFFERS]).c_str());
813-
logger->log("[MDI::EBC_VERTEX_BUFFERS offset] = \"%s\" bytes", system::ILogger::ELL_ERROR, getOffsetStr(multiAllocParams.offsets[MDI::EBC_VERTEX_BUFFERS]).c_str());
814+
logger->log("[MDI::EBC_DRAW_INDIRECT_STRUCTURES offset] = \"%s\" bytes", system::ILogger::ELL_ERROR, getOffsetStr(multiAllocParams.offsets[MDI::EBC_DRAW_INDIRECT_STRUCTURES]).c_str());
815+
logger->log("[MDI::EBC_ELEMENT_STRUCTURES offset] = \"%s\" bytes", system::ILogger::ELL_ERROR, getOffsetStr(multiAllocParams.offsets[MDI::EBC_ELEMENT_STRUCTURES]).c_str());
816+
logger->log("[MDI::EBC_INDEX_BUFFERS offset] = \"%s\" bytes", system::ILogger::ELL_ERROR, getOffsetStr(multiAllocParams.offsets[MDI::EBC_INDEX_BUFFERS]).c_str());
817+
logger->log("[MDI::EBC_VERTEX_BUFFERS offset] = \"%s\" bytes", system::ILogger::ELL_ERROR, getOffsetStr(multiAllocParams.offsets[MDI::EBC_VERTEX_BUFFERS]).c_str());
814818

815-
exit(0x45); // TODO: handle OOB memory requests
819+
exit(0x45); // TODO: handle OOB memory requests
820+
}
816821
}
817822
}
818823

@@ -966,9 +971,7 @@ namespace nbl::ext::imgui
966971
}
967972

968973
auto waitInfo = info.getFutureScratchSemaphore();
969-
//logger->log("wait info semaphore value for deferred free latch \"%s\"", nbl::system::ILogger::ELL_PERFORMANCE, std::to_string(waitInfo.value).c_str());
970-
971-
m_mdi.streamingTDBufferST->multi_deallocate(MDI_ALLOCATION_COUNT, multiAllocParams.offsets.data(), multiAllocParams.byteSizes.data(), waitInfo); // TODO: why does it not free my offsets with deferred latch free?
974+
m_mdi.streamingTDBufferST->multi_deallocate(MDI_ALLOCATION_COUNT, multiAllocParams.offsets.data(), multiAllocParams.byteSizes.data(), waitInfo); // at some point a block would be needed anyway, cull frees but where? - so I just retry on failed allocation then cull free
972975
}
973976

974977
return true;

0 commit comments

Comments
 (0)