diff --git a/apps/example/src/ComputeBoids/ComputeBoids.tsx b/apps/example/src/ComputeBoids/ComputeBoids.tsx index 75a1b6d9..133ee1bd 100644 --- a/apps/example/src/ComputeBoids/ComputeBoids.tsx +++ b/apps/example/src/ComputeBoids/ComputeBoids.tsx @@ -41,7 +41,7 @@ const renderBindGroupLayout = tgpu.bindGroupLayout({ const computeBindGroupLayout = tgpu.bindGroupLayout({ currentTrianglePos: { storage: TriangleDataArray }, - nextTrianglePos: { storage: TriangleDataArray, access: 'mutable' }, + nextTrianglePos: { storage: TriangleDataArray, access: "mutable" }, params: { uniform: Parameters }, }); @@ -122,7 +122,7 @@ export function ComputeBoids() { const triangleAmount = 1000; const trianglePosBuffers = Array.from({ length: 2 }, () => - root.createBuffer(TriangleDataArray(triangleAmount)).$usage("storage") + root.createBuffer(TriangleDataArray(triangleAmount)).$usage("storage"), ); randomizePositions.current = () => { @@ -234,7 +234,7 @@ export function ComputeBoids() { computePass.setPipeline(computePipeline); computePass.setBindGroup( 0, - root.unwrap(even ? computeBindGroups[0] : computeBindGroups[1]) + root.unwrap(even ? computeBindGroups[0] : computeBindGroups[1]), ); computePass.dispatchWorkgroups(triangleAmount); computePass.end(); @@ -244,7 +244,7 @@ export function ComputeBoids() { passEncoder.setVertexBuffer(0, triangleVertexBuffer.buffer); passEncoder.setBindGroup( 0, - root.unwrap(even ? renderBindGroups[1] : renderBindGroups[0]) + root.unwrap(even ? renderBindGroups[1] : renderBindGroups[0]), ); passEncoder.draw(3, triangleAmount); passEncoder.end(); diff --git a/apps/example/src/GradientTiles/GradientTiles.tsx b/apps/example/src/GradientTiles/GradientTiles.tsx index 701cd315..b6544de9 100644 --- a/apps/example/src/GradientTiles/GradientTiles.tsx +++ b/apps/example/src/GradientTiles/GradientTiles.tsx @@ -4,7 +4,7 @@ import { Canvas, useDevice, useGPUContext } from "react-native-wgpu"; import { struct, u32 } from "typegpu/data"; import tgpu, { type TgpuBindGroup, type TgpuBuffer } from "typegpu"; -import { vertWGSL, fragWGSL } from './gradientWgsl'; +import { vertWGSL, fragWGSL } from "./gradientWgsl"; const Span = struct({ x: u32, @@ -18,7 +18,7 @@ const bindGroupLayout = tgpu.bindGroupLayout({ interface RenderingState { pipeline: GPURenderPipeline; spanBuffer: TgpuBuffer; - bindGroup: TgpuBindGroup<(typeof bindGroupLayout)['entries']>; + bindGroup: TgpuBindGroup<(typeof bindGroupLayout)["entries"]>; } function useRoot() { @@ -26,7 +26,7 @@ function useRoot() { return useMemo( () => (device ? tgpu.initFromDevice({ device }) : null), - [device] + [device], ); } diff --git a/apps/example/src/Tensorflow/Platform.ts b/apps/example/src/Tensorflow/Platform.ts index 43e108d2..5a6a736e 100644 --- a/apps/example/src/Tensorflow/Platform.ts +++ b/apps/example/src/Tensorflow/Platform.ts @@ -1,5 +1,5 @@ -import { Platform } from "@tensorflow/tfjs-core"; -import { RequestDetails } from "@tensorflow/tfjs-core/dist/io/types"; +import type { Platform } from "@tensorflow/tfjs-core"; +import type { RequestDetails } from "@tensorflow/tfjs-core/dist/io/types"; export class PlatformReactNative implements Platform { fetch(path: string, init?: RequestInit, _options?: RequestDetails) { @@ -22,7 +22,9 @@ export class PlatformReactNative implements Platform { throw new Error("react native does not support setTimeoutCustom"); } - isTypedArray(a: unknown) { + isTypedArray( + a: unknown, + ): a is Uint8Array | Uint8ClampedArray | Int32Array | Float32Array { return ( a instanceof Float32Array || a instanceof Int32Array || diff --git a/packages/webgpu/src/Offscreen.ts b/packages/webgpu/src/Offscreen.ts index 3f83108f..c4e460bb 100644 --- a/packages/webgpu/src/Offscreen.ts +++ b/packages/webgpu/src/Offscreen.ts @@ -1,9 +1,6 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -export class GPUOffscreenCanvas implements OffscreenCanvas { +export class GPUOffscreenCanvas { width: number; height: number; - oncontextlost: ((this: OffscreenCanvas, ev: Event) => any) | null = null; - oncontextrestored: ((this: OffscreenCanvas, ev: Event) => any) | null = null; private context: GPUOffscreenCanvasContext; @@ -13,31 +10,7 @@ export class GPUOffscreenCanvas implements OffscreenCanvas { this.context = new GPUOffscreenCanvasContext(this); } - convertToBlob(_options?: ImageEncodeOptions): Promise { - // Implementation for converting the canvas content to a Blob - throw new Error("Method not implemented."); - } - - // Overloaded method signatures - getContext( - contextId: "2d", - options?: any, - ): OffscreenCanvasRenderingContext2D | null; - getContext( - contextId: "bitmaprenderer", - options?: any, - ): ImageBitmapRenderingContext | null; - getContext(contextId: "webgl", options?: any): WebGLRenderingContext | null; - getContext(contextId: "webgl2", options?: any): WebGL2RenderingContext | null; - getContext( - contextId: OffscreenRenderingContextId, - options?: any, - ): OffscreenRenderingContext | null; - getContext(contextId: "webgpu"): GPUOffscreenCanvasContext | null; - getContext( - contextId: unknown, - _options?: any, - ): OffscreenRenderingContext | GPUOffscreenCanvasContext | null { + getContext(contextId: "webgpu"): GPUOffscreenCanvasContext | null { if (contextId === "webgpu") { return this.context; } @@ -45,34 +18,6 @@ export class GPUOffscreenCanvas implements OffscreenCanvas { return null; } - transferToImageBitmap(): ImageBitmap { - // Implementation for transferring the canvas content to an ImageBitmap - throw new Error("Method not implemented."); - } - - addEventListener( - _type: K, - _listener: (this: OffscreenCanvas, ev: OffscreenCanvasEventMap[K]) => any, - _options?: boolean | AddEventListenerOptions, - ): void { - // Event listener implementation - throw new Error("Method not implemented."); - } - - removeEventListener( - _type: K, - _listener: (this: OffscreenCanvas, ev: OffscreenCanvasEventMap[K]) => any, - _options?: boolean | EventListenerOptions, - ): void { - // Remove event listener implementation - throw new Error("Method not implemented."); - } - - dispatchEvent(_event: Event): boolean { - // Event dispatch implementation - throw new Error("Method not implemented."); - } - getImageData() { const device = this.context.getDevice(); const texture = this.context.getTexture(); @@ -111,9 +56,13 @@ class GPUOffscreenCanvasContext implements GPUCanvasContext { private texture: GPUTexture | null = null; private device: GPUDevice | null = null; - constructor(public readonly canvas: OffscreenCanvas) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + constructor(public readonly canvas: any) { this.textureFormat = navigator.gpu.getPreferredCanvasFormat(); } + getConfiguration(): GPUCanvasConfigurationOut | null { + throw new Error("Method not implemented."); + } present() { // Do nothing