我试图在 WebGpu 中渲染 Web GPU 着色器对象
它返回此错误
未捕获( promise 中)类型错误:无法读取 null 的属性“requestDevice”
在 cube.html:28
这是我的 requestDevice 代码
(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;
});
任何想法来解决这个错误?
最佳答案
在尝试了很多事情之后,我通过在 about:flags 中重新启用 --enable-unsafe-webgpu 标志来修复它!
刷新页面之前工作了几次,但后来停止了......现在似乎很好!
关于javascript - 无法读取 null 的属性 'requestDevice',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65366815/