diff --git a/deno_webgpu/01_webgpu.js b/deno_webgpu/01_webgpu.js index 81958d399..c958f189e 100644 --- a/deno_webgpu/01_webgpu.js +++ b/deno_webgpu/01_webgpu.js @@ -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, diff --git a/deno_webgpu/device.rs b/deno_webgpu/device.rs index 6b9653265..ee99ace36 100644 --- a/deno_webgpu/device.rs +++ b/deno_webgpu/device.rs @@ -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); + } +} diff --git a/deno_webgpu/lib.rs b/deno_webgpu/lib.rs index 27f04ba5a..d529ca848 100644 --- a/deno_webgpu/lib.rs +++ b/deno_webgpu/lib.rs @@ -64,7 +64,11 @@ pub type Instance = Arc; 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,