use wgpu_profiler::GpuProfilerSettings;
use super::create_device;
#[test]
fn handle_dropped_frames_gracefully() {
let (_, device, queue) = create_device(
wgpu::Features::TIMESTAMP_QUERY.union(wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS),
)
.unwrap();
let mut profiler = wgpu_profiler::GpuProfiler::new(
&device,
GpuProfilerSettings {
max_num_pending_frames: 1,
..Default::default()
},
)
.unwrap();
for _ in 0..2 {
let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor::default());
{
let _ = profiler.scope("testscope", &mut encoder);
}
profiler.resolve_queries(&mut encoder);
profiler.end_frame().unwrap();
assert!(profiler
.process_finished_frame(queue.get_timestamp_period())
.is_none());
}
device.poll(wgpu::PollType::wait_indefinitely()).unwrap();
assert!(profiler
.process_finished_frame(queue.get_timestamp_period())
.is_some());
assert!(profiler
.process_finished_frame(queue.get_timestamp_period())
.is_none());
}