Skip to content

Commit

Permalink
fix: check for device mismatch in create_{render,compute}_pass
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Nov 6, 2024
1 parent 2e46a6c commit 5936fe5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Bottom level categories:
#### General

- Ensure that `Features::TIMESTAMP_QUERY` is set when using timestamp writes in render and compute passes. By @ErichDonGubler in [#6497](https://github.com/gfx-rs/wgpu/pull/6497).
- Check for device mismatches when beginning render and compute passes. By @ErichDonGubler in [#6497](https://github.com/gfx-rs/wgpu/pull/6497).

## 23.0.0 (2024-10-25)

Expand Down
13 changes: 8 additions & 5 deletions wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,14 @@ impl Global {
};

arc_desc.timestamp_writes = if let Some(tw) = desc.timestamp_writes {
let query_set = match hub.query_sets.get(tw.query_set).get() {
Ok(query_set) => query_set,
Err(e) => return make_err(e.into(), arc_desc),
};
match query_set.same_device(&cmd_buf.device) {
Ok(()) => (),
Err(e) => return make_err(e.into(), arc_desc),
}
match cmd_buf
.device
.require_features(wgt::Features::TIMESTAMP_QUERY)
Expand All @@ -316,11 +324,6 @@ impl Global {
Err(e) => return make_err(e.into(), arc_desc),
}

let query_set = match hub.query_sets.get(tw.query_set).get() {
Ok(query_set) => query_set,
Err(e) => return make_err(e.into(), arc_desc),
};

Some(ArcPassTimestampWrites {
query_set,
beginning_of_pass_write_index: tw.beginning_of_pass_write_index,
Expand Down
9 changes: 7 additions & 2 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1358,9 +1358,11 @@ impl Global {
}) = color_attachment
{
let view = texture_views.get(*view_id).get()?;
view.same_device(device)?;

let resolve_target = if let Some(resolve_target_id) = resolve_target {
let rt_arc = texture_views.get(*resolve_target_id).get()?;
rt_arc.same_device(device)?;

Some(rt_arc)
} else {
Expand All @@ -1382,6 +1384,7 @@ impl Global {
arc_desc.depth_stencil_attachment =
if let Some(depth_stencil_attachment) = desc.depth_stencil_attachment {
let view = texture_views.get(depth_stencil_attachment.view).get()?;
view.same_device(device)?;

Some(ArcRenderPassDepthStencilAttachment {
view,
Expand All @@ -1393,9 +1396,10 @@ impl Global {
};

arc_desc.timestamp_writes = if let Some(tw) = desc.timestamp_writes {
device.require_features(wgt::Features::TIMESTAMP_QUERY)?;

let query_set = query_sets.get(tw.query_set).get()?;
query_set.same_device(device)?;

device.require_features(wgt::Features::TIMESTAMP_QUERY)?;

Some(ArcPassTimestampWrites {
query_set,
Expand All @@ -1409,6 +1413,7 @@ impl Global {
arc_desc.occlusion_query_set =
if let Some(occlusion_query_set) = desc.occlusion_query_set {
let query_set = query_sets.get(occlusion_query_set).get()?;
query_set.same_device(device)?;

Some(query_set)
} else {
Expand Down

0 comments on commit 5936fe5

Please sign in to comment.