Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 3x 5x 5x 4x 4x 3x 3x | /**
* Keeps Pixi's WebGPU renderer from making transient (memoryless) multisampled textures.
*
* On a tile-based GPU (Apple, Arm, Qualcomm, Imagination) Pixi creates every MSAA texture with
* `GPUTextureUsage.TRANSIENT_ATTACHMENT` when the browser has it, and discards it after the resolve. Safari 27's WebGPU
* fails the command buffer that renders into such a texture (`MTLCommandBufferErrorInvalidResource`) and kills its GPU
* process for it, which loses every WebGPU device and WebGL context on the page: the built-in skins draw through a
* multisampled render texture, so the stage stayed blank. Turning both capabilities off gives ordinary stored MSAA
* textures, at the cost of their memory.
*/
/** What this needs of Pixi's `WebGPURenderer`. */
export interface TransientAttachmentRenderer {
readonly device: { extensions: { tileBased: boolean; transientAttachment: boolean } | null };
readonly runners: { readonly contextChange: { add(item: unknown): unknown } };
}
/**
* Turns off `renderer`'s transient MSAA textures now and after every device change: Pixi probes the capabilities
* again on each device, including the one that replaces a lost device, before it emits `contextChange`.
*/
export function disableTransientAttachments(renderer: TransientAttachmentRenderer): void {
const disable = () => {
const extensions = renderer.device.extensions;
if (extensions === null) return;
extensions.tileBased = false;
extensions.transientAttachment = false;
};
disable();
renderer.runners.contextChange.add({ contextChange: disable });
}
|