Revert "st/mesa: Transcode ASTC to BC7 (BPTC) where possible"
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 17 May 2022 20:51:49 +0000 (13:51 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 18 May 2022 09:45:43 +0000 (09:45 +0000)
commitc54555c496aea12d280ac6e882e81d3d69673e98
tree4fe71e2312454d59dbc665c0ff297d6404506ff4
parent74a172a44857ccf7c73a03913bd4e1498dbf601e
Revert "st/mesa: Transcode ASTC to BC7 (BPTC) where possible"

This reverts commit 68ef895674b176b4faf875a4d7f4d787b330d4d9.

When trying out transcode_astc=true with BPTC on Asphalt 9, we observed
very poor image quality - to the point that basic UI icons were blocky,
and buttons with a black border had smeared pixels on the edges.  Using
DXT5 had no such issues.

I originally suspected there was a bug in the BPTC encoder, but I now
believe the issue is deeper than that.  The commit that introduced the
encoder, 17cde55c538009764207bd29b78a909d2c5d14b4, says:

   "The compressor is written from scratch and takes a very simple
    approach.  It always uses a single mode of the BPTC format (4 for
    unorm and 3 for half-floats) and picks the two endpoints by dividing
    the texels into those which have more or less than the average
    luminance of the block and then calculating an average color of the
    texels within each division.

    It's probably not really sensible to try to use BPTC compression at
    runtime because for example with the Nvidia offline compression tool
    it can take in the order of an hour to compress a full-screen image.
    With that in mind I don't think it's worth having a proper compressor
    in Mesa and this approach gives reasonable results for a usage that
    is basically a corner case."

In other words, the reason our BPTC compressor was so fast is that it
only implements one of the modes and does a low quality approximation.
This honestly should probably be improved somewhat, but the original
use case was for online-compression, the uncommon but mandatory OpenGL
feature where you can supply uncompressed data and trust the driver to
compress it for you (at unknown and uncontrolled quality and speed).

Unfortunately, the compressor as it stands is simply not usable for
transcoding ASTC data where we want to preserve the underlying image
quality as much as possible.

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16566>
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_format.c