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

Implement the device_set_device_lost_callback method for ContextWebGpu #5438

Merged
merged 2 commits into from
Mar 26, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Bottom level categories:

#### WebGPU

- Implement the `device_set_device_lost_callback` method for `ContextWebGpu`. By @suti in [#5438](https://github.com/gfx-rs/wgpu/pull/5438)
- Add support for storage texture access modes `ReadOnly` and `ReadWrite`. By @JolifantoBambla in [#5434](https://github.com/gfx-rs/wgpu/pull/5434)

### Bug Fixes
Expand Down
21 changes: 17 additions & 4 deletions wgpu/src/backend/webgpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1979,10 +1979,23 @@ impl crate::context::Context for ContextWebGpu {
fn device_set_device_lost_callback(
&self,
_device: &Self::DeviceId,
_device_data: &Self::DeviceData,
_device_lost_callback: crate::context::DeviceLostCallback,
) {
unimplemented!();
device_data: &Self::DeviceData,
device_lost_callback: crate::context::DeviceLostCallback,
) {
use webgpu_sys::{GpuDeviceLostInfo, GpuDeviceLostReason};

let closure = Closure::once(move |info: JsValue| {
let info = info.dyn_into::<GpuDeviceLostInfo>().unwrap();
device_lost_callback(
match info.reason() {
GpuDeviceLostReason::Destroyed => crate::DeviceLostReason::Destroyed,
GpuDeviceLostReason::Unknown => crate::DeviceLostReason::Unknown,
_ => crate::DeviceLostReason::Unknown,
},
info.message(),
);
});
let _ = device_data.0.lost().then(&closure);
}

fn device_poll(
Expand Down
Loading