A temporary fix for the WebGPU detector. Also, Firefox doesn't support GPUQueue::copyExternalImageToTexture yet, so they'll fall back to regl until I work out a temporary alternative for that, too.

This commit is contained in:
Rezmason
2021-11-15 09:19:00 -08:00
parent d273573348
commit b39ae896b5

View File

@@ -6,9 +6,13 @@ document.addEventListener("touchmove", (e) => e.preventDefault(), {
passive: false, passive: false,
}); });
const supportsWebGPU = async () => {
return window?.GPUQueue?.prototype?.copyExternalImageToTexture != null;
}
document.body.onload = async () => { document.body.onload = async () => {
const urlParams = Object.fromEntries(new URLSearchParams(window.location.search).entries()); const urlParams = Object.fromEntries(new URLSearchParams(window.location.search).entries());
const useREGL = navigator.gpu == null || ["webgl", "regl"].includes(urlParams.renderer?.toLowerCase()); const useREGL = !(await supportsWebGPU()) || ["webgl", "regl"].includes(urlParams.renderer?.toLowerCase());
const solution = import(`./${useREGL ? "regl" : "webgpu"}/main.js`); const solution = import(`./${useREGL ? "regl" : "webgpu"}/main.js`);
const config = makeConfig(urlParams); const config = makeConfig(urlParams);
(await solution).default(canvas, config); (await solution).default(canvas, config);