Skip to content

Commit

Permalink
add regression test for #82
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Sep 21, 2024
1 parent 7f225aa commit ea4cd1b
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions tests/src/multiple_resolves_per_frame.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Regression test for bug described in https://github.com/Wumpf/wgpu-profiler/issues/79
// Regression test for bug described in
// * https://github.com/Wumpf/wgpu-profiler/issues/79
// * https://github.com/Wumpf/wgpu-profiler/issues/82
#[test]
fn multiple_resolves_per_frame() {
const NUM_SCOPES: usize = 1000;

let (_, device, queue) = super::create_device(
wgpu::Features::TIMESTAMP_QUERY.union(wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS),
)
Expand All @@ -13,14 +17,14 @@ fn multiple_resolves_per_frame() {
let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor::default());

// Resolve call per scope.
{
let _ = profiler.scope("testscope0", &mut encoder, &device);
}
profiler.resolve_queries(&mut encoder);
{
let _ = profiler.scope("testscope1", &mut encoder, &device);
// Do this many times to check for potential buffer overflows as found in
// https://github.com/Wumpf/wgpu-profiler/issues/82
for i in 0..NUM_SCOPES {
{
let _ = profiler.scope(format!("{i}"), &mut encoder, &device);
}
profiler.resolve_queries(&mut encoder);
}
profiler.resolve_queries(&mut encoder);

// And an extra resolve for good measure (this should be a no-op).
profiler.resolve_queries(&mut encoder);
Expand All @@ -31,8 +35,12 @@ fn multiple_resolves_per_frame() {
// Poll to explicitly trigger mapping callbacks.
device.poll(wgpu::Maintain::Wait);

// Frame should now be available.
assert!(profiler
// Frame should now be available and contain all the scopes.
let scopes = profiler
.process_finished_frame(queue.get_timestamp_period())
.is_some());
.unwrap();
assert_eq!(scopes.len(), NUM_SCOPES);
for (i, scope) in scopes.iter().enumerate() {
assert_eq!(scope.label, format!("{i}"));
}
}

0 comments on commit ea4cd1b

Please sign in to comment.