9
9
// #include "CFileSystem.h"
10
10
using namespace nbl ;
11
11
using namespace core ;
12
+ using namespace ui ;
12
13
13
14
struct UBOCompute
14
15
{
@@ -25,15 +26,16 @@ class SpecializationConstantsSampleApp : public ApplicationBase
25
26
static constexpr uint64_t MAX_TIMEOUT = 99999999999999ull ;
26
27
static_assert (FRAMES_IN_FLIGHT > SC_IMG_COUNT);
27
28
28
- core::smart_refctd_ptr<nbl::ui::IWindow> win;
29
+ core::smart_refctd_ptr<nbl::ui::IWindow> window;
30
+ core::smart_refctd_ptr<nbl::system::ISystem> system;
29
31
core::smart_refctd_ptr<CommonAPI::CommonAPIEventCallback> windowCb;
30
32
core::smart_refctd_ptr<nbl::video::IAPIConnection> api;
31
33
core::smart_refctd_ptr<nbl::video::ISurface> surface;
32
34
core::smart_refctd_ptr<nbl::video::IUtilities> utils;
33
35
core::smart_refctd_ptr<nbl::video::ILogicalDevice> device;
34
36
video::IPhysicalDevice* gpu;
35
37
std::array<video::IGPUQueue*, CommonAPI::InitOutput::MaxQueuesCount> queues;
36
- core::smart_refctd_ptr<nbl::video::ISwapchain> sc ;
38
+ core::smart_refctd_ptr<nbl::video::ISwapchain> swapchain ;
37
39
core::smart_refctd_ptr<nbl::video::IGPURenderpass> renderpass;
38
40
std::array<nbl::core::smart_refctd_ptr<nbl::video::IGPUFramebuffer>, CommonAPI::InitOutput::MaxSwapChainImageCount> fbo;
39
41
std::array<nbl::core::smart_refctd_ptr<nbl::video::IGPUCommandPool>, CommonAPI::InitOutput::MaxQueuesCount> commandPools;
@@ -77,17 +79,53 @@ class SpecializationConstantsSampleApp : public ApplicationBase
77
79
core::smart_refctd_ptr<video::IGPURenderpassIndependentPipeline> m_rpIndependentPipeline;
78
80
79
81
public:
82
+
80
83
void setWindow (core::smart_refctd_ptr<nbl::ui::IWindow>&& wnd) override
81
84
{
82
- win = std::move (wnd);
85
+ window = std::move (wnd);
86
+ }
87
+ void setSystem (core::smart_refctd_ptr<nbl::system::ISystem>&& s) override
88
+ {
89
+ system = std::move (s);
83
90
}
84
91
nbl::ui::IWindow* getWindow () override
85
92
{
86
- return win.get ();
93
+ return window.get ();
94
+ }
95
+ video::IAPIConnection* getAPIConnection () override
96
+ {
97
+ return api.get ();
98
+ }
99
+ video::ILogicalDevice* getLogicalDevice () override
100
+ {
101
+ return device.get ();
102
+ }
103
+ video::IGPURenderpass* getRenderpass () override
104
+ {
105
+ return renderpass.get ();
106
+ }
107
+ void setSurface (core::smart_refctd_ptr<video::ISurface>&& s) override
108
+ {
109
+ surface = std::move (s);
110
+ }
111
+ void setFBOs (std::vector<core::smart_refctd_ptr<video::IGPUFramebuffer>>& f) override
112
+ {
113
+ for (int i = 0 ; i < f.size (); i++)
114
+ {
115
+ fbo[i] = core::smart_refctd_ptr (f[i]);
116
+ }
117
+ }
118
+ void setSwapchain (core::smart_refctd_ptr<video::ISwapchain>&& s) override
119
+ {
120
+ swapchain = std::move (s);
121
+ }
122
+ uint32_t getSwapchainImageCount () override
123
+ {
124
+ return SC_IMG_COUNT;
87
125
}
88
- void setSystem (core::smart_refctd_ptr< nbl::system::ISystem>&& system ) override
126
+ virtual nbl::asset::E_FORMAT getDepthFormat ( ) override
89
127
{
90
- system = std::move (system) ;
128
+ return nbl::asset::EF_UNKNOWN ;
91
129
}
92
130
93
131
APP_CONSTRUCTOR (SpecializationConstantsSampleApp);
@@ -113,7 +151,8 @@ class SpecializationConstantsSampleApp : public ApplicationBase
113
151
const asset::E_FORMAT depthFormat = asset::EF_UNKNOWN;
114
152
115
153
CommonAPI::InitOutput initOutp;
116
- initOutp.window = core::smart_refctd_ptr (win);
154
+ initOutp.window = window;
155
+ initOutp.system = system;
117
156
CommonAPI::Init (
118
157
initOutp,
119
158
video::EAT_VULKAN,
@@ -127,14 +166,15 @@ class SpecializationConstantsSampleApp : public ApplicationBase
127
166
surfaceFormat,
128
167
depthFormat);
129
168
130
- win = std::move (initOutp.window );
169
+ window = std::move (initOutp.window );
170
+ system = std::move (initOutp.system );
131
171
windowCb = std::move (initOutp.windowCb );
132
172
api = std::move (initOutp.apiConnection );
133
173
surface = std::move (initOutp.surface );
134
174
device = std::move (initOutp.logicalDevice );
135
175
gpu = std::move (initOutp.physicalDevice );
136
176
queues = std::move (initOutp.queues );
137
- sc = std::move (initOutp.swapchain );
177
+ swapchain = std::move (initOutp.swapchain );
138
178
renderpass = std::move (initOutp.renderpass );
139
179
fbo = std::move (initOutp.fbo );
140
180
commandPools = std::move (initOutp.commandPools );
@@ -153,7 +193,7 @@ class SpecializationConstantsSampleApp : public ApplicationBase
153
193
154
194
video::IGPUObjectFromAssetConverter CPU2GPU;
155
195
m_cameraPosition = core::vectorSIMDf (0 , 0 , -10 );
156
- matrix4SIMD proj = matrix4SIMD::buildProjectionMatrixPerspectiveFovRH (core::radians (90 ), float (WIN_W) / WIN_H, 0.01 , 100 );
196
+ matrix4SIMD proj = matrix4SIMD::buildProjectionMatrixPerspectiveFovRH (core::radians (90 . 0f ), float (WIN_W) / WIN_H, 0.01 , 100 );
157
197
matrix3x4SIMD view = matrix3x4SIMD::buildCameraLookAtMatrixRH (m_cameraPosition, core::vectorSIMDf (0 , 0 , 0 ), core::vectorSIMDf (0 , 1 , 0 ));
158
198
m_viewProj = matrix4SIMD::concatenateBFollowedByA (proj, matrix4SIMD (view));
159
199
m_camFront = view[2 ];
@@ -191,7 +231,7 @@ class SpecializationConstantsSampleApp : public ApplicationBase
191
231
int32_t vel_buf_ix;
192
232
int32_t buf_count;
193
233
};
194
- SpecConstants sc { WORKGROUP_SIZE, PARTICLE_COUNT, POS_BUF_IX, VEL_BUF_IX, BUF_COUNT };
234
+ SpecConstants swapchain { WORKGROUP_SIZE, PARTICLE_COUNT, POS_BUF_IX, VEL_BUF_IX, BUF_COUNT };
195
235
196
236
auto it_particleBufDescIntro = std::find_if (introspection->descriptorSetBindings [COMPUTE_SET].begin (), introspection->descriptorSetBindings [COMPUTE_SET].end (),
197
237
[=](auto b) { return b.binding == PARTICLE_BUF_BINDING; }
@@ -202,8 +242,8 @@ class SpecializationConstantsSampleApp : public ApplicationBase
202
242
assert (particleDataArrayIntro.countIsSpecConstant );
203
243
const uint32_t particle_count_specID = particleDataArrayIntro.count_specID ;
204
244
205
- auto backbuf = core::make_smart_refctd_ptr<asset::ICPUBuffer>(sizeof (sc ));
206
- memcpy (backbuf->getPointer (), &sc , sizeof (sc ));
245
+ auto backbuf = core::make_smart_refctd_ptr<asset::ICPUBuffer>(sizeof (swapchain ));
246
+ memcpy (backbuf->getPointer (), &swapchain , sizeof (swapchain ));
207
247
auto entries = core::make_refctd_dynamic_array<core::smart_refctd_dynamic_array<asset::ISpecializedShader::SInfo::SMapEntry>>(5u );
208
248
(*entries)[0 ] = { 0u ,offsetof (SpecConstants,wg_size),sizeof (int32_t ) };// currently local_size_{x|y|z}_id is not queryable via introspection API
209
249
(*entries)[1 ] = { particle_count_specID,offsetof (SpecConstants,particle_count),sizeof (int32_t ) };
@@ -314,8 +354,6 @@ class SpecializationConstantsSampleApp : public ApplicationBase
314
354
auto & blendParams = pipeline->getBlendParams ();
315
355
blendParams.logicOpEnable = false ;
316
356
blendParams.logicOp = nbl::asset::ELO_NO_OP;
317
- for (size_t i = 0ull ; i < nbl::asset::SBlendParams::MAX_COLOR_ATTACHMENT_COUNT; i++)
318
- blendParams.blendParams [i].attachmentEnabled = (i == 0ull );
319
357
}
320
358
auto gfxLayout = core::make_smart_refctd_ptr<asset::ICPUPipelineLayout>(nullptr , nullptr , core::smart_refctd_ptr<asset::ICPUDescriptorSetLayout>(pipeline->getLayout ()->getDescriptorSetLayout (0 )));
321
359
pipeline->setLayout (core::smart_refctd_ptr (gfxLayout));
@@ -410,7 +448,7 @@ class SpecializationConstantsSampleApp : public ApplicationBase
410
448
COMPUTE_SET,
411
449
1u ,
412
450
&m_gpuds0Compute.get (),
413
- nullptr );
451
+ 0u );
414
452
cb->dispatch (PARTICLE_COUNT / WORKGROUP_SIZE, 1u , 1u );
415
453
416
454
asset::SMemoryBarrier memBarrier;
@@ -445,7 +483,7 @@ class SpecializationConstantsSampleApp : public ApplicationBase
445
483
}
446
484
// renderpass
447
485
uint32_t imgnum = 0u ;
448
- sc ->acquireNextImage (MAX_TIMEOUT, m_imageAcquire[m_resourceIx].get (), nullptr , &imgnum);
486
+ swapchain ->acquireNextImage (MAX_TIMEOUT, m_imageAcquire[m_resourceIx].get (), nullptr , &imgnum);
449
487
{
450
488
video::IGPUCommandBuffer::SRenderpassBeginInfo info;
451
489
asset::SClearValue clear;
@@ -466,15 +504,15 @@ class SpecializationConstantsSampleApp : public ApplicationBase
466
504
cb->bindGraphicsPipeline (m_graphicsPipeline.get ());
467
505
size_t vbOffset = 0 ;
468
506
cb->bindVertexBuffers (0 , 1 , &m_gpuParticleBuf.get (), &vbOffset);
469
- cb->bindDescriptorSets (asset::EPBP_GRAPHICS, m_rpIndependentPipeline->getLayout (), GRAPHICS_SET, 1u , &m_gpuds0Graphics.get (), nullptr );
507
+ cb->bindDescriptorSets (asset::EPBP_GRAPHICS, m_rpIndependentPipeline->getLayout (), GRAPHICS_SET, 1u , &m_gpuds0Graphics.get (), 0u );
470
508
cb->draw (PARTICLE_COUNT, 1 , 0 , 0 );
471
509
}
472
510
cb->endRenderPass ();
473
511
cb->end ();
474
512
475
513
CommonAPI::Submit (
476
514
device.get (),
477
- sc .get (),
515
+ swapchain .get (),
478
516
cb.get (),
479
517
queues[CommonAPI::InitOutput::EQT_GRAPHICS],
480
518
m_imageAcquire[m_resourceIx].get (),
@@ -483,7 +521,7 @@ class SpecializationConstantsSampleApp : public ApplicationBase
483
521
484
522
CommonAPI::Present (
485
523
device.get (),
486
- sc .get (),
524
+ swapchain .get (),
487
525
queues[CommonAPI::InitOutput::EQT_GRAPHICS],
488
526
m_renderFinished[m_resourceIx].get (),
489
527
imgnum);
0 commit comments