@@ -108,19 +108,21 @@ class StagingAndMultipleQueuesApp final : public application_templates::BasicMul
108
108
lp.logger = m_logger.get ();
109
109
110
110
auto transferUpQueue = getTransferUpQueue ();
111
- const core::bitflag<IGPUCommandPool::CREATE_FLAGS> commandPoolFlags = IGPUCommandPool::CREATE_FLAGS::RESET_COMMAND_BUFFER_BIT;
112
111
std::array<core::smart_refctd_ptr<nbl::video::IGPUCommandPool>, FRAMES_IN_FLIGHT> commandPools;
113
112
std::array<core::smart_refctd_ptr<nbl::video::IGPUCommandBuffer>, FRAMES_IN_FLIGHT> commandBuffers;
114
113
std::fill (commandPools.begin (), commandPools.end (), nullptr );
115
114
116
115
core::smart_refctd_ptr<ICPUImage> cpuImages[IMAGE_CNT];
117
116
for (uint32_t i = 0u ; i < FRAMES_IN_FLIGHT; ++i)
118
117
{
118
+ const core::bitflag<IGPUCommandPool::CREATE_FLAGS> commandPoolFlags = IGPUCommandPool::CREATE_FLAGS::RESET_COMMAND_BUFFER_BIT;
119
119
commandPools[i] = m_device->createCommandPool (transferUpQueue->getFamilyIndex (), commandPoolFlags);
120
120
commandPools[i]->createCommandBuffers (IGPUCommandPool::BUFFER_LEVEL::PRIMARY, {commandBuffers.data () + i, 1 }, core::smart_refctd_ptr (m_logger));
121
+ commandBuffers[i]->setObjectDebugName ((" Upload Command Buffer #" +std::to_string (i)).c_str ());
121
122
}
122
123
123
124
core::smart_refctd_ptr<ISemaphore> imgFillSemaphore = m_device->createSemaphore (0 );
125
+ imgFillSemaphore->setObjectDebugName (" Image Fill Semaphore" );
124
126
SIntendedSubmitInfo intendedSubmit = {
125
127
.queue = transferUpQueue,
126
128
.waitSemaphores = {},
@@ -166,6 +168,7 @@ class StagingAndMultipleQueuesApp final : public application_templates::BasicMul
166
168
imgParams.preinitialized = false ;
167
169
168
170
images[imageIdx] = m_device->createImage (std::move (imgParams));
171
+ images[imageIdx]->setObjectDebugName ((" Image #" +std::to_string (imageIdx)).c_str ());
169
172
auto imageAllocation = m_device->allocate (images[imageIdx]->getMemoryReqs (), images[imageIdx].get (), IDeviceMemoryAllocation::EMAF_NONE);
170
173
imageHandlesCreated++;
171
174
imageHandlesCreated.notify_one ();
@@ -232,7 +235,12 @@ class StagingAndMultipleQueuesApp final : public application_templates::BasicMul
232
235
233
236
cmdBuff->end ();
234
237
235
- const IQueue::SSubmitInfo::SSemaphoreInfo signalSemaphore = {.semaphore =m_imagesLoadedSemaphore.get (),.value =imageIdx+1u ,.stageMask =PIPELINE_STAGE_FLAGS::COPY_BIT};
238
+ const IQueue::SSubmitInfo::SSemaphoreInfo signalSemaphore = {
239
+ .semaphore =m_imagesLoadedSemaphore.get (),
240
+ .value =imageIdx+1u ,
241
+ // cannot signal from COPY stage because there's a layout transition we need to wait for right after and it doesn't have an explicit stage
242
+ .stageMask =PIPELINE_STAGE_FLAGS::ALL_COMMANDS_BITS
243
+ };
236
244
transferUpQueue->startCapture ();
237
245
getTransferUpQueue ()->submit (intendedSubmit.popSubmit ({&signalSemaphore,1 }));
238
246
transferUpQueue->endCapture ();
@@ -249,44 +257,48 @@ class StagingAndMultipleQueuesApp final : public application_templates::BasicMul
249
257
{
250
258
// INITIALIZE COMMON DATA
251
259
auto computeQueue = getComputeQueue ();
252
- const core::bitflag<IGPUCommandPool::CREATE_FLAGS> commandPoolFlags = static_cast <IGPUCommandPool::CREATE_FLAGS>(IGPUCommandPool::CREATE_FLAGS::NONE);
253
- std::array<core::smart_refctd_ptr<nbl::video::IGPUCommandPool>, FRAMES_IN_FLIGHT> commandPools;
254
- std::array<core::smart_refctd_ptr<nbl::video::IGPUCommandBuffer>, FRAMES_IN_FLIGHT> commandBuffers;
260
+
261
+ smart_refctd_ptr<IGPUDescriptorSetLayout> dsLayout;
255
262
core::smart_refctd_ptr<IGPUDescriptorSet> descSets[FRAMES_IN_FLIGHT];
256
- std::fill (commandPools.begin (), commandPools.end (), nullptr );
257
- nbl::video::IGPUDescriptorSetLayout::SBinding bindings[2 ] = {
258
- {
259
- .binding = 0 ,
260
- .type = nbl::asset::IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER,
261
- .createFlags = IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
262
- .stageFlags = IGPUShader::E_SHADER_STAGE::ESS_COMPUTE,
263
- .count = 1 ,
264
- .samplers = nullptr
265
- },
263
+ {
264
+ nbl::video::IGPUDescriptorSetLayout::SBinding bindings[2 ] = {
265
+ {
266
+ .binding = 0 ,
267
+ .type = nbl::asset::IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER, // TODO: just an image descriptor type when separable samplers arrive
268
+ .createFlags = IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
269
+ .stageFlags = IGPUShader::E_SHADER_STAGE::ESS_COMPUTE,
270
+ .count = 1 ,
271
+ .samplers = nullptr
272
+ },
273
+ {
274
+ .binding = 1 ,
275
+ .type = nbl::asset::IDescriptor::E_TYPE::ET_STORAGE_BUFFER,
276
+ .createFlags = IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
277
+ .stageFlags = IGPUShader::E_SHADER_STAGE::ESS_COMPUTE,
278
+ .count = 1 ,
279
+ .samplers = nullptr
280
+ }
281
+ };
282
+
283
+ dsLayout = m_device->createDescriptorSetLayout (bindings);
284
+ if (!dsLayout)
285
+ logFailAndTerminate (" Failed to create a Descriptor Layout!\n " );
286
+ auto descPool = m_device->createDescriptorPoolForDSLayouts (IDescriptorPool::ECF_NONE, { &dsLayout.get (),1 }, &FRAMES_IN_FLIGHT);
287
+ for (uint32_t i = 0u ; i < FRAMES_IN_FLIGHT; ++i)
266
288
{
267
- .binding = 1 ,
268
- .type = nbl::asset::IDescriptor::E_TYPE::ET_STORAGE_BUFFER,
269
- .createFlags = IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
270
- .stageFlags = IGPUShader::E_SHADER_STAGE::ESS_COMPUTE,
271
- .count = 1 ,
272
- .samplers = nullptr
289
+ descSets[i] = descPool->createDescriptorSet (core::smart_refctd_ptr (dsLayout));
290
+ descSets[i]->setObjectDebugName ((" Descriptor Set #" + std::to_string (i)).c_str ());
273
291
}
274
- };
275
- smart_refctd_ptr<IGPUDescriptorSetLayout> dsLayout[1 ] = { m_device->createDescriptorSetLayout (bindings) };
276
- if (!dsLayout[0 ])
277
- logFailAndTerminate (" Failed to create a Descriptor Layout!\n " );
278
- smart_refctd_ptr<nbl::video::IDescriptorPool> descPools[FRAMES_IN_FLIGHT] = { // TODO: only one desc pool?
279
- m_device->createDescriptorPoolForDSLayouts (IDescriptorPool::ECF_NONE, {&dsLayout[0 ].get (), 1 }),
280
- m_device->createDescriptorPoolForDSLayouts (IDescriptorPool::ECF_NONE, {&dsLayout[0 ].get (), 1 }),
281
- m_device->createDescriptorPoolForDSLayouts (IDescriptorPool::ECF_NONE, {&dsLayout[0 ].get (), 1 })
282
- };
292
+ }
283
293
294
+ std::array<core::smart_refctd_ptr<nbl::video::IGPUCommandPool>, FRAMES_IN_FLIGHT> commandPools;
295
+ std::array<core::smart_refctd_ptr<nbl::video::IGPUCommandBuffer>, FRAMES_IN_FLIGHT> commandBuffers;
284
296
for (uint32_t i = 0u ; i < FRAMES_IN_FLIGHT; ++i)
285
297
{
298
+ const core::bitflag<IGPUCommandPool::CREATE_FLAGS> commandPoolFlags = IGPUCommandPool::CREATE_FLAGS::NONE;
286
299
commandPools[i] = m_device->createCommandPool (getComputeQueue ()->getFamilyIndex (), commandPoolFlags);
287
300
commandPools[i]->createCommandBuffers (IGPUCommandPool::BUFFER_LEVEL::PRIMARY, {commandBuffers.data () + i, 1 }, core::smart_refctd_ptr (m_logger));
288
-
289
- descSets[i] = descPools[i]->createDescriptorSet (core::smart_refctd_ptr (dsLayout[0 ]));
301
+ commandBuffers[i]->setObjectDebugName ((" Histogram Command Buffer #" + std::to_string (i)).c_str ());
290
302
}
291
303
292
304
// LOAD SHADER FROM FILE
@@ -310,7 +322,7 @@ class StagingAndMultipleQueuesApp final : public application_templates::BasicMul
310
322
pc[0 ].size = sizeof (PushConstants);
311
323
312
324
smart_refctd_ptr<nbl::video::IGPUComputePipeline> pipeline;
313
- smart_refctd_ptr<IGPUPipelineLayout> pplnLayout = m_device->createPipelineLayout (pc, smart_refctd_ptr (dsLayout[ 0 ] ));
325
+ smart_refctd_ptr<IGPUPipelineLayout> pplnLayout = m_device->createPipelineLayout (pc,std::move (dsLayout));
314
326
{
315
327
// Nabla actually has facilities for SPIR-V Reflection and "guessing" pipeline layouts for a given SPIR-V which we'll cover in a different example
316
328
if (!pplnLayout)
@@ -359,6 +371,7 @@ class StagingAndMultipleQueuesApp final : public application_templates::BasicMul
359
371
m_histogramBufferMemPtrs[2 ] = m_histogramBufferMemPtrs[1 ] + HISTOGRAM_SIZE;
360
372
}
361
373
374
+ // TODO: will no longer be necessary after separable samplers and images
362
375
IGPUSampler::SParams samplerParams;
363
376
samplerParams.AnisotropicFilter = false ;
364
377
core::smart_refctd_ptr<IGPUSampler> sampler = m_device->createSampler (samplerParams);
@@ -399,9 +412,11 @@ class StagingAndMultipleQueuesApp final : public application_templates::BasicMul
399
412
params.subresourceRange .aspectMask = IImage::E_ASPECT_FLAGS::EAF_COLOR_BIT;
400
413
params.subresourceRange .layerCount = images[imageToProcessId]->getCreationParameters ().arrayLayers ;
401
414
402
- imgInfo. desc = m_device->createImageView (std::move (params));
403
- if (!imgInfo. desc )
415
+ auto view = m_device->createImageView (std::move (params));
416
+ if (!view )
404
417
logFailAndTerminate (" Couldn't create descriptor." );
418
+ view->setObjectDebugName ((" Image View #" +std::to_string (imageToProcessId)).c_str ());
419
+ imgInfo.desc = std::move (view);
405
420
imgInfo.info .image = { .sampler = sampler, .imageLayout = IImage::LAYOUT::READ_ONLY_OPTIMAL };
406
421
407
422
IGPUDescriptorSet::SWriteDescriptorSet write[1 ] = {
0 commit comments