From a3d3f39fbd110c81bf833a08b0808eb067cf8ab3 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Mon, 18 Oct 2021 12:23:06 -0700 Subject: [PATCH] Wait on query results This shouldn't be necessary, but was causing NOT_READY errors. --- piet-gpu-hal/src/vulkan.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/piet-gpu-hal/src/vulkan.rs b/piet-gpu-hal/src/vulkan.rs index 5b0dfd6..e1d78f2 100644 --- a/piet-gpu-hal/src/vulkan.rs +++ b/piet-gpu-hal/src/vulkan.rs @@ -708,12 +708,16 @@ impl crate::backend::Device for VkDevice { unsafe fn fetch_query_pool(&self, pool: &Self::QueryPool) -> Result, Error> { let device = &self.device.device; let mut buf = vec![0u64; pool.n_queries as usize]; + // It's unclear to me why WAIT is needed here, as the wait on the command buffer's + // fence should make the query available, but otherwise we get sporadic NOT_READY + // results (Windows 10, AMD 5700 XT). + let flags = vk::QueryResultFlags::TYPE_64 | vk::QueryResultFlags::WAIT; device.get_query_pool_results( pool.pool, 0, pool.n_queries, &mut buf, - vk::QueryResultFlags::TYPE_64, + flags, )?; let ts0 = buf[0]; let tsp = self.timestamp_period as f64 * 1e-9;