Reset query pool before use

Quiets validation errors now that we can see them :)
This commit is contained in:
Raph Levien 2020-04-29 18:13:56 -07:00
parent 144f46c5fa
commit aa8b71e922
5 changed files with 26 additions and 0 deletions

7
Cargo.lock generated
View file

@ -114,6 +114,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "once_cell"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b"
[[package]]
name = "piet"
version = "0.0.12"
@ -149,6 +155,7 @@ name = "piet-gpu-hal"
version = "0.1.0"
dependencies = [
"ash",
"once_cell",
]
[[package]]

View file

@ -17,6 +17,7 @@ fn main() {
let query_pool = device.create_query_pool(2).unwrap();
let mut cmd_buf = device.create_cmd_buf().unwrap();
cmd_buf.begin();
cmd_buf.reset_query_pool(&query_pool);
cmd_buf.write_timestamp(&query_pool, 0);
cmd_buf.dispatch(&pipeline, &descriptor_set, (256, 1, 1));
cmd_buf.write_timestamp(&query_pool, 1);

View file

@ -80,6 +80,13 @@ pub trait CmdBuf<D: Device> {
unsafe fn copy_buffer(&self, src: &D::Buffer, dst: &D::Buffer);
/// Reset the query pool.
///
/// The query pool must be reset before each use, to avoid validation errors.
/// This is annoying, and we could tweak the API to make it implicit, doing
/// the reset before the first timestamp write.
unsafe fn reset_query_pool(&mut self, pool: &D::QueryPool);
unsafe fn write_timestamp(&mut self, pool: &D::QueryPool, query: u32);
}

View file

@ -573,6 +573,16 @@ impl crate::CmdBuf<VkDevice> for CmdBuf {
);
}
unsafe fn reset_query_pool(&mut self, pool: &QueryPool) {
let device = &self.device.device;
device.cmd_reset_query_pool(
self.cmd_buf,
pool.pool,
0,
pool.n_queries,
);
}
unsafe fn write_timestamp(&mut self, pool: &QueryPool, query: u32) {
let device = &self.device.device;
device.cmd_write_timestamp(

View file

@ -181,6 +181,7 @@ fn main() {
cmd_buf.clear_buffer(&tilegroup_buf);
cmd_buf.clear_buffer(&ptcl_buf);
cmd_buf.memory_barrier();
cmd_buf.reset_query_pool(&query_pool);
cmd_buf.write_timestamp(&query_pool, 0);
cmd_buf.dispatch(
&k1_pipeline,