Skip to content

Commit 46c78a8

Browse files
committed
add UI streaming buffer const getter, extra cull frees call, correct some typos, add comments & update examples_tests submodule
1 parent 46a5039 commit 46c78a8

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

examples_tests

include/nbl/ext/ImGui/ImGui.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ class UI final : public core::IReferenceCounted
1919
void update(float deltaTimeInSec, const nbl::hlsl::float32_t2 mousePosition, const core::SRange<const nbl::ui::SMouseEvent> mouseEvents, const core::SRange<const nbl::ui::SKeyboardEvent> keyboardEvents);
2020
int registerListener(std::function<void()> const& listener);
2121
bool unregisterListener(uint32_t id);
22+
void setContext(void* imguiContext);
23+
2224
inline nbl::core::smart_refctd_ptr<nbl::video::IGPUImageView> getFontAtlasView() { return m_fontAtlasTexture; }
23-
25+
inline auto getStreamingBuffer() -> decltype(auto) { return (std::as_const(m_mdi.streamingTDBufferST)); }
2426
void* getContext();
25-
void setContext(void* imguiContext);
2627

2728
private:
2829
void createPipeline(core::smart_refctd_ptr<video::IGPUDescriptorSetLayout> descriptorSetLayout, video::IGPURenderpass* renderpass, video::IGPUPipelineCache* pipelineCache);

src/nbl/ext/ImGui/ImGui.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ namespace nbl::ext::imgui
761761
}();
762762

763763
static constexpr auto MDI_ALLOCATION_COUNT = MDI::EBC_COUNT;
764-
static auto MDI_ALIGNMENTS = std::to_array<typename MDI::COMPOSE_T::size_type, MDI_ALLOCATION_COUNT>({ alignof(VkDrawIndexedIndirectCommand), alignof(PerObjectData), alignof(ImDrawIdx), alignof(ImDrawVert) });
764+
static constexpr auto MDI_ALIGNMENTS = std::to_array<typename MDI::COMPOSE_T::size_type, MDI_ALLOCATION_COUNT>({ alignof(VkDrawIndexedIndirectCommand), alignof(PerObjectData), alignof(ImDrawIdx), alignof(ImDrawVert) });
765765

766766
struct MULTI_ALLOC_PARAMS
767767
{
@@ -794,7 +794,7 @@ namespace nbl::ext::imgui
794794

795795
if (unallocatedSize != 0u)
796796
{
797-
// retry
797+
// retry & cull frees
798798
m_mdi.streamingTDBufferST->cull_frees();
799799
unallocatedSize = m_mdi.streamingTDBufferST->multi_allocate(timeout, MDI_ALLOCATION_COUNT, multiAllocParams.offsets.data(), multiAllocParams.byteSizes.data(), MDI_ALIGNMENTS.data());
800800

@@ -816,7 +816,7 @@ namespace nbl::ext::imgui
816816
logger->log("[MDI::EBC_INDEX_BUFFERS offset] = \"%s\" bytes", system::ILogger::ELL_ERROR, getOffsetStr(multiAllocParams.offsets[MDI::EBC_INDEX_BUFFERS]).c_str());
817817
logger->log("[MDI::EBC_VERTEX_BUFFERS offset] = \"%s\" bytes", system::ILogger::ELL_ERROR, getOffsetStr(multiAllocParams.offsets[MDI::EBC_VERTEX_BUFFERS]).c_str());
818818

819-
exit(0x45); // TODO: handle OOB memory requests
819+
exit(0x45); // TODO: handle OOB memory requests, probably need to extend the mdi buffer/let user pass more size at init
820820
}
821821
}
822822
}
@@ -971,8 +971,10 @@ namespace nbl::ext::imgui
971971
}
972972

973973
auto waitInfo = info.getFutureScratchSemaphore();
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
974+
m_mdi.streamingTDBufferST->multi_deallocate(MDI_ALLOCATION_COUNT, multiAllocParams.offsets.data(), multiAllocParams.byteSizes.data(), waitInfo);
975975
}
976+
977+
m_mdi.streamingTDBufferST->cull_frees();
976978

977979
return true;
978980
}

0 commit comments

Comments
 (0)