Skip to content

Commit 5936fe5

Browse files
fix: check for device mismatch in create_{render,compute}_pass
1 parent 2e46a6c commit 5936fe5

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Bottom level categories:
6363
#### General
6464

6565
- 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).
66+
- Check for device mismatches when beginning render and compute passes. By @ErichDonGubler in [#6497](https://github.com/gfx-rs/wgpu/pull/6497).
6667

6768
## 23.0.0 (2024-10-25)
6869

wgpu-core/src/command/compute.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,14 @@ impl Global {
308308
};
309309

310310
arc_desc.timestamp_writes = if let Some(tw) = desc.timestamp_writes {
311+
let query_set = match hub.query_sets.get(tw.query_set).get() {
312+
Ok(query_set) => query_set,
313+
Err(e) => return make_err(e.into(), arc_desc),
314+
};
315+
match query_set.same_device(&cmd_buf.device) {
316+
Ok(()) => (),
317+
Err(e) => return make_err(e.into(), arc_desc),
318+
}
311319
match cmd_buf
312320
.device
313321
.require_features(wgt::Features::TIMESTAMP_QUERY)
@@ -316,11 +324,6 @@ impl Global {
316324
Err(e) => return make_err(e.into(), arc_desc),
317325
}
318326

319-
let query_set = match hub.query_sets.get(tw.query_set).get() {
320-
Ok(query_set) => query_set,
321-
Err(e) => return make_err(e.into(), arc_desc),
322-
};
323-
324327
Some(ArcPassTimestampWrites {
325328
query_set,
326329
beginning_of_pass_write_index: tw.beginning_of_pass_write_index,

wgpu-core/src/command/render.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,9 +1358,11 @@ impl Global {
13581358
}) = color_attachment
13591359
{
13601360
let view = texture_views.get(*view_id).get()?;
1361+
view.same_device(device)?;
13611362

13621363
let resolve_target = if let Some(resolve_target_id) = resolve_target {
13631364
let rt_arc = texture_views.get(*resolve_target_id).get()?;
1365+
rt_arc.same_device(device)?;
13641366

13651367
Some(rt_arc)
13661368
} else {
@@ -1382,6 +1384,7 @@ impl Global {
13821384
arc_desc.depth_stencil_attachment =
13831385
if let Some(depth_stencil_attachment) = desc.depth_stencil_attachment {
13841386
let view = texture_views.get(depth_stencil_attachment.view).get()?;
1387+
view.same_device(device)?;
13851388

13861389
Some(ArcRenderPassDepthStencilAttachment {
13871390
view,
@@ -1393,9 +1396,10 @@ impl Global {
13931396
};
13941397

13951398
arc_desc.timestamp_writes = if let Some(tw) = desc.timestamp_writes {
1396-
device.require_features(wgt::Features::TIMESTAMP_QUERY)?;
1397-
13981399
let query_set = query_sets.get(tw.query_set).get()?;
1400+
query_set.same_device(device)?;
1401+
1402+
device.require_features(wgt::Features::TIMESTAMP_QUERY)?;
13991403

14001404
Some(ArcPassTimestampWrites {
14011405
query_set,
@@ -1409,6 +1413,7 @@ impl Global {
14091413
arc_desc.occlusion_query_set =
14101414
if let Some(occlusion_query_set) = desc.occlusion_query_set {
14111415
let query_set = query_sets.get(occlusion_query_set).get()?;
1416+
query_set.same_device(device)?;
14121417

14131418
Some(query_set)
14141419
} else {

0 commit comments

Comments
 (0)