1155{
1158 return { .label = label, .duration_ns = 0, .valid = false };
1159 }
1160
1161 auto query_it = it->second.timestamp_queries.find(label);
1162 if (query_it == it->second.timestamp_queries.end()) {
1163 return { .label = label, .duration_ns = 0, .valid = false };
1164 }
1165
1166 if (!it->second.timestamp_pool) {
1167 return { .label = label, .duration_ns = 0, .valid = false };
1168 }
1169
1170 uint32_t query_index = query_it->second;
1171 uint64_t timestamps[2];
1172
1173 auto result =
get_device().getQueryPoolResults(
1174 it->second.timestamp_pool,
1175 query_index,
1176 2,
1177 sizeof(timestamps),
1178 timestamps,
1179 sizeof(uint64_t),
1180 vk::QueryResultFlagBits::e64 | vk::QueryResultFlagBits::eWait);
1181
1182 if (result != vk::Result::eSuccess) {
1183 return { .label = label, .duration_ns = 0, .valid = false };
1184 }
1185
1186 auto props =
m_backend->get_context().get_physical_device().getProperties();
1187 float timestamp_period = props.limits.timestampPeriod;
1188
1189 auto duration_ns = static_cast<uint64_t>((timestamps[1] - timestamps[0]) * timestamp_period);
1190
1191 return { .label = label, .duration_ns = duration_ns, .valid = true };
1192}
vk::Device get_device() const
std::unordered_map< CommandBufferID, CommandBufferState > m_command_buffers
std::shared_ptr< Core::VulkanBackend > m_backend