Skip to content

Commit

Permalink
metal: improve push | pop_debug_marker
Browse files Browse the repository at this point in the history
  • Loading branch information
jinleili authored and kvark committed Mar 15, 2022
1 parent 73f4235 commit ba07db9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wgpu-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ winapi = { version = "0.3", features = ["libloaderapi", "windef", "winuser", "dc
native = { package = "d3d12", git = "https://github.com/gfx-rs/d3d12-rs.git", rev = "ffe5e261da0a6cb85332b82ab310abd2a7e849f6", features = ["libloading"], optional = true }

[target.'cfg(any(target_os="macos", target_os="ios"))'.dependencies]
mtl = { package = "metal", git = "https://github.com/gfx-rs/metal-rs", rev = "a357159" }
mtl = { package = "metal", git = "https://github.com/gfx-rs/metal-rs", rev = "1aaa903" }
objc = "0.2.5"
core-graphics-types = "0.1"

Expand Down
26 changes: 19 additions & 7 deletions wgpu-hal/src/metal/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ impl super::CommandEncoder {
}
}

fn enter_any(&mut self) -> &mtl::CommandEncoderRef {
fn enter_any(&mut self) -> Option<&mtl::CommandEncoderRef> {
if let Some(ref encoder) = self.state.render {
encoder
Some(encoder)
} else if let Some(ref encoder) = self.state.compute {
encoder
Some(encoder)
} else if let Some(ref encoder) = self.state.blit {
Some(encoder)
} else {
self.enter_blit()
None
}
}

Expand Down Expand Up @@ -627,13 +629,23 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
}

unsafe fn insert_debug_marker(&mut self, label: &str) {
self.enter_any().insert_debug_signpost(label);
if let Some(encoder) = self.enter_any() {
encoder.insert_debug_signpost(label);
}
}
unsafe fn begin_debug_marker(&mut self, group_label: &str) {
self.enter_any().push_debug_group(group_label);
if let Some(encoder) = self.enter_any() {
encoder.push_debug_group(group_label);
} else if let Some(ref buf) = self.raw_cmd_buf {
buf.push_debug_group(group_label);
}
}
unsafe fn end_debug_marker(&mut self) {
self.enter_any().pop_debug_group();
if let Some(encoder) = self.enter_any() {
encoder.pop_debug_group();
} else if let Some(ref buf) = self.raw_cmd_buf {
buf.pop_debug_group();
}
}

unsafe fn set_render_pipeline(&mut self, pipeline: &super::RenderPipeline) {
Expand Down

0 comments on commit ba07db9

Please sign in to comment.