Skip to content

Commit

Permalink
[rs] Merge gfx-rs#374
Browse files Browse the repository at this point in the history
374: Add debug markers and debug markers example r=kvark a=krupitskas

Depends on gfx-rs#719

Co-authored-by: Nikita Krupitskas <krupitskas@icloud.com>
  • Loading branch information
bors[bot] and krupitskas authored Jun 17, 2020
2 parents fa5b6bd + 6a0a4d6 commit 0d807b7
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions wgpu/examples/cube/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
20 changes: 20 additions & 0 deletions wgpu/src/backend/direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item = &'a wgc::id::RenderBundleId>>(
&mut self,
render_bundles: I,
Expand Down
13 changes: 13 additions & 0 deletions wgpu/src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,19 @@ impl crate::RenderPassInner<Context> 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<Item = &'a ()>>(&mut self, render_bundles: I) {
unimplemented!()
}
Expand Down
18 changes: 18 additions & 0 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ trait RenderPassInner<Ctx: Context>: RenderInner<Ctx> {
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<Item = &'a Ctx::RenderBundleId>>(
&mut self,
render_bundles: I,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0d807b7

Please sign in to comment.