#canvas element problem with webgpu

10 messages · Page 1 of 1 (latest)

placid hornet
#

@real mural Probably it's supposed to be wgpu_canvas.getContext('webpgu')

#

Honestly, there's some pretty sketchy parts in that code:

#

They also never declare commandEncoder, and just do commandEncoder = device.createCommandEncoder();

real mural
#

@placid hornet

#

thanks for input, I made my code more compact ```ts
async function wgpu_init()
{
console.log("from wgpu_init function");
const adapter = await navigator.gpu.requestAdapter
({
featureLevel: "compatibility",
});

const device = await adapter?.requestDevice();
if (!device) {
console.log("device error");
}
else
{
console.log("device ok");
}

const canvas = document.getElementById("wgpu") as HTMLCanvasElement;
const context = canvas.getContext("webgpu") as GPUCanvasContext;
const devicePixelRatio = window.devicePixelRatio;

const presentationFormat = navigator.gpu.getPreferredCanvasFormat();

context?.configure
({
device,
format: presentationFormat,
})
}

wgpu_init();```

#

but it still fails at