From 187cb415ac97ae9f68db02d160782263c63194ec Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Wed, 12 Aug 2026 17:40:18 +0200 Subject: [PATCH 1/3] Call RenderPass::end from Global::render_pass_end Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- wgpu-core/src/command/render.rs | 38 +-------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 216c93fe436..3c4f04bd827 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -2271,43 +2271,7 @@ impl Global { } pub fn render_pass_end(&self, pass: &mut RenderPass) -> Result<(), EncoderStateError> { - profiling::scope!( - "CommandEncoder::run_render_pass {}", - pass.base.label.as_deref().unwrap_or("") - ); - - let cmd_enc = pass.parent.take().ok_or(EncoderStateError::Ended)?; - let mut cmd_buf_data = cmd_enc.data.lock(); - - cmd_buf_data.unlock_encoder()?; - - let base = pass.base.take(); - - if let Err(RenderPassError { inner, scope: _ }) = &base { - if let RenderPassErrorInner::EncoderState( - err @ (EncoderStateError::Locked | EncoderStateError::Ended), - ) = inner.as_ref() - { - // Most encoding errors are detected and raised within `finish()`. - // - // However, we raise a validation error here if the pass was opened - // within another pass, or on a finished encoder. The latter is - // particularly important, because in that case reporting errors via - // `CommandEncoder::finish` is not possible. - return Err(err.clone()); - } - } - - cmd_buf_data.push_with(|| -> Result<_, RenderPassError> { - Ok(ArcCommand::RunRenderPass { - pass: base?, - color_attachments: SmallVec::from(pass.color_attachments.as_slice()), - depth_stencil_attachment: pass.depth_stencil_attachment.take(), - timestamp_writes: pass.timestamp_writes.take(), - occlusion_query_set: pass.occlusion_query_set.take(), - multiview_mask: pass.multiview_mask, - }) - }) + pass.end() } pub fn render_pass_end_with_id( From 3e720aa5f57a172b9882508195f98a84ce56387e Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Wed, 12 Aug 2026 17:41:28 +0200 Subject: [PATCH 2/3] move trace inside Queue::write_texture Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- wgpu-core/src/device/queue.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index 01874269bc2..f718e84a209 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -912,6 +912,18 @@ impl Queue { profiling::scope!("Queue::write_texture"); api_log!("Queue::write_texture"); + #[cfg(feature = "trace")] + if let Some(ref mut trace) = *self.device.trace.lock() { + use crate::device::trace::DataKind; + let data = trace.make_binary(DataKind::Bin, data); + trace.add(Action::WriteTexture { + to: destination.to_trace(), + data, + layout: *data_layout, + size: *size, + }); + } + self.device.check_is_valid()?; let dst = destination.texture; @@ -2048,18 +2060,6 @@ impl Global { aspect: destination.aspect, }; - #[cfg(feature = "trace")] - if let Some(ref mut trace) = *queue.device.trace.lock() { - use crate::device::trace::DataKind; - let data = trace.make_binary(DataKind::Bin, data); - trace.add(Action::WriteTexture { - to: destination.to_trace(), - data, - layout: *data_layout, - size: *size, - }); - } - queue.write_texture(destination, data, data_layout, size) } From a0dd5cea3aacead639483e509f1da28431c30bd3 Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Wed, 12 Aug 2026 17:47:22 +0200 Subject: [PATCH 3/3] [core] move normalize from Global into `Queue::get_timestamp_period` Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- wgpu-core/src/device/queue.rs | 14 +++++++++----- wgpu-core/src/device/resource.rs | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index f718e84a209..631537f5d13 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -1841,10 +1841,18 @@ impl Queue { Ok(SubmissionResult { snatch_guard }) } - pub fn get_timestamp_period(&self) -> f32 { + pub(crate) fn get_raw_timestamp_period(&self) -> f32 { unsafe { self.raw().get_timestamp_period() } } + pub fn get_timestamp_period(&self) -> f32 { + if self.device.timestamp_normalizer.get().unwrap().enabled() { + return 1.0; + } + + self.get_raw_timestamp_period() + } + /// `closure` is guaranteed to be called. pub fn on_submitted_work_done( &self, @@ -2101,10 +2109,6 @@ impl Global { pub fn queue_get_timestamp_period(&self, queue_id: QueueId) -> f32 { let queue = self.hub.queues.get(queue_id); - if queue.device.timestamp_normalizer.get().unwrap().enabled() { - return 1.0; - } - queue.get_timestamp_period() } diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 59834a45541..f5b229b9e3c 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -765,7 +765,7 @@ impl Device { let timestamp_normalizer = crate::timestamp_normalization::TimestampNormalizer::new( self, - queue.get_timestamp_period(), + queue.get_raw_timestamp_period(), )?; self.timestamp_normalizer