@@ -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 );
@@ -196,6 +196,14 @@ class MeshLoadersApp : public ApplicationBase
196
196
197
197
quantNormalCache->saveCacheToFile <asset::EF_A2B10G10R10_SNORM_PACK32>(system.get (), sharedOutputCWD / " normalCache101010.sse" );
198
198
}
199
+
200
+ // Fix FrontFace and BlendParams for meshBuffers
201
+ for (size_t i = 0ull ; i < meshRaw->getMeshBuffers ().size (); ++i)
202
+ {
203
+ auto & meshBuffer = meshRaw->getMeshBuffers ().begin ()[i];
204
+ meshBuffer->getPipeline ()->getRasterizationParams ().frontFaceIsCCW = false ;
205
+ }
206
+
199
207
// we can safely assume that all meshbuffers within mesh loaded from OBJ has same DS1 layout (used for camera-specific data)
200
208
firstMeshBuffer = *meshRaw->getMeshBuffers ().begin ();
201
209
pipelineMetadata = metaOBJ->getAssetSpecificMetadata (firstMeshBuffer->getPipeline ());
@@ -232,8 +240,8 @@ class MeshLoadersApp : public ApplicationBase
232
240
ubomemreq.vulkanReqs .size = neededDS1UBOsz;
233
241
video::IGPUBuffer::SCreationParams gpuuboCreationParams;
234
242
gpuuboCreationParams.canUpdateSubRange = true ;
235
- gpuuboCreationParams.usage = asset::IBuffer::EUF_UNIFORM_BUFFER_BIT;
236
- gpuuboCreationParams.sharingMode = asset::E_SHARING_MODE::ESM_CONCURRENT ;
243
+ gpuuboCreationParams.usage = core::bitflag< asset::IBuffer::E_USAGE_FLAGS>(asset::IBuffer:: EUF_UNIFORM_BUFFER_BIT) | asset::IBuffer::EUF_TRANSFER_DST_BIT ;
244
+ gpuuboCreationParams.sharingMode = asset::E_SHARING_MODE::ESM_EXCLUSIVE ;
237
245
gpuuboCreationParams.queueFamilyIndexCount = 0u ;
238
246
gpuuboCreationParams.queueFamilyIndices = nullptr ;
239
247
@@ -305,6 +313,7 @@ class MeshLoadersApp : public ApplicationBase
305
313
}
306
314
void onAppTerminated_impl () override
307
315
{
316
+ logicalDevice->waitIdle ();
308
317
}
309
318
void workLoopBody () override
310
319
{
@@ -344,36 +353,18 @@ class MeshLoadersApp : public ApplicationBase
344
353
viewport.width = WIN_W;
345
354
viewport.height = WIN_H;
346
355
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);
356
+
357
+ VkRect2D scissor = {};
358
+ scissor.offset = { 0 , 0 };
359
+ scissor.extent = { WIN_W, WIN_H };
360
+ commandBuffer->setScissor (0u , 1u , &scissor);
370
361
371
362
core::matrix3x4SIMD modelMatrix;
372
363
modelMatrix.setTranslation (nbl::core::vectorSIMDf (0 , 0 , 0 , 0 ));
373
-
374
364
core::matrix4SIMD mvp = core::concatenateBFollowedByA (viewProjectionMatrix, modelMatrix);
375
365
376
- core::vector<uint8_t > uboData (gpuubo->getSize ());
366
+ const size_t uboSize = gpuubo->getCachedCreationParams ().declaredSize ;
367
+ core::vector<uint8_t > uboData (uboSize);
377
368
for (const auto & shdrIn : pipelineMetadata->m_inputSemantics )
378
369
{
379
370
if (shdrIn.descriptorSection .type == asset::IRenderpassIndependentPipelineMetadata::ShaderInput::ET_UNIFORM_BUFFER && shdrIn.descriptorSection .uniformBufferObject .set == 1u && shdrIn.descriptorSection .uniformBufferObject .binding == ds1UboBinding)
@@ -397,8 +388,28 @@ class MeshLoadersApp : public ApplicationBase
397
388
}
398
389
}
399
390
}
391
+ commandBuffer->updateBuffer (gpuubo.get (), 0ull , uboSize, uboData.data ());
392
+
393
+ nbl::video::IGPUCommandBuffer::SRenderpassBeginInfo beginInfo;
394
+ {
395
+ VkRect2D area;
396
+ area.offset = { 0 ,0 };
397
+ area.extent = { WIN_W, WIN_H };
398
+ asset::SClearValue clear[2 ] = {};
399
+ clear[0 ].color .float32 [0 ] = 1 .f ;
400
+ clear[0 ].color .float32 [1 ] = 1 .f ;
401
+ clear[0 ].color .float32 [2 ] = 1 .f ;
402
+ clear[0 ].color .float32 [3 ] = 1 .f ;
403
+ clear[1 ].depthStencil .depth = 0 .f ;
400
404
401
- commandBuffer->updateBuffer (gpuubo.get (), 0ull , gpuubo->getSize (), uboData.data ());
405
+ beginInfo.clearValueCount = 2u ;
406
+ beginInfo.framebuffer = fbo[acquiredNextFBO];
407
+ beginInfo.renderpass = renderpass;
408
+ beginInfo.renderArea = area;
409
+ beginInfo.clearValues = clear;
410
+ }
411
+
412
+ commandBuffer->beginRenderPass (&beginInfo, nbl::asset::ESC_INLINE);
402
413
403
414
for (size_t i = 0 ; i < gpumesh->getMeshBuffers ().size (); ++i)
404
415
{
@@ -422,7 +433,8 @@ class MeshLoadersApp : public ApplicationBase
422
433
423
434
commandBuffer->endRenderPass ();
424
435
commandBuffer->end ();
425
-
436
+
437
+ logicalDevice->resetFences (1 , &fence.get ());
426
438
CommonAPI::Submit (logicalDevice.get (),
427
439
swapchain.get (),
428
440
commandBuffer.get (),
@@ -436,7 +448,7 @@ class MeshLoadersApp : public ApplicationBase
436
448
}
437
449
bool keepRunning () override
438
450
{
439
- return true ; // windowCb->isWindowOpen();
451
+ return windowCb->isWindowOpen ();
440
452
}
441
453
};
442
454
0 commit comments