From 6cb5747441a9105a00cf0620f3e85556c0e37c8c Mon Sep 17 00:00:00 2001 From: Christian Helgeson Date: Mon, 17 Jun 2024 15:05:50 -0700 Subject: [PATCH 1/2] feat: add types for WebGPUAttributeUtils and WebGPUBindingUtils, both of which can mostly be typed without explicit access to webgpu types --- .../webgpu/utils/WebGPUAttributeUtils.d.ts | 14 ++++++++++++++ .../renderers/webgpu/utils/WebGPUBindingUtils.d.ts | 12 ++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 types/three/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.d.ts create mode 100644 types/three/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.d.ts diff --git a/types/three/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.d.ts b/types/three/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.d.ts new file mode 100644 index 000000000..d3ecd1dba --- /dev/null +++ b/types/three/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.d.ts @@ -0,0 +1,14 @@ +import { BufferAttribute } from "three/src/Three.js"; +import Backend from "../../common/Backend"; +import RenderObject from "../../common/RenderObject"; + +export default class WebGPUAttributeUtiils { + backend: Backend; + + constructor(backend: Backend); + createAttribute(attribute: BufferAttribute, usage: number); + updateAttribute(attribute: BufferAttribute); + createShaderVertexBuffers(renderObject: RenderObject); + destroyAttribute(attribute: BufferAttribute); + getArrayBufferAsync(attribute: BufferAttribute); +} diff --git a/types/three/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.d.ts b/types/three/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.d.ts new file mode 100644 index 000000000..9210705a5 --- /dev/null +++ b/types/three/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.d.ts @@ -0,0 +1,12 @@ +import Backend from "../../common/Backend"; +import Binding from "../../common/Binding"; + +export default class WebGPUBindingUtils { + backend: Backend; + + constructor(backend: Backend); + createBindingsLayout(bindings: Binding[]); + createBindings(bindings: Binding[]); + updateBinding(binding: Binding); + // createBindGroup(bindings: Binding[], layoutGPU: GPUBindGroupLayout): GPUBindGroup; +} From 77bd2dc5ad812e2297ea291e7193b710bb74f844 Mon Sep 17 00:00:00 2001 From: Christian Helgeson Date: Mon, 17 Jun 2024 18:25:06 -0700 Subject: [PATCH 2/2] fix: added return types where possible, though commented out areas where webgpu types would be necessary --- .../jsm/renderers/webgpu/utils/WebGPUAttributeUtils.d.ts | 6 +++--- .../jsm/renderers/webgpu/utils/WebGPUBindingUtils.d.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/three/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.d.ts b/types/three/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.d.ts index d3ecd1dba..3f9cc82d3 100644 --- a/types/three/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.d.ts +++ b/types/three/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.d.ts @@ -1,4 +1,4 @@ -import { BufferAttribute } from "three/src/Three.js"; +import { BufferAttribute } from "three"; import Backend from "../../common/Backend"; import RenderObject from "../../common/RenderObject"; @@ -8,7 +8,7 @@ export default class WebGPUAttributeUtiils { constructor(backend: Backend); createAttribute(attribute: BufferAttribute, usage: number); updateAttribute(attribute: BufferAttribute); - createShaderVertexBuffers(renderObject: RenderObject); + // createShaderVertexBuffers(renderObject: RenderObject): GPUVertexBufferLayout[]; destroyAttribute(attribute: BufferAttribute); - getArrayBufferAsync(attribute: BufferAttribute); + getArrayBufferAsync(attribute: BufferAttribute): ArrayBuffer; } diff --git a/types/three/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.d.ts b/types/three/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.d.ts index 9210705a5..116bca94e 100644 --- a/types/three/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.d.ts +++ b/types/three/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.d.ts @@ -5,7 +5,7 @@ export default class WebGPUBindingUtils { backend: Backend; constructor(backend: Backend); - createBindingsLayout(bindings: Binding[]); + // createBindingsLayout(bindings: Binding[]): GPUBindGroupLayout; createBindings(bindings: Binding[]); updateBinding(binding: Binding); // createBindGroup(bindings: Binding[], layoutGPU: GPUBindGroupLayout): GPUBindGroup;