@@ -790,29 +790,34 @@ namespace nbl::ext::imgui
790
790
{
791
791
std::chrono::steady_clock::time_point timeout (std::chrono::seconds (0x45 ));
792
792
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 ());
794
794
795
- const bool ok = unallocatedSize == 0u ;
796
-
797
- if (!ok)
795
+ if (unallocatedSize != 0u )
798
796
{
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 ());
800
800
801
- auto getOffsetStr = [&]( const MDI::COMPOSE_T::value_type offset) -> std::string
801
+ if (unallocatedSize != 0u )
802
802
{
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
+ };
805
809
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 ());
809
813
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 ());
814
818
815
- exit (0x45 ); // TODO: handle OOB memory requests
819
+ exit (0x45 ); // TODO: handle OOB memory requests
820
+ }
816
821
}
817
822
}
818
823
@@ -966,9 +971,7 @@ namespace nbl::ext::imgui
966
971
}
967
972
968
973
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
972
975
}
973
976
974
977
return true ;
0 commit comments