diff --git a/js/main.js b/js/main.js index 723b020..086a0fa 100644 --- a/js/main.js +++ b/js/main.js @@ -6,9 +6,13 @@ document.addEventListener("touchmove", (e) => e.preventDefault(), { passive: false, }); +const supportsWebGPU = async () => { + return window?.GPUQueue?.prototype?.copyExternalImageToTexture != null; +} + document.body.onload = async () => { 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 config = makeConfig(urlParams); (await solution).default(canvas, config);