Skip to content

Commit 190050e

Browse files
crowlKatsErichDonGubler
authored andcommitted
[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)
1 parent 4809741 commit 190050e

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

deno_webgpu/01_webgpu.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ import {
3737
GPUTextureView,
3838
GPUExternalTexture,
3939
op_create_gpu,
40+
op_webgpu_device_start_capture,
41+
op_webgpu_device_stop_capture,
4042
} from "ext:core/ops";
4143
const {
4244
ObjectDefineProperty,
@@ -884,6 +886,19 @@ webidl.converters["GPUUncapturedErrorEventInit"] = webidl
884886
dictMembersGPUUncapturedErrorEventInit,
885887
);
886888

889+
function deviceStartCapture(device) {
890+
op_webgpu_device_start_capture(device);
891+
}
892+
893+
function deviceStopCapture(device) {
894+
op_webgpu_device_stop_capture(device);
895+
}
896+
897+
const denoNsWebGPU = {
898+
deviceStartCapture,
899+
deviceStopCapture,
900+
};
901+
887902
let gpu;
888903
function initGPU() {
889904
if (!gpu) {
@@ -896,6 +911,7 @@ function initGPU() {
896911
}
897912

898913
export {
914+
denoNsWebGPU,
899915
GPU,
900916
gpu,
901917
GPUAdapter,

deno_webgpu/device.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,3 +917,21 @@ impl GPUDeviceLostInfo {
917917
"device was lost"
918918
}
919919
}
920+
921+
#[op2(fast)]
922+
pub fn op_webgpu_device_start_capture(#[cppgc] device: &GPUDevice) {
923+
unsafe {
924+
device
925+
.instance
926+
.device_start_graphics_debugger_capture(device.id);
927+
}
928+
}
929+
930+
#[op2(fast)]
931+
pub fn op_webgpu_device_stop_capture(#[cppgc] device: &GPUDevice) {
932+
unsafe {
933+
device
934+
.instance
935+
.device_stop_graphics_debugger_capture(device.id);
936+
}
937+
}

deno_webgpu/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ pub type Instance = Arc<wgpu_core::global::Global>;
6464
deno_core::extension!(
6565
deno_webgpu,
6666
deps = [deno_webidl, deno_web],
67-
ops = [op_create_gpu],
67+
ops = [
68+
op_create_gpu,
69+
device::op_webgpu_device_start_capture,
70+
device::op_webgpu_device_stop_capture,
71+
],
6872
objects = [
6973
GPU,
7074
adapter::GPUAdapter,

0 commit comments

Comments
 (0)