Skip to content

Commit

Permalink
fixup! Make it possible to filter labels out.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblandy committed Oct 18, 2023
1 parent a9c3a6f commit 4f4ba31
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 32 deletions.
16 changes: 12 additions & 4 deletions wgpu-core/src/command/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,9 @@ impl RenderBundleEncoder {
texture_memory_init_actions,
context: self.context,
life_guard: LifeGuard::new(desc.label.borrow_or_default()),
discard_hal_labels: device
.instance_flags
.contains(wgt::InstanceFlags::DISCARD_HAL_LABELS),
})
}

Expand Down Expand Up @@ -746,6 +749,7 @@ pub struct RenderBundle<A: HalApi> {
pub(super) texture_memory_init_actions: Vec<TextureInitTrackerAction>,
pub(super) context: RenderPassContext,
pub(crate) life_guard: LifeGuard,
discard_hal_labels: bool,
}

#[cfg(any(
Expand Down Expand Up @@ -788,8 +792,10 @@ impl<A: HalApi> RenderBundle<A> {
) -> Result<(), ExecutionError> {
let mut offsets = self.base.dynamic_offsets.as_slice();
let mut pipeline_layout_id = None::<id::Valid<id::PipelineLayoutId>>;
if let Some(ref label) = self.base.label {
unsafe { raw.begin_debug_marker(label) };
if !self.discard_hal_labels {
if let Some(ref label) = self.base.label {
unsafe { raw.begin_debug_marker(label) };
}
}

for command in self.base.commands.iter() {
Expand Down Expand Up @@ -966,8 +972,10 @@ impl<A: HalApi> RenderBundle<A> {
}
}

if let Some(_) = self.base.label {
unsafe { raw.end_debug_marker() };
if !self.discard_hal_labels {
if let Some(_) = self.base.label {
unsafe { raw.end_debug_marker() };
}
}

Ok(())
Expand Down
16 changes: 8 additions & 8 deletions wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,11 +776,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}
ComputeCommand::PushDebugGroup { color: _, len } => {
state.debug_scope_depth += 1;
let label =
str::from_utf8(&base.string_data[string_offset..string_offset + len])
.unwrap();
string_offset += len;
if !discard_hal_labels {
let label =
str::from_utf8(&base.string_data[string_offset..string_offset + len])
.unwrap();
string_offset += len;
unsafe {
raw.begin_debug_marker(label);
}
Expand All @@ -801,11 +801,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}
}
ComputeCommand::InsertDebugMarker { color: _, len } => {
let label =
str::from_utf8(&base.string_data[string_offset..string_offset + len])
.unwrap();
string_offset += len;
if !discard_hal_labels {
let label =
str::from_utf8(&base.string_data[string_offset..string_offset + len])
.unwrap();
string_offset += len;
unsafe { raw.insert_debug_marker(label) }
}
}
Expand Down
32 changes: 25 additions & 7 deletions wgpu-core/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}

let cmd_buf_raw = cmd_buf.encoder.open();
unsafe {
cmd_buf_raw.begin_debug_marker(label);
if !self
.instance
.flags
.contains(wgt::InstanceFlags::DISCARD_HAL_LABELS)
{
unsafe {
cmd_buf_raw.begin_debug_marker(label);
}
}
Ok(())
}
Expand All @@ -430,9 +436,15 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
list.push(TraceCommand::InsertDebugMarker(label.to_string()));
}

let cmd_buf_raw = cmd_buf.encoder.open();
unsafe {
cmd_buf_raw.insert_debug_marker(label);
if !self
.instance
.flags
.contains(wgt::InstanceFlags::DISCARD_HAL_LABELS)
{
let cmd_buf_raw = cmd_buf.encoder.open();
unsafe {
cmd_buf_raw.insert_debug_marker(label);
}
}
Ok(())
}
Expand All @@ -456,8 +468,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}

let cmd_buf_raw = cmd_buf.encoder.open();
unsafe {
cmd_buf_raw.end_debug_marker();
if !self
.instance
.flags
.contains(wgt::InstanceFlags::DISCARD_HAL_LABELS)
{
unsafe {
cmd_buf_raw.end_debug_marker();
}
}
Ok(())
}
Expand Down
24 changes: 11 additions & 13 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2163,14 +2163,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}
RenderCommand::PushDebugGroup { color: _, len } => {
state.debug_scope_depth += 1;
if !discard_hal_labels {
let label = str::from_utf8(
&base.string_data[string_offset..string_offset + len],
)
.unwrap();
let label =
str::from_utf8(&base.string_data[string_offset..string_offset + len])
.unwrap();

log::trace!("RenderPass::push_debug_group {label:?}");
string_offset += len;
log::trace!("RenderPass::push_debug_group {label:?}");
string_offset += len;
if !discard_hal_labels {
unsafe {
raw.begin_debug_marker(label);
}
Expand All @@ -2192,13 +2191,12 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}
}
RenderCommand::InsertDebugMarker { color: _, len } => {
let label =
str::from_utf8(&base.string_data[string_offset..string_offset + len])
.unwrap();
log::trace!("RenderPass::insert_debug_marker {label:?}");
string_offset += len;
if !discard_hal_labels {
let label = str::from_utf8(
&base.string_data[string_offset..string_offset + len],
)
.unwrap();
log::trace!("RenderPass::insert_debug_marker {label:?}");
string_offset += len;
unsafe {
raw.insert_debug_marker(label);
}
Expand Down

0 comments on commit 4f4ba31

Please sign in to comment.