Skip to content

Commit fe79eaf

Browse files
committed
remove system creation from the UI, take everything it requires from the constructor, do also another clean-up, put stuff into nice creation parameters struct, remove unnecessary font adjusting static method + a few IO variables we were setting to their default values anyway, add more comments for users, update examples_tests submodule
1 parent 2df883e commit fe79eaf

File tree

3 files changed

+99
-161
lines changed

3 files changed

+99
-161
lines changed

examples_tests

include/nbl/ext/ImGui/ImGui.h

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,18 @@ class UI final : public core::IReferenceCounted
2222
EBC_COUNT,
2323
};
2424

25-
nbl::core::smart_refctd_ptr<typename COMPOSE_T> streamingTDBufferST; // composed buffer layout is [EBC_DRAW_INDIRECT_STRUCTURES] [EBC_ELEMENT_STRUCTURES] [EBC_INDEX_BUFFERS] [EBC_VERTEX_BUFFERS]
25+
nbl::core::smart_refctd_ptr<typename COMPOSE_T> streamingTDBufferST; //! composed buffer layout is [EBC_DRAW_INDIRECT_STRUCTURES] [EBC_ELEMENT_STRUCTURES] [EBC_INDEX_BUFFERS] [EBC_VERTEX_BUFFERS]
26+
};
27+
28+
struct S_CREATION_PARAMETERS
29+
{
30+
video::IUtilities* const utilities; //! required
31+
video::IQueue* const transfer; //! required
32+
video::IGPURenderpass* const renderpass; //! required
33+
uint32_t subpassIx = 0u; //! optional, default value if not provided
34+
video::IGPUDescriptorSetLayout* const descriptorSetLayout = nullptr; //! optional, default layout used if not provided [STILL TODO, currently its assumed its not nullptr!]
35+
video::IGPUPipelineCache* const pipelineCache = nullptr; //! optional, no cache used if not provided
36+
typename MDI::COMPOSE_T* const streamingMDIBuffer = nullptr; //! optional, default MDI buffer allocated if not provided
2637
};
2738

2839
//! parameters which may change every frame, used with the .update call to interact with ImGuiIO; we require a very *required* minimum - if you need to cover more IO options simply get the IO with ImGui::GetIO() to customize them (they all have default values you can change before calling the .update)
@@ -44,17 +55,17 @@ class UI final : public core::IReferenceCounted
4455
S_EVENTS events;
4556
};
4657

47-
UI(core::smart_refctd_ptr<video::ILogicalDevice> _device, core::smart_refctd_ptr<video::IGPUDescriptorSetLayout> _descriptorSetLayout, video::IGPURenderpass* renderpass, uint32_t subpassIx, video::IGPUPipelineCache* pipelineCache = nullptr, nbl::core::smart_refctd_ptr<typename MDI::COMPOSE_T> _streamingMDIBuffer = nullptr);
58+
UI(S_CREATION_PARAMETERS&& params);
4859
~UI() override;
4960

5061
//! Nabla ImGUI backend reserves this index for font atlas, any attempt to hook user defined texture within the index will cause runtime error [TODO: could have a setter & getter to control the default & currently hooked font texture ID and init 0u by default]
5162
_NBL_STATIC_INLINE_CONSTEXPR auto NBL_FONT_ATLAS_TEX_ID = 0u;
5263

5364
//! update ImGuiIO & record ImGUI *cpu* draw command lists, call it before .render
54-
bool update(const S_UPDATE_PARAMETERS params);
65+
bool update(const S_UPDATE_PARAMETERS& params);
5566

5667
//! updates mapped mdi buffer & records *gpu* draw commands, handles overflows for mdi allocation failure cases (pop & submit)
57-
bool render(nbl::video::SIntendedSubmitInfo& info, const nbl::video::IGPUDescriptorSet* const descriptorSet);
68+
bool render(nbl::video::SIntendedSubmitInfo& info, const nbl::video::IGPUDescriptorSet* const descriptorSet, const std::span<const VkRect2D> scissors = {});
5869

5970
//! registers lambda listener in which ImGUI calls should be recorded
6071
size_t registerListener(std::function<void()> const& listener);
@@ -72,17 +83,13 @@ class UI final : public core::IReferenceCounted
7283
//! ImGUI context getter, you are supposed to cast it, eg. reinterpret_cast<ImGuiContext*>(this->getContext());
7384
void* getContext();
7485
private:
75-
void createSystem();
76-
void createPipeline(core::smart_refctd_ptr<video::IGPUDescriptorSetLayout> descriptorSetLayout, video::IGPURenderpass* renderpass, uint32_t subpassIx, video::IGPUPipelineCache* pipelineCache);
77-
void createMDIBuffer(nbl::core::smart_refctd_ptr<typename MDI::COMPOSE_T> _streamingMDIBuffer);
78-
video::ISemaphore::future_t<video::IQueue::RESULT> createFontAtlasTexture(video::IGPUCommandBuffer* cmdBuffer, video::IQueue* queue);
79-
void handleMouseEvents(const core::SRange<const nbl::ui::SMouseEvent>& events, nbl::hlsl::float32_t2 mousePosition) const;
80-
void handleKeyEvents(const core::SRange<const nbl::ui::SKeyboardEvent>& events) const;
81-
82-
core::smart_refctd_ptr<system::ISystem> system;
83-
core::smart_refctd_ptr<system::ILogger> logger;
84-
core::smart_refctd_ptr<video::IUtilities> utilities;
85-
core::smart_refctd_ptr<video::ILogicalDevice> m_device;
86+
void createPipeline();
87+
void createMDIBuffer();
88+
void handleMouseEvents(const S_UPDATE_PARAMETERS& params) const;
89+
void handleKeyEvents(const S_UPDATE_PARAMETERS& params) const;
90+
video::ISemaphore::future_t<video::IQueue::RESULT> createFontAtlasTexture(video::IGPUCommandBuffer* cmdBuffer);
91+
92+
S_CREATION_PARAMETERS m_creationParams;
8693

8794
core::smart_refctd_ptr<video::IGPUGraphicsPipeline> pipeline;
8895
core::smart_refctd_ptr<video::IGPUImageView> m_fontAtlasTexture;

0 commit comments

Comments
 (0)