Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metal: improve push | pop_debug_marker #2537

Merged
merged 1 commit into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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