wgpu_profiler/
profiler_command_recorder.rs

1/// Trait for exposing the methods of `wgpu::CommandEncoder`, `wgpu::RenderPass` and `wgpu::ComputePass` that are used by the profiler.
2pub trait ProfilerCommandRecorder {
3    /// Returns `true` if it's a pass or `false` if it's an encoder
4    fn is_pass(&self) -> bool;
5    fn write_timestamp(&mut self, query_set: &wgpu::QuerySet, query_index: u32);
6    fn push_debug_group(&mut self, label: &str);
7    fn pop_debug_group(&mut self);
8}
9
10macro_rules! ImplProfilerCommandRecorder {
11    ($($name:ident $(< $lt:lifetime >)? : $pass:literal,)*) => {
12        $(
13            impl $(< $lt >)? ProfilerCommandRecorder for wgpu::$name $(< $lt >)? {
14                fn is_pass(&self) -> bool { $pass }
15
16                fn write_timestamp(&mut self, query_set: &wgpu::QuerySet, query_index: u32) {
17                    self.write_timestamp(query_set, query_index)
18                }
19
20                fn push_debug_group(&mut self, label: &str) {
21                    self.push_debug_group(label)
22                }
23
24                fn pop_debug_group(&mut self) {
25                    self.pop_debug_group()
26                }
27            }
28        )*
29    };
30}
31
32ImplProfilerCommandRecorder!(CommandEncoder:false, RenderPass<'a>:true, ComputePass<'a>:true,);