1170{
1173 return { .label = label, .duration_ns = 0, .valid = false };
1174 }
1175
1176 auto query_it = it->second.timestamp_queries.find(label);
1177 if (query_it == it->second.timestamp_queries.end()) {
1178 return { .label = label, .duration_ns = 0, .valid = false };
1179 }
1180
1181 if (!it->second.timestamp_pool) {
1182 return { .label = label, .duration_ns = 0, .valid = false };
1183 }
1184
1185 uint32_t query_index = query_it->second;
1186 uint64_t timestamps[2];
1187
1188 auto result =
get_device().getQueryPoolResults(
1189 it->second.timestamp_pool,
1190 query_index,
1191 2,
1192 sizeof(timestamps),
1193 timestamps,
1194 sizeof(uint64_t),
1195 vk::QueryResultFlagBits::e64 | vk::QueryResultFlagBits::eWait);
1196
1197 if (result != vk::Result::eSuccess) {
1198 return { .label = label, .duration_ns = 0, .valid = false };
1199 }
1200
1201 auto props =
m_backend->get_context().get_physical_device().getProperties();
1202 float timestamp_period = props.limits.timestampPeriod;
1203
1204 auto duration_ns = static_cast<uint64_t>((timestamps[1] - timestamps[0]) * timestamp_period);
1205
1206 return { .label = label, .duration_ns = duration_ns, .valid = true };
1207}
vk::Device get_device() const
std::unordered_map< CommandBufferID, CommandBufferState > m_command_buffers
std::shared_ptr< Core::VulkanBackend > m_backend