CodexCapsule / gpu.js
LordXido's picture
Update gpu.js
cb68079 verified
raw
history blame
487 Bytes
export async function initGPU(width, height) {
if (!navigator.gpu) {
console.warn("WebGPU not supported, falling back to CPU");
return null;
}
const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();
const size = width * height * 4;
const buffer = device.createBuffer({
size,
usage:
GPUBufferUsage.STORAGE |
GPUBufferUsage.COPY_SRC |
GPUBufferUsage.COPY_DST
});
return { device, buffer };
}