diff --git a/wgpu/examples/cube/main.rs b/wgpu/examples/cube/main.rs index 65a1c81d21..5488c5eb26 100644 --- a/wgpu/examples/cube/main.rs +++ b/wgpu/examples/cube/main.rs @@ -341,10 +341,13 @@ impl framework::Example for Example { }], depth_stencil_attachment: None, }); + rpass.push_debug_group("Prepare data for draw."); rpass.set_pipeline(&self.pipeline); rpass.set_bind_group(0, &self.bind_group, &[]); rpass.set_index_buffer(self.index_buf.slice(..)); rpass.set_vertex_buffer(0, self.vertex_buf.slice(..)); + rpass.pop_debug_group(); + rpass.insert_debug_marker("Draw!"); rpass.draw_indexed(0..self.index_count as u32, 0, 0..1); } diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index 5cfbf20a86..57ab832e6f 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -169,6 +169,26 @@ mod pass_impl { unsafe { wgpu_render_pass_set_stencil_reference(self, reference) } } + fn insert_debug_marker(&mut self, label: &str) { + unsafe { + let label = std::ffi::CString::new(label).unwrap(); + wgpu_render_pass_insert_debug_marker(self, label.as_ptr().into(), 0); + } + } + + fn push_debug_group(&mut self, group_label: &str) { + unsafe { + let label = std::ffi::CString::new(group_label).unwrap(); + wgpu_render_pass_push_debug_group(self, label.as_ptr().into(), 0); + } + } + + fn pop_debug_group(&mut self) { + unsafe { + wgpu_render_pass_pop_debug_group(self); + } + } + fn execute_bundles<'a, I: Iterator>( &mut self, render_bundles: I, diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index 0369f8439b..e2744d3fa5 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -184,6 +184,19 @@ impl crate::RenderPassInner for RenderPass { fn set_stencil_reference(&mut self, reference: u32) { self.0.set_stencil_reference(reference); } + + fn insert_debug_marker(&mut self, label: &str) { + unimplemented!() + } + + fn push_debug_group(&mut self, group_label: &str) { + unimplemented!() + } + + fn pop_debug_group(&mut self) { + unimplemented!() + } + fn execute_bundles<'a, I: Iterator>(&mut self, render_bundles: I) { unimplemented!() } diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index f7226ee177..977f25755d 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -90,6 +90,9 @@ trait RenderPassInner: RenderInner { max_depth: f32, ); fn set_stencil_reference(&mut self, reference: u32); + fn insert_debug_marker(&mut self, label: &str); + fn push_debug_group(&mut self, group_label: &str); + fn pop_debug_group(&mut self); fn execute_bundles<'a, I: Iterator>( &mut self, render_bundles: I, @@ -1601,6 +1604,21 @@ impl<'a> RenderPass<'a> { RenderInner::draw(&mut self.id, vertices, instances) } + /// Inserts debug marker. + pub fn insert_debug_marker(&mut self, label: &str) { + self.id.insert_debug_marker(label); + } + + /// Start record commands and group it into debug marker group. + pub fn push_debug_group(&mut self, label: &str) { + self.id.push_debug_group(label); + } + + /// Stops command recording and creates debug group. + pub fn pop_debug_group(&mut self) { + self.id.pop_debug_group(); + } + /// Draws indexed primitives using the active index buffer and the active vertex buffers. /// /// The active index buffer can be set with [`RenderPass::set_index_buffer`], while the active