我试图在WebGpu中渲染WebGpu着色器对象
它返回这个错误
Uncaught (承诺) TypeError:无法在cube.html:28上读取null的属性“requestDevice”
这是我给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;
});有什么办法纠正这个错误吗?
发布于 2021-02-07 19:45:20
在尝试了许多事情之后,我通过重新启用--启用--不安全的--webgpu标志来修复它:标志!
刷新页面在那之前有几次有效,但后来停止了.现在似乎很好!
https://stackoverflow.com/questions/65366815
复制相似问题