1453{
1454 auto query_it = state.timestamp_queries.find(
label);
1455 if (query_it == state.timestamp_queries.end() || !state.timestamp_pool) {
1456 return { .label =
label, .duration_ns = 0, .valid =
false };
1457 }
1458
1459 uint32_t query_index = query_it->second;
1460 uint64_t timestamps[2];
1461
1462 vk::QueryResultFlags flags = vk::QueryResultFlagBits::e64;
1463 if (wait) {
1464 flags |= vk::QueryResultFlagBits::eWait;
1465 }
1466
1467 auto result =
get_device().getQueryPoolResults(
1468 state.timestamp_pool,
1469 query_index,
1470 2,
1471 sizeof(timestamps),
1472 timestamps,
1473 sizeof(uint64_t),
1474 flags);
1475
1476 if (result != vk::Result::eSuccess) {
1477 return { .label =
label, .duration_ns = 0, .valid =
false };
1478 }
1479
1480 auto props =
m_backend->get_context().get_physical_device().getProperties();
1481 float timestamp_period = props.limits.timestampPeriod;
1482
1483 auto duration_ns = static_cast<uint64_t>((timestamps[1] - timestamps[0]) * timestamp_period);
1484
1485 return { .label =
label, .duration_ns = duration_ns, .valid =
true };
1486}
vk::Device get_device() const
Get logical device handle.
std::shared_ptr< Core::VulkanBackend > m_backend