Skip to content

Commit

Permalink
Pass correct surface for existing canvases (gfx-rs#3718)
Browse files Browse the repository at this point in the history
  • Loading branch information
grovesNL authored and Wumpf committed May 14, 2023
1 parent 0b53b47 commit 25f96b3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ Bottom level categories:

## Unreleased

### Bug Fixes

#### WebGPU

* Fix crash when calling `create_surface_from_canvas`. By @grovesNL in [#3718](https://github.com/gfx-rs/wgpu/pull/3718)

## v0.16.0 (2023-04-19)

### Major changes
Expand Down
13 changes: 0 additions & 13 deletions wgpu/src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,6 @@ impl<T> From<Identified<T>> for ObjectId {
}
}

#[allow(unused_variables)]
impl<T> From<(Identified<T>, Sendable<T>)> for ObjectId {
fn from((id, _data): (Identified<T>, Sendable<T>)) -> Self {
Self::new(
// TODO: the ID isn't used, so we hardcode it to 1 for now until we rework this
// API.
core::num::NonZeroU64::new(1).unwrap(),
#[cfg(feature = "expose-ids")]
id.0,
)
}
}

#[derive(Clone, Debug)]
pub(crate) struct Sendable<T>(T);
unsafe impl<T> Send for Sendable<T> {}
Expand Down
2 changes: 1 addition & 1 deletion wgpu/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ pub struct ObjectId {
}

impl ObjectId {
const UNUSED: Self = ObjectId {
pub(crate) const UNUSED: Self = ObjectId {
id: None,
#[cfg(feature = "expose-ids")]
global_id: None,
Expand Down
8 changes: 4 additions & 4 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1616,9 +1616,9 @@ impl Instance {
#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))]
data: Box::new(surface),
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
id: ObjectId::from(surface),
id: ObjectId::UNUSED,
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
data: Box::new(()),
data: Box::new(surface.1),
config: Mutex::new(None),
})
}
Expand Down Expand Up @@ -1652,9 +1652,9 @@ impl Instance {
#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))]
data: Box::new(surface),
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
id: ObjectId::from(surface),
id: ObjectId::UNUSED,
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
data: Box::new(()),
data: Box::new(surface.1),
config: Mutex::new(None),
})
}
Expand Down

0 comments on commit 25f96b3

Please sign in to comment.