Request device报错
-
我想在webgpu中render一个object,但是request device报错
Uncaught (in promise) TypeError: Cannot read property 'requestDevice' of null at cube.html:28
下面是我的代码,怎么解决这个error?(async () => { const [adapter, glslang] = await Promise.all([ navigator.gpu.requestAdapter(), import(""https://unpkg.com/@webgpu/glslang@0.0.7/web/glslang.js"").then(m => m.default()) ]); const device = await adapter.requestDevice(); const canvas = document.getElementById(""webgpu-canvas""); canvas.width = window.innerWidth; canvas.height = window.innerHeight; })
-
@曙光磁铁 WebGPU标准仍处于draft阶段,浏览器默认不支持,需要 chrome 94+ 的浏览器配合origin-trail token才可以运行。如果需要自己本地开发测试,可以使用chrome canary,在地址栏访问chrome://flags ,将Unsafe WebGPU 设置为 enable 进行开启!