From c76bc8995e566168f947e1266c996c8a742e8ab2 Mon Sep 17 00:00:00 2001 From: kevyuu Date: Wed, 27 Aug 2025 15:41:53 +0700 Subject: [PATCH 1/4] Fix nite --- tools/nite/main.cpp | 57 +++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/tools/nite/main.cpp b/tools/nite/main.cpp index af1db69278..30ebd6213b 100644 --- a/tools/nite/main.cpp +++ b/tools/nite/main.cpp @@ -6,8 +6,8 @@ #include #include "nbl/video/utilities/CSimpleResizeSurface.h" -#include "SimpleWindowedApplication.hpp" -#include "CEventCallback.hpp" +#include "nbl/examples/common/SimpleWindowedApplication.hpp" +#include "nbl/examples/common/CEventCallback.hpp" #include "nbl/ext/ImGui/ImGui.h" #include "nbl/ui/ICursorControl.h" @@ -39,6 +39,7 @@ class NITETool final : public examples::SimpleWindowedApplication static_assert(FRAMES_IN_FLIGHT > SC_IMG_COUNT); constexpr static inline clock_t::duration DisplayImageDuration = std::chrono::milliseconds(900); + constexpr static inline uint8_t MaxUITextureCount = 1u; public: inline NITETool(const path& _localInputCWD, const path& _localOutputCWD, const path& _sharedInputCWD, const path& _sharedOutputCWD) @@ -49,7 +50,7 @@ class NITETool final : public examples::SimpleWindowedApplication if (!m_surface) { { - auto windowCallback = core::make_smart_refctd_ptr(smart_refctd_ptr(m_inputSystem), smart_refctd_ptr(m_logger)); + auto windowCallback = core::make_smart_refctd_ptr(smart_refctd_ptr(m_inputSystem), smart_refctd_ptr(m_logger)); IWindow::SCreationParams params = {}; params.callback = core::make_smart_refctd_ptr(); params.width = WIN_W; @@ -107,7 +108,7 @@ class NITETool final : public examples::SimpleWindowedApplication const auto pModeArg = program.get(NBL_MODE_ARG.data()); const auto pGroupArg = program.get(NBL_GROUP_ARG.data()); - m_inputSystem = make_smart_refctd_ptr(logger_opt_smart_ptr(smart_refctd_ptr(m_logger))); + m_inputSystem = make_smart_refctd_ptr(logger_opt_smart_ptr(smart_refctd_ptr(m_logger))); if (!device_base_t::onAppInitialized(smart_refctd_ptr(m_system))) return false; @@ -157,7 +158,7 @@ class NITETool final : public examples::SimpleWindowedApplication if (!m_surface || !m_surface->init(gQueue, std::move(scResources), swapchainParams.sharedParams)) return logFail("Could not create Window & Surface or initialize the Surface!"); - m_maxFramesInFlight = m_surface->getMaxFramesInFlight(); + m_maxFramesInFlight = m_surface->getMaxAcquiresInFlight(); if (FRAMES_IN_FLIGHT < m_maxFramesInFlight) { m_logger->log("Lowering frames in flight!", ILogger::ELL_WARNING); @@ -174,17 +175,20 @@ class NITETool final : public examples::SimpleWindowedApplication return logFail("Couldn't create Command Buffer!"); } - ui.manager = core::make_smart_refctd_ptr - ( - nbl::ext::imgui::UI::S_CREATION_PARAMETERS - { - .assetManager = m_assetManager.get(), - .utilities = m_utils.get(), - .transfer = getTransferUpQueue(), - .renderpass = renderpass, - .subpassIx = 0u - } - ); + nbl::ext::imgui::UI::SCreationParameters params; + + params.resources.texturesInfo = { .setIx = 0u, .bindingIx = 0u }; + params.resources.samplersInfo = { .setIx = 0u, .bindingIx = 1u }; + params.assetManager = m_assetManager; + params.pipelineCache = nullptr; + params.pipelineLayout = nbl::ext::imgui::UI::createDefaultPipelineLayout(m_utils->getLogicalDevice(), params.resources.texturesInfo, params.resources.samplersInfo, MaxUITextureCount); + params.renderpass = smart_refctd_ptr(renderpass); + params.streamingBuffer = nullptr; + params.subpassIx = 0u; + params.transfer = getTransferUpQueue(); + params.utilities = m_utils; + + ui.manager = nbl::ext::imgui::UI::create(std::move(params)); { // note that we use default layout provided by our extension (textures & samplers -> single set at 0u ix) @@ -192,8 +196,8 @@ class NITETool final : public examples::SimpleWindowedApplication const auto& params = ui.manager->getCreationParameters(); IDescriptorPool::SCreateInfo descriptorPoolInfo = {}; - descriptorPoolInfo.maxDescriptorCount[static_cast(asset::IDescriptor::E_TYPE::ET_SAMPLER)] = params.resources.count; - descriptorPoolInfo.maxDescriptorCount[static_cast(asset::IDescriptor::E_TYPE::ET_SAMPLED_IMAGE)] = params.resources.count; + descriptorPoolInfo.maxDescriptorCount[static_cast(asset::IDescriptor::E_TYPE::ET_SAMPLER)] = params.resources.getSamplersCount(); + descriptorPoolInfo.maxDescriptorCount[static_cast(asset::IDescriptor::E_TYPE::ET_SAMPLED_IMAGE)] = params.resources.getTexturesCount(); descriptorPoolInfo.maxSets = 1u; descriptorPoolInfo.flags = IDescriptorPool::E_CREATE_FLAGS::ECF_UPDATE_AFTER_BIND_BIT; @@ -333,7 +337,7 @@ class NITETool final : public examples::SimpleWindowedApplication const auto uiParams = ui.manager->getCreationParameters(); auto* pipeline = ui.manager->getPipeline(); cb->bindGraphicsPipeline(pipeline); - cb->bindDescriptorSets(EPBP_GRAPHICS, pipeline->getLayout(), uiParams.resources.textures.setIx, 1u, &ui.descriptorSet.get()); // note that we use default UI pipeline layout where uiParams.resources.textures.setIx == uiParams.resources.samplers.setIx + cb->bindDescriptorSets(EPBP_GRAPHICS, pipeline->getLayout(), uiParams.resources.texturesInfo.setIx, 1u, &ui.descriptorSet.get()); // note that we use default UI pipeline layout where uiParams.resources.textures.setIx == uiParams.resources.samplers.setIx ui.manager->render(cb, waitInfo); cb->endRenderPass(); } @@ -470,15 +474,12 @@ class NITETool final : public examples::SimpleWindowedApplication const auto cursorPosition = m_window->getCursorControl()->getPosition(); - nbl::ext::imgui::UI::S_UPDATE_PARAMETERS params = + nbl::ext::imgui::UI::SUpdateParameters params = { .mousePosition = nbl::hlsl::float32_t2(cursorPosition.x, cursorPosition.y) - nbl::hlsl::float32_t2(m_window->getX(), m_window->getY()), .displaySize = { m_window->getWidth(), m_window->getHeight() }, - .events = - { - .mouse = core::SRange(capturedEvents.mouse.data(), capturedEvents.mouse.data() + capturedEvents.mouse.size()), - .keyboard = core::SRange(capturedEvents.keyboard.data(), capturedEvents.keyboard.data() + capturedEvents.keyboard.size()) - } + .mouseEvents = core::SRange(capturedEvents.mouse.data(), capturedEvents.mouse.data() + capturedEvents.mouse.size()), + .keyboardEvents = core::SRange(capturedEvents.keyboard.data(), capturedEvents.keyboard.data() + capturedEvents.keyboard.size()), }; ui.manager->update(params); @@ -502,9 +503,9 @@ class NITETool final : public examples::SimpleWindowedApplication } ui; smart_refctd_ptr m_assetManager; - core::smart_refctd_ptr m_inputSystem; - InputSystem::ChannelReader mouse; - InputSystem::ChannelReader keyboard; + core::smart_refctd_ptr m_inputSystem; + examples::InputSystem::ChannelReader mouse; + examples::InputSystem::ChannelReader keyboard; // Test engine ImGuiTestEngine* engine = nullptr; From 1ae9a5784ac734418b3f6718036a4a8120b225d3 Mon Sep 17 00:00:00 2001 From: kevyuu Date: Wed, 27 Aug 2025 15:44:04 +0700 Subject: [PATCH 2/4] public read access to texturesCount and samplersCount --- include/nbl/ext/ImGui/ImGui.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/nbl/ext/ImGui/ImGui.h b/include/nbl/ext/ImGui/ImGui.h index 244195c01a..5f3c1d5f08 100644 --- a/include/nbl/ext/ImGui/ImGui.h +++ b/include/nbl/ext/ImGui/ImGui.h @@ -48,6 +48,9 @@ class UI final : public core::IReferenceCounted //! required, fill the info to instruct the backend about the required UI resources SBindingInfo texturesInfo, samplersInfo; + uint32_t getTexturesCount() const { return texturesCount; } + uint32_t getSamplersCount() const { return samplersCount; } + private: uint32_t texturesCount = {}, samplersCount = {}; From 17d5a6d772214b9d1fbd2f8ca6f3b2b27592b86c Mon Sep 17 00:00:00 2001 From: kevyuu Date: Wed, 27 Aug 2025 18:29:11 +0700 Subject: [PATCH 3/4] Include nite in CI --- tools/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 57f66ad44b..b59ad2a18a 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -2,7 +2,7 @@ add_subdirectory(nsc) add_subdirectory(xxHash256) if(NBL_BUILD_IMGUI) - add_subdirectory(nite EXCLUDE_FROM_ALL) + add_subdirectory(nite) endif() NBL_ADJUST_FOLDERS(tools) \ No newline at end of file From d48cfaea1ab1d5060a8930656247bb643bda76ac Mon Sep 17 00:00:00 2001 From: kevyuu Date: Thu, 28 Aug 2025 15:34:37 +0700 Subject: [PATCH 4/4] Exclude nite from CI --- tools/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index b59ad2a18a..57f66ad44b 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -2,7 +2,7 @@ add_subdirectory(nsc) add_subdirectory(xxHash256) if(NBL_BUILD_IMGUI) - add_subdirectory(nite) + add_subdirectory(nite EXCLUDE_FROM_ALL) endif() NBL_ADJUST_FOLDERS(tools) \ No newline at end of file