Skip to content
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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cts_runner/fail.lst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ webgpu:api,operation,rendering,3d_texture_slices:* // https://github.com/gfx-rs/
webgpu:api,operation,vertex_state,correctness:* // Vulkan (https://github.com/gfx-rs/wgpu/issues/1105) and dx12 (https://github.com/gfx-rs/wgpu/issues/10216)

webgpu:api,validation,buffer,create:new_usages,* // 0%, deno_webgpu declares the GPU*Usage constants as static getters, which are non-enumerable, so the test sees no legal usage bits, https://github.com/denoland/deno/issues/33846
webgpu:api,validation,buffer,mapping:* // crash
webgpu:api,validation,capability_checks,features,* // 21%, TypeError not thrown for missing features (needs deno_webgpu fix)
webgpu:api,validation,capability_checks,limits,* // 60%, workgroup storage size validation unimplemented; interstage vars counting; bind group timing on dx12
webgpu:api,validation,compute_pipeline:limits,workgroup_storage_size:* // 0%
Expand Down
12 changes: 9 additions & 3 deletions cts_runner/src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,19 +299,25 @@ core.registerErrorBuilder(
core.registerErrorBuilder(
"DOMExceptionAbortError",
function DOMExceptionAbortError(msg) {
return new domException.DOMException(msg, "AbortError");
return new DOMException(msg, "AbortError");
},
);
core.registerErrorBuilder(
"DOMExceptionInvalidCharacterError",
function DOMExceptionInvalidCharacterError(msg) {
return new domException.DOMException(msg, "InvalidCharacterError");
return new DOMException(msg, "InvalidCharacterError");
},
);
core.registerErrorBuilder(
"DOMExceptionInvalidStateError",
function DOMExceptionInvalidStateError(msg) {
return new DOMException(msg, "InvalidStateError");
},
);
core.registerErrorBuilder(
"DOMExceptionDataError",
function DOMExceptionDataError(msg) {
return new domException.DOMException(msg, "DataError");
return new DOMException(msg, "DataError");
},
);

Expand Down
1 change: 1 addition & 0 deletions cts_runner/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ webgpu:api,validation,buffer,create:limit,*
webgpu:api,validation,buffer,create:size,*
webgpu:api,validation,buffer,create:usage,*
webgpu:api,validation,buffer,destroy:*
webgpu:api,validation,buffer,mapping:*
webgpu:api,validation,capability_checks,features,clip_distances:*
webgpu:api,validation,capability_checks,features,query_types:createQuerySet:*
webgpu:api,validation,capability_checks,features,texture_component_swizzle:*
Expand Down
64 changes: 41 additions & 23 deletions deno_webgpu/adapter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright 2018-2025 the Deno authors. MIT license.

use std::cell::RefCell;
use std::ops::BitOr;
use std::rc::Rc;
use std::sync::Arc;
Expand Down Expand Up @@ -122,7 +123,7 @@ impl GPUAdapter {
#[global]
fn request_device(
&self,
state: &mut OpState,
state: Rc<RefCell<OpState>>,
scope: &mut v8::HandleScope,
#[webidl] descriptor: GPUDeviceDescriptor,
) -> Result<v8::Global<v8::Value>, CreateDeviceError> {
Expand Down Expand Up @@ -190,11 +191,14 @@ impl GPUAdapter {

let lost_resolver = v8::PromiseResolver::new(scope).unwrap();
let lost_promise = lost_resolver.get_promise(scope);
let cross_thread_spawner =
state.borrow::<V8CrossThreadTaskSpawner>().clone();
state
.borrow_mut::<LostPromiseResolverHM>()
.insert(wgpu_device_id, v8::Global::new(scope, lost_resolver));
let lost_resolver = v8::Global::new(scope, lost_resolver);
let cross_thread_spawner = {
let mut state = state.borrow_mut();
state
.borrow_mut::<LostPromiseResolverHM>()
.insert(wgpu_device_id, lost_resolver);
state.borrow::<V8CrossThreadTaskSpawner>().clone()
};
let wake = Arc::new(Mutex::new(move |reason: DeviceLostReason| {
cross_thread_spawner.spawn(move |scope| {
let lost_resolver = JsRuntime::op_state_from(scope)
Expand Down Expand Up @@ -242,12 +246,18 @@ impl GPUAdapter {
};
let device = deno_core::cppgc::make_cppgc_object(scope, device);
let weak_device = v8::Weak::new(scope, device);
let event_target_setup = state.borrow::<crate::EventTargetSetup>();
let webidl_brand = v8::Local::new(scope, event_target_setup.brand.clone());
let (brand, set_event_target_data) = {
let state = state.borrow();
let event_target_setup = state.borrow::<crate::EventTargetSetup>();
(
event_target_setup.brand.clone(),
event_target_setup.set_event_target_data.clone(),
)
};
let webidl_brand = v8::Local::new(scope, brand);
device.set(scope, webidl_brand, webidl_brand);
let set_event_target_data =
v8::Local::new(scope, event_target_setup.set_event_target_data.clone())
.cast::<v8::Function>();
v8::Local::new(scope, set_event_target_data).cast::<v8::Function>();
let null = v8::null(scope);
set_event_target_data.call(scope, null.into(), &[device.into()]);

Expand Down Expand Up @@ -276,19 +286,30 @@ impl GPUAdapter {
deno_core::cppgc::try_unwrap_cppgc_object::<GPUDevice>(scope, device)
.unwrap();

let cross_thread_spawner =
state.borrow::<V8CrossThreadTaskSpawner>().clone();
state
.borrow_mut::<WeakDeviceHM>()
.insert(wgpu_device_id, weak_device);
let cross_thread_spawner = {
let mut state = state.borrow_mut();
state
.borrow_mut::<WeakDeviceHM>()
.insert(wgpu_device_id, weak_device);
state.borrow::<V8CrossThreadTaskSpawner>().clone()
};
let wake = Arc::new(Mutex::new(move |error: wgpu_types::error::Error| {
cross_thread_spawner.spawn(move |scope| {
let state = JsRuntime::op_state_from(&*scope);
let state = state.borrow();
let weak_device =
state.borrow::<WeakDeviceHM>().get(&wgpu_device_id).unwrap();
// Do not hold the OpState borrow while calling into V8: a GC
// finalizer may need to borrow it mutably.
let (weak_device, error_event_class) = {
let state = JsRuntime::op_state_from(&*scope);
let state = state.borrow();
(
state
.borrow::<WeakDeviceHM>()
.get(&wgpu_device_id)
.unwrap()
.clone(),
state.borrow::<crate::ErrorEventClass>().0.clone(),
)
};
let err: GPUError = error.into();
let weak_device = weak_device.clone();

let Some(device) = weak_device.to_local(scope) else {
// The device has already gone away, so we don't have
Expand All @@ -300,9 +321,6 @@ impl GPUAdapter {
let func =
v8::Global::new(scope, val.try_cast::<v8::Function>().unwrap());
let device = v8::Global::new(scope, device.cast::<v8::Value>());
let error_event_class =
state.borrow::<crate::ErrorEventClass>().0.clone();

let error = deno_core::error::to_v8_error(scope, &err);

let error_event_class =
Expand Down
Loading
Loading