(options: {
validationError?: GPUError | null;
limits?: GPUSupportedLimits;
} = {})
| 73 | } |
| 74 | |
| 75 | function makeDevice(options: { |
| 76 | validationError?: GPUError | null; |
| 77 | limits?: GPUSupportedLimits; |
| 78 | } = {}) { |
| 79 | const submittedCommand = { label: 'command' } as unknown as GPUCommandBuffer; |
| 80 | const encoder = { |
| 81 | finish: vi.fn(() => submittedCommand), |
| 82 | } as unknown as GPUCommandEncoder; |
| 83 | const device = { |
| 84 | limits: options.limits, |
| 85 | createBuffer: vi.fn((descriptor: GPUBufferDescriptor) => |
| 86 | makeBuffer(String(descriptor.label ?? ''), Number(descriptor.size), Number(descriptor.usage)) |
| 87 | ), |
| 88 | createCommandEncoder: vi.fn(() => encoder), |
| 89 | queue: { |
| 90 | submit: vi.fn(), |
| 91 | onSubmittedWorkDone: vi.fn(async () => undefined), |
| 92 | }, |
| 93 | pushErrorScope: vi.fn(), |
| 94 | popErrorScope: vi.fn(async () => options.validationError ?? null), |
| 95 | } as unknown as GPUDevice; |
| 96 | return { device, encoder, submittedCommand }; |
| 97 | } |
| 98 | |
| 99 | function makeRenderTargets(width: number, height: number, format: GPUTextureFormat) { |
| 100 | const colorTexture = makeTexture(`rt-${width}x${height}`); |
no test coverage detected