| 1314 | } |
| 1315 | |
| 1316 | uint64 GPUContextVulkan::BeginQuery(GPUQueryType type) |
| 1317 | { |
| 1318 | // Check if timer queries are supported |
| 1319 | if (type == GPUQueryType::Timer && _device->PhysicalDeviceLimits.timestampComputeAndGraphics != VK_TRUE) |
| 1320 | return 0; |
| 1321 | |
| 1322 | // Allocate query |
| 1323 | auto poolIndex = _device->GetOrCreateQueryPool(type); |
| 1324 | auto pool = _device->QueryPools[poolIndex]; |
| 1325 | uint32 index = 0; |
| 1326 | const auto cmdBuffer = _cmdBufferManager->GetCmdBuffer(); |
| 1327 | if (!pool->AcquireQuery(cmdBuffer, index)) |
| 1328 | return 0; |
| 1329 | GPUQueryVulkan query; |
| 1330 | query.PoolIndex = (uint16)poolIndex; |
| 1331 | query.QueryIndex = (uint16)index; |
| 1332 | query.SecondQueryIndex = 0; |
| 1333 | query.Dummy = 1; // Ensure Raw is never 0, even for the first query |
| 1334 | |
| 1335 | // Begin query |
| 1336 | switch (type) |
| 1337 | { |
| 1338 | case GPUQueryType::Timer: |
| 1339 | // Timer queries need 2 slots (begin + end) |
| 1340 | pool->AcquireQuery(cmdBuffer, index); |
| 1341 | query.SecondQueryIndex = (uint16)index; |
| 1342 | |
| 1343 | vkCmdWriteTimestamp(cmdBuffer->GetHandle(), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, pool->GetHandle(), query.QueryIndex); |
| 1344 | #if GPU_VULKAN_PAUSE_QUERIES |
| 1345 | _cmdBufferManager->OnTimerQueryBegin(query.Raw); |
| 1346 | #endif |
| 1347 | break; |
| 1348 | case GPUQueryType::Occlusion: |
| 1349 | vkCmdBeginQuery(cmdBuffer->GetHandle(), pool->GetHandle(), query.QueryIndex, 0); |
| 1350 | break; |
| 1351 | } |
| 1352 | pool->MarkQueryAsStarted(query.QueryIndex); |
| 1353 | |
| 1354 | return query.Raw; |
| 1355 | } |
| 1356 | |
| 1357 | void GPUContextVulkan::EndQuery(uint64 queryID) |
| 1358 | { |
no test coverage detected