File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
quartz/components/scripts Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -68,13 +68,28 @@ type TweenNode = {
6868 stop : ( ) => void
6969}
7070
71+ // workaround for pixijs webgpu issue: https://github.com/pixijs/pixijs/issues/11389
7172async function determineGraphicsAPI ( ) : Promise < "webgpu" | "webgl" > {
7273 const adapter = await navigator . gpu ?. requestAdapter ( ) . catch ( ( ) => null )
73- if ( ! adapter ) {
74+ const device = adapter && ( await adapter . requestDevice ( ) . catch ( ( ) => null ) )
75+ if ( ! device ) {
7476 return "webgl"
7577 }
76- // Devices with WebGPU but no float32-blendable feature fail to render the graph
77- return adapter . features . has ( "float32-blendable" ) ? "webgpu" : "webgl"
78+
79+ const canvas = document . createElement ( "canvas" )
80+ const gl =
81+ ( canvas . getContext ( "webgl2" ) as WebGL2RenderingContext | null ) ??
82+ ( canvas . getContext ( "webgl" ) as WebGLRenderingContext | null )
83+
84+ // we have to return webgl so pixijs automatically falls back to canvas
85+ if ( ! gl ) {
86+ return "webgl"
87+ }
88+
89+ const webglMaxTextures = gl . getParameter ( gl . MAX_TEXTURE_IMAGE_UNITS )
90+ const webgpuMaxTextures = device . limits . maxSampledTexturesPerShaderStage
91+
92+ return webglMaxTextures === webgpuMaxTextures ? "webgpu" : "webgl"
7893}
7994
8095async function renderGraph ( graph : HTMLElement , fullSlug : FullSlug ) {
You can’t perform that action at this time.
0 commit comments