@@ -39,11 +39,11 @@ class MeshLoadersApp : public ApplicationBase
39
39
nbl::core::smart_refctd_ptr<nbl::video::IUtilities> utilities;
40
40
nbl::core::smart_refctd_ptr<nbl::video::ILogicalDevice> logicalDevice;
41
41
nbl::video::IPhysicalDevice* physicalDevice;
42
- std::array<video::IGPUQueue*, CommonAPI::InitOutput::MaxQueuesCount> queues;
42
+ std::array<video::IGPUQueue*, CommonAPI::InitOutput::MaxQueuesCount> queues;
43
43
nbl::core::smart_refctd_ptr<nbl::video::ISwapchain> swapchain;
44
44
nbl::core::smart_refctd_ptr<nbl::video::IGPURenderpass> renderpass;
45
- std::array<nbl::core::smart_refctd_ptr<nbl::video::IGPUFramebuffer>, CommonAPI::InitOutput::MaxSwapChainImageCount> fbo;
46
- std::array<nbl::core::smart_refctd_ptr<nbl::video::IGPUCommandPool>, CommonAPI::InitOutput::MaxQueuesCount> commandPools;
45
+ std::array<nbl::core::smart_refctd_ptr<nbl::video::IGPUFramebuffer>, CommonAPI::InitOutput::MaxSwapChainImageCount> fbo;
46
+ std::array<nbl::core::smart_refctd_ptr<nbl::video::IGPUCommandPool>, CommonAPI::InitOutput::MaxQueuesCount> commandPools;
47
47
nbl::core::smart_refctd_ptr<nbl::system::ISystem> system;
48
48
nbl::core::smart_refctd_ptr<nbl::asset::IAssetManager> assetManager;
49
49
nbl::video::IGPUObjectFromAssetConverter::SParams cpu2gpuParams;
@@ -152,8 +152,8 @@ class MeshLoadersApp : public ApplicationBase
152
152
initOutput.window = core::smart_refctd_ptr (window);
153
153
initOutput.system = core::smart_refctd_ptr (system);
154
154
155
- const auto swapchainImageUsage = static_cast <asset::IImage::E_USAGE_FLAGS>(asset::IImage::EUF_COLOR_ATTACHMENT_BIT);
156
- const video::ISurface::SFormat surfaceFormat (asset::EF_R8G8B8A8_SRGB, asset::ECP_COUNT , asset::EOTF_UNKNOWN );
155
+ const auto swapchainImageUsage = static_cast <asset::IImage::E_USAGE_FLAGS>(asset::IImage::EUF_COLOR_ATTACHMENT_BIT);
156
+ const video::ISurface::SFormat surfaceFormat (asset::EF_R8G8B8A8_SRGB, asset::ECP_SRGB , asset::EOTF_sRGB );
157
157
158
158
CommonAPI::InitWithDefaultExt (initOutput, video::EAT_OPENGL_ES, " MeshLoaders" , WIN_W, WIN_H, SC_IMG_COUNT, swapchainImageUsage, surfaceFormat, nbl::asset::EF_D32_SFLOAT);
159
159
window = std::move (initOutput.window );
@@ -232,8 +232,8 @@ class MeshLoadersApp : public ApplicationBase
232
232
ubomemreq.vulkanReqs .size = neededDS1UBOsz;
233
233
video::IGPUBuffer::SCreationParams gpuuboCreationParams;
234
234
gpuuboCreationParams.canUpdateSubRange = true ;
235
- gpuuboCreationParams.usage = asset::IBuffer::EUF_UNIFORM_BUFFER_BIT;
236
- gpuuboCreationParams.sharingMode = asset::E_SHARING_MODE::ESM_CONCURRENT ;
235
+ gpuuboCreationParams.usage = core::bitflag< asset::IBuffer::E_USAGE_FLAGS>(asset::IBuffer:: EUF_UNIFORM_BUFFER_BIT) | asset::IBuffer::EUF_TRANSFER_DST_BIT ;
236
+ gpuuboCreationParams.sharingMode = asset::E_SHARING_MODE::ESM_EXCLUSIVE ;
237
237
gpuuboCreationParams.queueFamilyIndexCount = 0u ;
238
238
gpuuboCreationParams.queueFamilyIndices = nullptr ;
239
239
@@ -344,36 +344,18 @@ class MeshLoadersApp : public ApplicationBase
344
344
viewport.width = WIN_W;
345
345
viewport.height = WIN_H;
346
346
commandBuffer->setViewport (0u , 1u , &viewport);
347
-
348
- swapchain->acquireNextImage (MAX_TIMEOUT, imageAcquire[resourceIx].get (), nullptr , &acquiredNextFBO);
349
-
350
- nbl::video::IGPUCommandBuffer::SRenderpassBeginInfo beginInfo;
351
- {
352
- VkRect2D area;
353
- area.offset = { 0 ,0 };
354
- area.extent = { WIN_W, WIN_H };
355
- asset::SClearValue clear[2 ] = {};
356
- clear[0 ].color .float32 [0 ] = 1 .f ;
357
- clear[0 ].color .float32 [1 ] = 1 .f ;
358
- clear[0 ].color .float32 [2 ] = 1 .f ;
359
- clear[0 ].color .float32 [3 ] = 1 .f ;
360
- clear[1 ].depthStencil .depth = 0 .f ;
361
-
362
- beginInfo.clearValueCount = 2u ;
363
- beginInfo.framebuffer = fbo[acquiredNextFBO];
364
- beginInfo.renderpass = renderpass;
365
- beginInfo.renderArea = area;
366
- beginInfo.clearValues = clear;
367
- }
368
-
369
- commandBuffer->beginRenderPass (&beginInfo, nbl::asset::ESC_INLINE);
347
+
348
+ VkRect2D scissor = {};
349
+ scissor.offset = { 0 , 0 };
350
+ scissor.extent = { WIN_W, WIN_H };
351
+ commandBuffer->setScissor (0u , 1u , &scissor);
370
352
371
353
core::matrix3x4SIMD modelMatrix;
372
354
modelMatrix.setTranslation (nbl::core::vectorSIMDf (0 , 0 , 0 , 0 ));
373
-
374
355
core::matrix4SIMD mvp = core::concatenateBFollowedByA (viewProjectionMatrix, modelMatrix);
375
356
376
- core::vector<uint8_t > uboData (gpuubo->getSize ());
357
+ const size_t uboSize = gpuubo->getCachedCreationParams ().declaredSize ;
358
+ core::vector<uint8_t > uboData (uboSize);
377
359
for (const auto & shdrIn : pipelineMetadata->m_inputSemantics )
378
360
{
379
361
if (shdrIn.descriptorSection .type == asset::IRenderpassIndependentPipelineMetadata::ShaderInput::ET_UNIFORM_BUFFER && shdrIn.descriptorSection .uniformBufferObject .set == 1u && shdrIn.descriptorSection .uniformBufferObject .binding == ds1UboBinding)
@@ -397,8 +379,28 @@ class MeshLoadersApp : public ApplicationBase
397
379
}
398
380
}
399
381
}
382
+ commandBuffer->updateBuffer (gpuubo.get (), 0ull , uboSize, uboData.data ());
383
+
384
+ nbl::video::IGPUCommandBuffer::SRenderpassBeginInfo beginInfo;
385
+ {
386
+ VkRect2D area;
387
+ area.offset = { 0 ,0 };
388
+ area.extent = { WIN_W, WIN_H };
389
+ asset::SClearValue clear[2 ] = {};
390
+ clear[0 ].color .float32 [0 ] = 1 .f ;
391
+ clear[0 ].color .float32 [1 ] = 1 .f ;
392
+ clear[0 ].color .float32 [2 ] = 1 .f ;
393
+ clear[0 ].color .float32 [3 ] = 1 .f ;
394
+ clear[1 ].depthStencil .depth = 0 .f ;
395
+
396
+ beginInfo.clearValueCount = 2u ;
397
+ beginInfo.framebuffer = fbo[acquiredNextFBO];
398
+ beginInfo.renderpass = renderpass;
399
+ beginInfo.renderArea = area;
400
+ beginInfo.clearValues = clear;
401
+ }
400
402
401
- commandBuffer->updateBuffer (gpuubo. get (), 0ull , gpuubo-> getSize (), uboData. data () );
403
+ commandBuffer->beginRenderPass (&beginInfo, nbl::asset::ESC_INLINE );
402
404
403
405
for (size_t i = 0 ; i < gpumesh->getMeshBuffers ().size (); ++i)
404
406
{
@@ -422,7 +424,8 @@ class MeshLoadersApp : public ApplicationBase
422
424
423
425
commandBuffer->endRenderPass ();
424
426
commandBuffer->end ();
425
-
427
+
428
+ logicalDevice->resetFences (1 , &fence.get ());
426
429
CommonAPI::Submit (logicalDevice.get (),
427
430
swapchain.get (),
428
431
commandBuffer.get (),
0 commit comments