Skip to content
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
38 changes: 1 addition & 37 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
38 changes: 21 additions & 17 deletions wgpu-core/src/device/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1829,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,
Expand Down Expand Up @@ -2048,18 +2068,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)
}

Expand Down Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/device/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down