UNPKG

pixi.js

Version:

<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">

1 lines 1.95 kB
{"version":3,"file":"isWebGPUSupported.mjs","sources":["../../../src/utils/browser/isWebGPUSupported.ts"],"sourcesContent":["import { DOMAdapter } from '../../environment/adapter';\n\nlet _isWebGPUSupported: boolean | undefined;\n\n/**\n * Helper for checking for WebGPU support in the current environment.\n * Results are cached after first call for better performance.\n * @example\n * ```ts\n * // Basic WebGPU support check\n * const hasWebGPU = await isWebGPUSupported();\n * console.log('WebGPU available:', hasWebGPU);\n * ```\n * @param options - The options for requesting a GPU adapter\n * @returns Promise that resolves to true if WebGPU is supported\n * @category utils\n * @standard\n */\nexport async function isWebGPUSupported(options: GPURequestAdapterOptions = {}): Promise<boolean>\n{\n if (_isWebGPUSupported !== undefined) return _isWebGPUSupported;\n\n _isWebGPUSupported = await (async (): Promise<boolean> =>\n {\n const gpu = DOMAdapter.get().getNavigator().gpu;\n\n if (!gpu)\n {\n return false;\n }\n\n try\n {\n const adapter = await gpu.requestAdapter(options) as GPUAdapter;\n\n // TODO and one of these!\n await adapter.requestDevice();\n\n return true;\n }\n catch (_e)\n {\n return false;\n }\n })();\n\n return _isWebGPUSupported;\n}\n"],"names":[],"mappings":";;;AAEA,IAAI,kBAAA;AAgBJ,eAAsB,iBAAA,CAAkB,OAAA,GAAoC,EAAC,EAC7E;AACI,EAAA,IAAI,kBAAA,KAAuB,QAAW,OAAO,kBAAA;AAE7C,EAAA,kBAAA,GAAqB,OAAO,YAC5B;AACI,IAAA,MAAM,GAAA,GAAM,UAAA,CAAW,GAAA,EAAI,CAAE,cAAa,CAAE,GAAA;AAE5C,IAAA,IAAI,CAAC,GAAA,EACL;AACI,MAAA,OAAO,KAAA;AAAA,IACX;AAEA,IAAA,IACA;AACI,MAAA,MAAM,OAAA,GAAU,MAAM,GAAA,CAAI,cAAA,CAAe,OAAO,CAAA;AAGhD,MAAA,MAAM,QAAQ,aAAA,EAAc;AAE5B,MAAA,OAAO,IAAA;AAAA,IACX,SACO,EAAA,EACP;AACI,MAAA,OAAO,KAAA;AAAA,IACX;AAAA,EACJ,CAAA,GAAG;AAEH,EAAA,OAAO,kBAAA;AACX;;;;"}