Spaces:
Running
Running
File size: 696 Bytes
6af9568 552351c 0870851 552351c 0870851 552351c 0870851 6af9568 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
// wgpu-device.js
export async function initializeDevice(state) {
const context = state.canvas.getContext('webgpu');
const device = await state.webgpu.adapter?.requestDevice();
if (!device) {
alert('need a browser that supports WebGPU');
state.webgpu.device = null;
state.webgpu.context = null;
state.webgpu.presentationFormat = null;
return;
}
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
context.configure({
device,
format: presentationFormat,
});
state.webgpu.device = device;
state.webgpu.context = context;
state.webgpu.presentationFormat = presentationFormat;
}
|