6
6
#include < nabla.h>
7
7
#include " nbl/video/utilities/CSimpleResizeSurface.h"
8
8
9
- #include " SimpleWindowedApplication.hpp"
10
- #include " CEventCallback.hpp"
9
+ #include " nbl/examples/common/ SimpleWindowedApplication.hpp"
10
+ #include " nbl/examples/common/ CEventCallback.hpp"
11
11
12
12
#include " nbl/ext/ImGui/ImGui.h"
13
13
#include " nbl/ui/ICursorControl.h"
@@ -39,6 +39,7 @@ class NITETool final : public examples::SimpleWindowedApplication
39
39
static_assert (FRAMES_IN_FLIGHT > SC_IMG_COUNT);
40
40
41
41
constexpr static inline clock_t ::duration DisplayImageDuration = std::chrono::milliseconds(900 );
42
+ constexpr static inline uint8_t MaxUITextureCount = 1u ;
42
43
43
44
public:
44
45
inline NITETool (const path& _localInputCWD, const path& _localOutputCWD, const path& _sharedInputCWD, const path& _sharedOutputCWD)
@@ -49,7 +50,7 @@ class NITETool final : public examples::SimpleWindowedApplication
49
50
if (!m_surface)
50
51
{
51
52
{
52
- auto windowCallback = core::make_smart_refctd_ptr<CEventCallback>(smart_refctd_ptr (m_inputSystem), smart_refctd_ptr (m_logger));
53
+ auto windowCallback = core::make_smart_refctd_ptr<examples:: CEventCallback>(smart_refctd_ptr (m_inputSystem), smart_refctd_ptr (m_logger));
53
54
IWindow::SCreationParams params = {};
54
55
params.callback = core::make_smart_refctd_ptr<nbl::video::ISimpleManagedSurface::ICallback>();
55
56
params.width = WIN_W;
@@ -107,7 +108,7 @@ class NITETool final : public examples::SimpleWindowedApplication
107
108
const auto pModeArg = program.get <std::string>(NBL_MODE_ARG.data ());
108
109
const auto pGroupArg = program.get <std::string>(NBL_GROUP_ARG.data ());
109
110
110
- m_inputSystem = make_smart_refctd_ptr<InputSystem>(logger_opt_smart_ptr (smart_refctd_ptr (m_logger)));
111
+ m_inputSystem = make_smart_refctd_ptr<examples:: InputSystem>(logger_opt_smart_ptr (smart_refctd_ptr (m_logger)));
111
112
112
113
if (!device_base_t::onAppInitialized (smart_refctd_ptr (m_system)))
113
114
return false ;
@@ -157,7 +158,7 @@ class NITETool final : public examples::SimpleWindowedApplication
157
158
if (!m_surface || !m_surface->init (gQueue , std::move (scResources), swapchainParams.sharedParams ))
158
159
return logFail (" Could not create Window & Surface or initialize the Surface!" );
159
160
160
- m_maxFramesInFlight = m_surface->getMaxFramesInFlight ();
161
+ m_maxFramesInFlight = m_surface->getMaxAcquiresInFlight ();
161
162
if (FRAMES_IN_FLIGHT < m_maxFramesInFlight)
162
163
{
163
164
m_logger->log (" Lowering frames in flight!" , ILogger::ELL_WARNING);
@@ -174,26 +175,29 @@ class NITETool final : public examples::SimpleWindowedApplication
174
175
return logFail (" Couldn't create Command Buffer!" );
175
176
}
176
177
177
- ui.manager = core::make_smart_refctd_ptr<nbl::ext::imgui::UI>
178
- (
179
- nbl::ext::imgui::UI::S_CREATION_PARAMETERS
180
- {
181
- .assetManager = m_assetManager.get (),
182
- .utilities = m_utils.get (),
183
- .transfer = getTransferUpQueue (),
184
- .renderpass = renderpass,
185
- .subpassIx = 0u
186
- }
187
- );
178
+ nbl::ext::imgui::UI::SCreationParameters params;
179
+
180
+ params.resources .texturesInfo = { .setIx = 0u , .bindingIx = 0u };
181
+ params.resources .samplersInfo = { .setIx = 0u , .bindingIx = 1u };
182
+ params.assetManager = m_assetManager;
183
+ params.pipelineCache = nullptr ;
184
+ params.pipelineLayout = nbl::ext::imgui::UI::createDefaultPipelineLayout (m_utils->getLogicalDevice (), params.resources .texturesInfo , params.resources .samplersInfo , MaxUITextureCount);
185
+ params.renderpass = smart_refctd_ptr<IGPURenderpass>(renderpass);
186
+ params.streamingBuffer = nullptr ;
187
+ params.subpassIx = 0u ;
188
+ params.transfer = getTransferUpQueue ();
189
+ params.utilities = m_utils;
190
+
191
+ ui.manager = nbl::ext::imgui::UI::create (std::move (params));
188
192
189
193
{
190
194
// note that we use default layout provided by our extension (textures & samplers -> single set at 0u ix)
191
195
const auto * descriptorSetLayout = ui.manager ->getPipeline ()->getLayout ()->getDescriptorSetLayout (0u );
192
196
const auto & params = ui.manager ->getCreationParameters ();
193
197
194
198
IDescriptorPool::SCreateInfo descriptorPoolInfo = {};
195
- descriptorPoolInfo.maxDescriptorCount [static_cast <uint32_t >(asset::IDescriptor::E_TYPE::ET_SAMPLER)] = params.resources .count ;
196
- descriptorPoolInfo.maxDescriptorCount [static_cast <uint32_t >(asset::IDescriptor::E_TYPE::ET_SAMPLED_IMAGE)] = params.resources .count ;
199
+ descriptorPoolInfo.maxDescriptorCount [static_cast <uint32_t >(asset::IDescriptor::E_TYPE::ET_SAMPLER)] = params.resources .getSamplersCount () ;
200
+ descriptorPoolInfo.maxDescriptorCount [static_cast <uint32_t >(asset::IDescriptor::E_TYPE::ET_SAMPLED_IMAGE)] = params.resources .getTexturesCount () ;
197
201
descriptorPoolInfo.maxSets = 1u ;
198
202
descriptorPoolInfo.flags = IDescriptorPool::E_CREATE_FLAGS::ECF_UPDATE_AFTER_BIND_BIT;
199
203
@@ -333,7 +337,7 @@ class NITETool final : public examples::SimpleWindowedApplication
333
337
const auto uiParams = ui.manager ->getCreationParameters ();
334
338
auto * pipeline = ui.manager ->getPipeline ();
335
339
cb->bindGraphicsPipeline (pipeline);
336
- 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
340
+ 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
337
341
ui.manager ->render (cb, waitInfo);
338
342
cb->endRenderPass ();
339
343
}
@@ -470,15 +474,12 @@ class NITETool final : public examples::SimpleWindowedApplication
470
474
471
475
const auto cursorPosition = m_window->getCursorControl ()->getPosition ();
472
476
473
- nbl::ext::imgui::UI::S_UPDATE_PARAMETERS params =
477
+ nbl::ext::imgui::UI::SUpdateParameters params =
474
478
{
475
479
.mousePosition = nbl::hlsl::float32_t2 (cursorPosition.x , cursorPosition.y ) - nbl::hlsl::float32_t2 (m_window->getX (), m_window->getY ()),
476
480
.displaySize = { m_window->getWidth (), m_window->getHeight () },
477
- .events =
478
- {
479
- .mouse = core::SRange<const nbl::ui::SMouseEvent>(capturedEvents.mouse .data (), capturedEvents.mouse .data () + capturedEvents.mouse .size ()),
480
- .keyboard = core::SRange<const nbl::ui::SKeyboardEvent>(capturedEvents.keyboard .data (), capturedEvents.keyboard .data () + capturedEvents.keyboard .size ())
481
- }
481
+ .mouseEvents = core::SRange<const nbl::ui::SMouseEvent>(capturedEvents.mouse .data (), capturedEvents.mouse .data () + capturedEvents.mouse .size ()),
482
+ .keyboardEvents = core::SRange<const nbl::ui::SKeyboardEvent>(capturedEvents.keyboard .data (), capturedEvents.keyboard .data () + capturedEvents.keyboard .size ()),
482
483
};
483
484
484
485
ui.manager ->update (params);
@@ -502,9 +503,9 @@ class NITETool final : public examples::SimpleWindowedApplication
502
503
} ui;
503
504
504
505
smart_refctd_ptr<nbl::asset::IAssetManager> m_assetManager;
505
- core::smart_refctd_ptr<InputSystem> m_inputSystem;
506
- InputSystem::ChannelReader<IMouseEventChannel> mouse;
507
- InputSystem::ChannelReader<IKeyboardEventChannel> keyboard;
506
+ core::smart_refctd_ptr<examples:: InputSystem> m_inputSystem;
507
+ examples:: InputSystem::ChannelReader<IMouseEventChannel> mouse;
508
+ examples:: InputSystem::ChannelReader<IKeyboardEventChannel> keyboard;
508
509
509
510
// Test engine
510
511
ImGuiTestEngine* engine = nullptr ;
0 commit comments