[deno] add deviceStartCapture and deviceStopCapture

This is achieved by adding a new `Deno.webgpu` namespace which will be
used for non-spec functionality, which for now will be marked as
unstable

(cherry picked from denoland/deno#28192)
This commit is contained in:
Leo Kettmeir 2025-09-17 14:03:25 -04:00 committed by Erich Gubler
parent 48097412fc
commit 190050e296
3 changed files with 39 additions and 1 deletions

View File

@ -37,6 +37,8 @@ import {
GPUTextureView,
GPUExternalTexture,
op_create_gpu,
op_webgpu_device_start_capture,
op_webgpu_device_stop_capture,
} from "ext:core/ops";
const {
ObjectDefineProperty,
@ -884,6 +886,19 @@ webidl.converters["GPUUncapturedErrorEventInit"] = webidl
dictMembersGPUUncapturedErrorEventInit,
);
function deviceStartCapture(device) {
op_webgpu_device_start_capture(device);
}
function deviceStopCapture(device) {
op_webgpu_device_stop_capture(device);
}
const denoNsWebGPU = {
deviceStartCapture,
deviceStopCapture,
};
let gpu;
function initGPU() {
if (!gpu) {
@ -896,6 +911,7 @@ function initGPU() {
}
export {
denoNsWebGPU,
GPU,
gpu,
GPUAdapter,

View File

@ -917,3 +917,21 @@ impl GPUDeviceLostInfo {
"device was lost"
}
}
#[op2(fast)]
pub fn op_webgpu_device_start_capture(#[cppgc] device: &GPUDevice) {
unsafe {
device
.instance
.device_start_graphics_debugger_capture(device.id);
}
}
#[op2(fast)]
pub fn op_webgpu_device_stop_capture(#[cppgc] device: &GPUDevice) {
unsafe {
device
.instance
.device_stop_graphics_debugger_capture(device.id);
}
}

View File

@ -64,7 +64,11 @@ pub type Instance = Arc<wgpu_core::global::Global>;
deno_core::extension!(
deno_webgpu,
deps = [deno_webidl, deno_web],
ops = [op_create_gpu],
ops = [
op_create_gpu,
device::op_webgpu_device_start_capture,
device::op_webgpu_device_stop_capture,
],
objects = [
GPU,
adapter::GPUAdapter,