Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate features and device mismatches in pass beginnings #6497

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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ Bottom level categories:

- Change the `DropCallback` API to use `FnOnce` instead of `FnMut`. By @jerzywilczek in [#6482](https://github.com/gfx-rs/wgpu/pull/6482)

### Bug Fixes

#### 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)

### Themes of this release
Expand Down
11 changes: 11 additions & 0 deletions wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,17 @@ impl Global {
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)
{
Ok(()) => (),
Err(e) => return make_err(e.into(), arc_desc),
}

Some(ArcPassTimestampWrites {
query_set,
Expand Down
4 changes: 3 additions & 1 deletion wgpu-core/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub use timestamp_writes::PassTimestampWrites;

use self::memory_init::CommandBufferTextureMemoryActions;

use crate::device::{Device, DeviceError};
use crate::device::{Device, DeviceError, MissingFeatures};
use crate::lock::{rank, Mutex};
use crate::snatch::SnatchGuard;

Expand Down Expand Up @@ -642,6 +642,8 @@ pub enum CommandEncoderError {
InvalidColorAttachment(#[from] ColorAttachmentError),
#[error(transparent)]
InvalidResource(#[from] InvalidResourceError),
#[error(transparent)]
MissingFeatures(#[from] MissingFeatures),
}

impl Global {
Expand Down
7 changes: 7 additions & 0 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 @@ -1394,6 +1397,9 @@ impl Global {

arc_desc.timestamp_writes = if let Some(tw) = desc.timestamp_writes {
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 @@ -1407,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