@@ -88,6 +88,8 @@ class MeshLoadersApp : public ApplicationBase
88
88
double dtList[NBL_FRAMES_TO_AVERAGE] = {};
89
89
90
90
video::CDumbPresentationOracle oracle;
91
+
92
+ core::smart_refctd_ptr<video::IGPUBuffer> queryResultsBuffer;
91
93
92
94
auto createDescriptorPool (const uint32_t textureCount)
93
95
{
@@ -190,7 +192,7 @@ class MeshLoadersApp : public ApplicationBase
190
192
const auto swapchainImageUsage = static_cast <asset::IImage::E_USAGE_FLAGS>(asset::IImage::EUF_COLOR_ATTACHMENT_BIT);
191
193
const video::ISurface::SFormat surfaceFormat (asset::EF_R8G8B8A8_SRGB, asset::ECP_SRGB, asset::EOTF_sRGB);
192
194
193
- CommonAPI::InitWithDefaultExt (initOutput, video::EAT_OPENGL , " MeshLoaders" , WIN_W, WIN_H, SC_IMG_COUNT, swapchainImageUsage, surfaceFormat, nbl::asset::EF_D32_SFLOAT);
195
+ CommonAPI::InitWithDefaultExt (initOutput, video::EAT_VULKAN , " MeshLoaders" , WIN_W, WIN_H, SC_IMG_COUNT, swapchainImageUsage, surfaceFormat, nbl::asset::EF_D32_SFLOAT);
194
196
window = std::move (initOutput.window );
195
197
windowCb = std::move (initOutput.windowCb );
196
198
apiConnection = std::move (initOutput.apiConnection );
@@ -226,6 +228,22 @@ class MeshLoadersApp : public ApplicationBase
226
228
timestampQueryPool = logicalDevice->createQueryPool (std::move (queryPoolCreationParams));
227
229
}
228
230
231
+ {
232
+ // SAMPLES_PASSED_0 + AVAILABILIY_0 + SAMPLES_PASSED_1 + AVAILABILIY_1 (uint32_t)
233
+ const size_t queriesSize = sizeof (uint32_t ) * 4 ;
234
+ auto memreq = logicalDevice->getDeviceLocalGPUMemoryReqs ();
235
+ memreq.vulkanReqs .size = queriesSize;
236
+ video::IGPUBuffer::SCreationParams gpuuboCreationParams;
237
+ gpuuboCreationParams.canUpdateSubRange = true ;
238
+ gpuuboCreationParams.usage = core::bitflag<asset::IBuffer::E_USAGE_FLAGS>(asset::IBuffer::EUF_UNIFORM_BUFFER_BIT) | asset::IBuffer::EUF_TRANSFER_DST_BIT;
239
+ gpuuboCreationParams.sharingMode = asset::E_SHARING_MODE::ESM_EXCLUSIVE;
240
+ gpuuboCreationParams.queueFamilyIndexCount = 0u ;
241
+ gpuuboCreationParams.queueFamilyIndices = nullptr ;
242
+
243
+ queryResultsBuffer = logicalDevice->createGPUBufferOnDedMem (gpuuboCreationParams, memreq);
244
+ queryResultsBuffer->setObjectDebugName (" QueryResults" );
245
+ }
246
+
229
247
nbl::video::IGPUObjectFromAssetConverter cpu2gpu;
230
248
{
231
249
auto * quantNormalCache = assetManager->getMeshManipulator ()->getQuantNormalCache ();
@@ -502,11 +520,15 @@ class MeshLoadersApp : public ApplicationBase
502
520
commandBuffer->drawMeshBuffer (gpuMeshBuffer);
503
521
504
522
if (i < 2 )
505
- commandBuffer->endQuery (occlusionQueryPool.get (), i);
523
+ commandBuffer->endQuery (occlusionQueryPool.get (), i);
506
524
}
507
525
commandBuffer->writeTimestamp (asset::E_PIPELINE_STAGE_FLAGS::EPSF_BOTTOM_OF_PIPE_BIT, timestampQueryPool.get (), 1u );
508
526
509
527
commandBuffer->endRenderPass ();
528
+
529
+ auto queryResultFlags = core::bitflag<video::IQueryPool::E_QUERY_RESULTS_FLAGS>(video::IQueryPool::EQRF_WAIT_BIT) | video::IQueryPool::EQRF_WITH_AVAILABILITY_BIT;
530
+ commandBuffer->copyQueryPoolResults (occlusionQueryPool.get (), 0 , 2 , queryResultsBuffer.get (), 0u , sizeof (uint32_t ) * 2 , queryResultFlags);
531
+
510
532
commandBuffer->end ();
511
533
512
534
logicalDevice->resetFences (1 , &fence.get ());
0 commit comments