@@ -79,11 +79,11 @@ class GPUMesh : public ApplicationBase
79
79
nbl::core::smart_refctd_ptr<nbl::video::IUtilities> utilities;
80
80
nbl::core::smart_refctd_ptr<nbl::video::ILogicalDevice> logicalDevice;
81
81
nbl::video::IPhysicalDevice* physicalDevice;
82
- std::array<nbl::video::IGPUQueue*, CommonAPI::InitOutput<SC_IMG_COUNT>::EQT_COUNT > queues = { nullptr , nullptr , nullptr , nullptr };
82
+ std::array<nbl::video::IGPUQueue*, CommonAPI::InitOutput::MaxQueuesCount > queues = { nullptr , nullptr , nullptr , nullptr };
83
83
nbl::core::smart_refctd_ptr<nbl::video::ISwapchain> swapchain;
84
84
nbl::core::smart_refctd_ptr<nbl::video::IGPURenderpass> renderpass;
85
- std::array<nbl::core::smart_refctd_ptr<nbl::video::IGPUFramebuffer>, SC_IMG_COUNT> fbos ;
86
- nbl::core::smart_refctd_ptr<nbl::video::IGPUCommandPool> commandPool ;
85
+ std::array<nbl::core::smart_refctd_ptr<nbl::video::IGPUFramebuffer>, CommonAPI::InitOutput::MaxSwapChainImageCount> fbo ;
86
+ std::array< nbl::core::smart_refctd_ptr<nbl::video::IGPUCommandPool>, CommonAPI::InitOutput::MaxQueuesCount> commandPools ;
87
87
nbl::core::smart_refctd_ptr<nbl::system::ISystem> system;
88
88
nbl::core::smart_refctd_ptr<nbl::asset::IAssetManager> assetManager;
89
89
nbl::video::IGPUObjectFromAssetConverter::SParams cpu2gpuParams;
@@ -94,8 +94,8 @@ class GPUMesh : public ApplicationBase
94
94
nbl::core::smart_refctd_ptr<video::IGPUFence> gpuComputeFence;
95
95
nbl::video::IGPUObjectFromAssetConverter cpu2gpu;
96
96
97
- CommonAPI::InputSystem::ChannelReader<IMouseEventChannel> mouse;
98
- CommonAPI::InputSystem::ChannelReader<IKeyboardEventChannel> keyboard;
97
+ CommonAPI::InputSystem::ChannelReader<ui:: IMouseEventChannel> mouse;
98
+ CommonAPI::InputSystem::ChannelReader<ui:: IKeyboardEventChannel> keyboard;
99
99
Camera camera = Camera(vectorSIMDf(0 , 0 , 0 ), vectorSIMDf(0 , 0 , 0 ), matrix4SIMD());
100
100
101
101
int resourceIx = -1 ;
@@ -123,14 +123,54 @@ class GPUMesh : public ApplicationBase
123
123
{
124
124
return window.get ();
125
125
}
126
+ video::IAPIConnection* getAPIConnection () override
127
+ {
128
+ return apiConnection.get ();
129
+ }
130
+ video::ILogicalDevice* getLogicalDevice () override
131
+ {
132
+ return logicalDevice.get ();
133
+ }
134
+ video::IGPURenderpass* getRenderpass () override
135
+ {
136
+ return renderpass.get ();
137
+ }
138
+ void setSurface (core::smart_refctd_ptr<video::ISurface>&& s) override
139
+ {
140
+ surface = std::move (s);
141
+ }
142
+ void setFBOs (std::vector<core::smart_refctd_ptr<video::IGPUFramebuffer>>& f) override
143
+ {
144
+ for (int i = 0 ; i < f.size (); i++)
145
+ {
146
+ fbo[i] = core::smart_refctd_ptr (f[i]);
147
+ }
148
+ }
149
+ void setSwapchain (core::smart_refctd_ptr<video::ISwapchain>&& s) override
150
+ {
151
+ swapchain = std::move (s);
152
+ }
153
+ uint32_t getSwapchainImageCount () override
154
+ {
155
+ return SC_IMG_COUNT;
156
+ }
157
+ virtual nbl::asset::E_FORMAT getDepthFormat () override
158
+ {
159
+ return nbl::asset::EF_D32_SFLOAT;
160
+ }
126
161
127
162
APP_CONSTRUCTOR (GPUMesh)
128
163
129
164
void onAppInitialized_impl () override
130
165
{
131
- CommonAPI::InitOutput<SC_IMG_COUNT> initOutput;
166
+ CommonAPI::InitOutput initOutput;
132
167
initOutput.window = core::smart_refctd_ptr (window);
133
- CommonAPI::Init<WIN_W, WIN_H, SC_IMG_COUNT>(initOutput, video::EAT_OPENGL, " GPUMesh" , nbl::asset::EF_D32_SFLOAT);
168
+ initOutput.system = core::smart_refctd_ptr (system);
169
+
170
+ const auto swapchainImageUsage = static_cast <asset::IImage::E_USAGE_FLAGS>(asset::IImage::EUF_COLOR_ATTACHMENT_BIT);
171
+ const video::ISurface::SFormat surfaceFormat (asset::EF_R8G8B8A8_SRGB, asset::ECP_COUNT, asset::EOTF_UNKNOWN);
172
+
173
+ CommonAPI::InitWithDefaultExt (initOutput, video::EAT_OPENGL_ES, " GPUMesh" , WIN_W, WIN_H, SC_IMG_COUNT, swapchainImageUsage, surfaceFormat, nbl::asset::EF_D32_SFLOAT);
134
174
window = std::move (initOutput.window );
135
175
windowCb = std::move (initOutput.windowCb );
136
176
apiConnection = std::move (initOutput.apiConnection );
@@ -141,8 +181,8 @@ class GPUMesh : public ApplicationBase
141
181
queues = std::move (initOutput.queues );
142
182
swapchain = std::move (initOutput.swapchain );
143
183
renderpass = std::move (initOutput.renderpass );
144
- fbos = std::move (initOutput.fbo );
145
- commandPool = std::move (initOutput.commandPool );
184
+ fbo = std::move (initOutput.fbo );
185
+ commandPools = std::move (initOutput.commandPools );
146
186
system = std::move (initOutput.system );
147
187
assetManager = std::move (initOutput.assetManager );
148
188
cpu2gpuParams = std::move (initOutput.cpu2gpuParams );
@@ -155,7 +195,7 @@ class GPUMesh : public ApplicationBase
155
195
matrix4SIMD projectionMatrix = matrix4SIMD::buildProjectionMatrixPerspectiveFovLH (core::radians (60 .0f ), float (WIN_W) / WIN_H, 0.1 , 1000 );
156
196
camera = Camera (core::vectorSIMDf (-4 , 0 , 0 ), core::vectorSIMDf (0 , 0 , 0 ), projectionMatrix);
157
197
158
- logicalDevice->createCommandBuffers (commandPool .get (), video::IGPUCommandBuffer::EL_PRIMARY, FRAMES_IN_FLIGHT, commandBuffers);
198
+ logicalDevice->createCommandBuffers (commandPools[CommonAPI::InitOutput::EQT_GRAPHICS] .get (), video::IGPUCommandBuffer::EL_PRIMARY, FRAMES_IN_FLIGHT, commandBuffers);
159
199
160
200
for (uint32_t i = 0u ; i < FRAMES_IN_FLIGHT; i++)
161
201
{
@@ -213,8 +253,8 @@ class GPUMesh : public ApplicationBase
213
253
inputSystem->getDefaultKeyboard (&keyboard);
214
254
215
255
camera.beginInputProcessing (nextPresentationTimeStamp);
216
- mouse.consumeEvents ([&](const IMouseEventChannel::range_t & events) -> void { camera.mouseProcess (events); }, logger.get ());
217
- keyboard.consumeEvents ([&](const IKeyboardEventChannel::range_t & events) -> void { camera.keyboardProcess (events); }, logger.get ());
256
+ mouse.consumeEvents ([&](const ui:: IMouseEventChannel::range_t & events) -> void { camera.mouseProcess (events); }, logger.get ());
257
+ keyboard.consumeEvents ([&](const ui:: IKeyboardEventChannel::range_t & events) -> void { camera.keyboardProcess (events); }, logger.get ());
218
258
camera.endInputProcessing (nextPresentationTimeStamp);
219
259
220
260
const auto & mvp = camera.getConcatenatedMatrix ();
@@ -246,7 +286,7 @@ class GPUMesh : public ApplicationBase
246
286
clear[1 ].depthStencil .depth = 0 .f ;
247
287
248
288
beginInfo.clearValueCount = 2u ;
249
- beginInfo.framebuffer = fbos [acquiredNextFBO];
289
+ beginInfo.framebuffer = fbo [acquiredNextFBO];
250
290
beginInfo.renderpass = renderpass;
251
291
beginInfo.renderArea = area;
252
292
beginInfo.clearValues = clear;
0 commit comments