mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-09 20:31:29 +11:00
Merge pull request #52 from linebender/fix_query_pool
Fetch correct query pool
This commit is contained in:
commit
56aaf7c19a
|
@ -45,6 +45,7 @@ fn main() -> Result<(), Error> {
|
||||||
let renderer = Renderer::new(&session, scene, n_paths, n_pathseg)?;
|
let renderer = Renderer::new(&session, scene, n_paths, n_pathseg)?;
|
||||||
|
|
||||||
let mut submitted: Option<hub::SubmittedCmdBuf> = None;
|
let mut submitted: Option<hub::SubmittedCmdBuf> = None;
|
||||||
|
let mut last_frame_idx = 0;
|
||||||
|
|
||||||
event_loop.run(move |event, _, control_flow| {
|
event_loop.run(move |event, _, control_flow| {
|
||||||
*control_flow = ControlFlow::Poll; // `ControlFlow::Wait` if only re-render on event
|
*control_flow = ControlFlow::Poll; // `ControlFlow::Wait` if only re-render on event
|
||||||
|
@ -63,12 +64,16 @@ fn main() -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
Event::RedrawRequested(window_id) if window_id == window.id() => {
|
Event::RedrawRequested(window_id) if window_id == window.id() => {
|
||||||
let frame_idx = current_frame % NUM_FRAMES;
|
let frame_idx = current_frame % NUM_FRAMES;
|
||||||
let query_pool = &query_pools[frame_idx];
|
|
||||||
|
|
||||||
|
// Note: this logic is a little strange. We have two sets of renderer
|
||||||
|
// resources, so we could have two frames in flight (submit two, wait on
|
||||||
|
// the first), but we actually just wait on the last submitted.
|
||||||
|
//
|
||||||
|
// Getting this right will take some thought.
|
||||||
if let Some(submitted) = submitted.take() {
|
if let Some(submitted) = submitted.take() {
|
||||||
submitted.wait().unwrap();
|
submitted.wait().unwrap();
|
||||||
|
|
||||||
let ts = session.fetch_query_pool(query_pool).unwrap();
|
let ts = session.fetch_query_pool(&query_pools[last_frame_idx]).unwrap();
|
||||||
window.set_title(&format!(
|
window.set_title(&format!(
|
||||||
"{:.3}ms :: e:{:.3}ms|alloc:{:.3}ms|cp:{:.3}ms|bd:{:.3}ms|bin:{:.3}ms|cr:{:.3}ms|r:{:.3}ms",
|
"{:.3}ms :: e:{:.3}ms|alloc:{:.3}ms|cp:{:.3}ms|bd:{:.3}ms|bin:{:.3}ms|cr:{:.3}ms|r:{:.3}ms",
|
||||||
ts[6] * 1e3,
|
ts[6] * 1e3,
|
||||||
|
@ -82,8 +87,10 @@ fn main() -> Result<(), Error> {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let (image_idx, acquisition_semaphore) = swapchain.next().unwrap();
|
let (image_idx, acquisition_semaphore) = swapchain.next().unwrap();
|
||||||
let swap_image = swapchain.image(image_idx);
|
let swap_image = swapchain.image(image_idx);
|
||||||
|
let query_pool = &query_pools[frame_idx];
|
||||||
let mut cmd_buf = session.cmd_buf().unwrap();
|
let mut cmd_buf = session.cmd_buf().unwrap();
|
||||||
cmd_buf.begin();
|
cmd_buf.begin();
|
||||||
renderer.record(&mut cmd_buf, &query_pool);
|
renderer.record(&mut cmd_buf, &query_pool);
|
||||||
|
@ -105,6 +112,7 @@ fn main() -> Result<(), Error> {
|
||||||
&[present_semaphores[frame_idx]],
|
&[present_semaphores[frame_idx]],
|
||||||
)
|
)
|
||||||
.unwrap());
|
.unwrap());
|
||||||
|
last_frame_idx = frame_idx;
|
||||||
|
|
||||||
swapchain
|
swapchain
|
||||||
.present(image_idx, &[present_semaphores[frame_idx]])
|
.present(image_idx, &[present_semaphores[frame_idx]])
|
||||||
|
|
Loading…
Reference in a new issue