diff --git a/tests/src/multiple_resolves_per_frame.rs b/tests/src/multiple_resolves_per_frame.rs index f54948a..6facda9 100644 --- a/tests/src/multiple_resolves_per_frame.rs +++ b/tests/src/multiple_resolves_per_frame.rs @@ -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), ) @@ -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); @@ -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}")); + } }