@@ -63,6 +63,9 @@ class SubpassBaking : public ApplicationBase
63
63
core::smart_refctd_ptr<video::IGPUBuffer> cameraUBO;
64
64
video::CDumbPresentationOracle oracle;
65
65
const asset::COBJMetadata::CRenderpassIndependentPipeline* pipelineMetadata = nullptr ;
66
+
67
+ core::smart_refctd_ptr<video::IQueryPool> occlusionQueryPool;
68
+ core::smart_refctd_ptr<video::IQueryPool> timestampQueryPool;
66
69
67
70
uint32_t acquiredNextFBO = {};
68
71
int resourceIx = -1 ;
@@ -117,6 +120,25 @@ class SubpassBaking : public ApplicationBase
117
120
118
121
APP_CONSTRUCTOR (SubpassBaking)
119
122
123
+ void getAndLogQueryPoolResults ()
124
+ {
125
+ #ifdef QUERY_POOL_LOGS
126
+ bool all_results_available = false ;
127
+ uint64_t samples_passed[4 ] = {};
128
+ while (!all_results_available)
129
+ {
130
+ auto queryResultFlags = core::bitflag<video::IQueryPool::E_QUERY_RESULTS_FLAGS>(video::IQueryPool::EQRF_WITH_AVAILABILITY_BIT) | video::IQueryPool::EQRF_64_BIT;
131
+ logicalDevice->getQueryPoolResults (occlusionQueryPool.get (), 0u , 2u , sizeof (samples_passed), samples_passed, sizeof (uint64_t ) * 2 , queryResultFlags);
132
+
133
+ all_results_available = true ;
134
+ all_results_available &= samples_passed[1 ];
135
+ // all_results_available &= samples_passed[3];
136
+ }
137
+
138
+ logger->log (" SamplesPassed[0] = %d, SamplesPassed[1] = %d" , system::ILogger::ELL_INFO, samples_passed[0 ], samples_passed[2 ]);
139
+ #endif
140
+ }
141
+
120
142
void onAppInitialized_impl () override
121
143
{
122
144
CommonAPI::InitOutput initOutput;
@@ -142,6 +164,23 @@ class SubpassBaking : public ApplicationBase
142
164
windowCb = std::move (initOutput.windowCb );
143
165
cpu2gpuParams = std::move (initOutput.cpu2gpuParams );
144
166
utilities = std::move (initOutput.utilities );
167
+
168
+ // Occlusion Query
169
+ {
170
+ video::IQueryPool::SCreationParams queryPoolCreationParams = {};
171
+ queryPoolCreationParams.queryType = video::IQueryPool::EQT_OCCLUSION;
172
+ queryPoolCreationParams.queryCount = 2u ;
173
+ occlusionQueryPool = logicalDevice->createQueryPool (std::move (queryPoolCreationParams));
174
+ }
175
+
176
+ // Timestamp Query
177
+ video::IQueryPool::SCreationParams queryPoolCreationParams = {};
178
+ {
179
+ video::IQueryPool::SCreationParams queryPoolCreationParams = {};
180
+ queryPoolCreationParams.queryType = video::IQueryPool::EQT_TIMESTAMP;
181
+ queryPoolCreationParams.queryCount = 2u ;
182
+ timestampQueryPool = logicalDevice->createQueryPool (std::move (queryPoolCreationParams));
183
+ }
145
184
146
185
asset::ICPUMesh* meshRaw = nullptr ;
147
186
const asset::COBJMetadata* metaOBJ = nullptr ;
@@ -247,7 +286,7 @@ class SubpassBaking : public ApplicationBase
247
286
inheritanceInfo.renderpass = renderpass;
248
287
inheritanceInfo.subpass = 0 ; // this should probably be kSubpassIx?
249
288
// inheritanceInfo.framebuffer = ;
250
- // inheritanceInfo.occlusionQueryEnable = ;
289
+ inheritanceInfo.occlusionQueryEnable = true ;
251
290
// inheritanceInfo.queryFlags = ;
252
291
253
292
bakedCommandBuffer->begin (video::IGPUCommandBuffer::EU_RENDER_PASS_CONTINUE_BIT | video::IGPUCommandBuffer::EU_SIMULTANEOUS_USE_BIT, &inheritanceInfo);
@@ -543,15 +582,24 @@ class SubpassBaking : public ApplicationBase
543
582
beginInfo.clearValues = clear;
544
583
}
545
584
585
+ commandBuffer->resetQueryPool (occlusionQueryPool.get (), 0u , 2u );
586
+ commandBuffer->resetQueryPool (timestampQueryPool.get (), 0u , 2u );
587
+
588
+ commandBuffer->beginQuery (occlusionQueryPool.get (), 0u );
589
+
546
590
commandBuffer->beginRenderPass (&beginInfo, nbl::asset::ESC_SECONDARY_COMMAND_BUFFERS);
547
591
commandBuffer->executeCommands (1u , &bakedCommandBuffer.get ());
548
592
commandBuffer->endRenderPass ();
549
593
594
+ commandBuffer->endQuery (occlusionQueryPool.get (), 0u );
595
+
550
596
commandBuffer->end ();
551
597
}
552
598
553
599
CommonAPI::Submit (logicalDevice.get (), swapchain.get (), commandBuffer.get (), queues[CommonAPI::InitOutput::EQT_GRAPHICS], imageAcquire[resourceIx].get (), renderFinished[resourceIx].get (), fence.get ());
554
600
CommonAPI::Present (logicalDevice.get (), swapchain.get (), queues[CommonAPI::InitOutput::EQT_GRAPHICS], renderFinished[resourceIx].get (), acquiredNextFBO);
601
+
602
+ getAndLogQueryPoolResults ();
555
603
}
556
604
557
605
bool keepRunning () override
0 commit comments