SIGN IN SIGN UP

KTX2Loader: Fix ETC1S/UASTC prioritization (#31871)

Due to a historical accident, the list of formats for ETC1S was sorted
using UASTC priority. This change fixes that.

However, this exposes a problem that already exists for UASTC to ETC1S
as well: on Linux, Mesa drivers for various Intel and AMD GPUs expose
support for ETC2 and ASTC extensions even if the hardware does not
support them, as part of GLES compatibility. When a texture with an
emulated format is uploaded, the driver runs a very expensive CPU side
decompression; this runs on the main thread and causes performance and
memory issues.

When using Chrome based browsers, ANGLE filters out ASTC and ETC
extensions for us; we now detect Gecko based browsers like Firefox that
don't use ANGLE and do this filtering ourselves.

In principle, it is possible for GPUs to support all formats - notably,
Safari exposes all formats on macOS when using Apple Silicon hardware,
as it genuinely supports all possible formats. In this case we still
should prefer native (ASTC/ETC2) format targets as they are faster to
transcode to. A corner case is a combination of Firefox / Asahi Linux on
Apple Silicon hardware; in the future it might be possible to detect the
unmasked vendor to disambiguate, but even that combination will simply
use BC7 for UASTC or dual-slice ETC1S which is probably reasonable.
A
Arseny Kapoulkine committed
eac5acce91a6d91fc256cbd99fbbdf2d392b7652
Parent: f25b5a6
Committed by GitHub <[email protected]> on 9/17/2025, 8:05:02 AM