Skip to content

Conversation

zeux
Copy link
Contributor

@zeux zeux commented Sep 10, 2025

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.

See #29730 (comment) for motivating profiles.

Fixes #29745

@zeux zeux force-pushed the ktx2-transcode-priority branch from 42c34fb to 1b6fbfe Compare September 10, 2025 07:21
@zeux
Copy link
Contributor Author

zeux commented Sep 10, 2025

WebGL report for posterity; ETC2 and ASTC are emulated but you can only tell by observing a significant performance degradation when using these:

image

@mrdoob mrdoob requested a review from donmccurdy September 12, 2025 06:11
@mrdoob mrdoob added this to the r181 milestone Sep 12, 2025
@zeux zeux force-pushed the ktx2-transcode-priority branch from 1b6fbfe to fd77d42 Compare September 15, 2025 01:18
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.
@zeux zeux force-pushed the ktx2-transcode-priority branch from fd77d42 to 2a7f67f Compare September 15, 2025 01:29
Copy link
Collaborator

@donmccurdy donmccurdy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a quick test at https://jsfiddle.net/donmccurdy/bkr3q8mc/ — prints navigatior.platform and whether Firefox is detected (true/false) — and as expected the Linux+Firefox checks return false on devices I have available. That's as expected, I don't have a Linux device currently.

Thank you @zeux!

@Mugen87 Mugen87 merged commit eac5acc into mrdoob:dev Sep 17, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KTX2Loader: Improve transcoder target format selection
4 participants