Revert "st/mesa: Transcode ASTC to BC7 (BPTC) where possible"

This reverts commit 68ef895674.

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, 17cde55c53, 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>
This commit is contained in:
Kenneth Graunke 2022-05-17 13:51:49 -07:00 committed by Marge Bot
parent 74a172a448
commit c54555c496
3 changed files with 12 additions and 28 deletions

View File

@ -568,20 +568,13 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
screen->is_format_supported(screen, PIPE_FORMAT_DXT1_SRGBA,
PIPE_TEXTURE_2D, 0, 0,
PIPE_BIND_SAMPLER_VIEW);
st->transcode_astc_to_bptc = options->transcode_astc &&
screen->is_format_supported(screen, PIPE_FORMAT_BPTC_SRGBA,
PIPE_TEXTURE_2D, 0, 0,
PIPE_BIND_SAMPLER_VIEW) &&
screen->is_format_supported(screen, PIPE_FORMAT_BPTC_RGBA_UNORM,
PIPE_TEXTURE_2D, 0, 0,
PIPE_BIND_SAMPLER_VIEW);
st->transcode_astc_to_dxt5 = options->transcode_astc &&
screen->is_format_supported(screen, PIPE_FORMAT_DXT5_SRGBA,
PIPE_TEXTURE_2D, 0, 0,
PIPE_BIND_SAMPLER_VIEW) &&
screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
PIPE_TEXTURE_2D, 0, 0,
PIPE_BIND_SAMPLER_VIEW);
st->transcode_astc = options->transcode_astc &&
screen->is_format_supported(screen, PIPE_FORMAT_DXT5_SRGBA,
PIPE_TEXTURE_2D, 0, 0,
PIPE_BIND_SAMPLER_VIEW) &&
screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
PIPE_TEXTURE_2D, 0, 0,
PIPE_BIND_SAMPLER_VIEW);
st->has_astc_2d_ldr =
screen->is_format_supported(screen, PIPE_FORMAT_ASTC_4x4_SRGB,
PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_SAMPLER_VIEW);

View File

@ -140,8 +140,7 @@ struct st_context
boolean has_etc1;
boolean has_etc2;
boolean transcode_etc;
boolean transcode_astc_to_bptc;
boolean transcode_astc_to_dxt5;
boolean transcode_astc;
boolean has_astc_2d_ldr;
boolean has_astc_5x5_ldr;
boolean prefer_blit_based_texture_transfer;

View File

@ -111,19 +111,11 @@ st_mesa_format_to_pipe_format(const struct st_context *st,
if (st_astc_format_fallback(st, mesaFormat)) {
if (_mesa_is_format_srgb(mesaFormat)) {
if (st->transcode_astc_to_bptc)
return PIPE_FORMAT_BPTC_SRGBA;
else if (st->transcode_astc_to_dxt5)
return PIPE_FORMAT_DXT5_SRGBA;
else
return PIPE_FORMAT_R8G8B8A8_SRGB;
return st->transcode_astc ? PIPE_FORMAT_DXT5_SRGBA :
PIPE_FORMAT_R8G8B8A8_SRGB;
} else {
if (st->transcode_astc_to_bptc)
return PIPE_FORMAT_BPTC_RGBA_UNORM;
else if (st->transcode_astc_to_dxt5)
return PIPE_FORMAT_DXT5_RGBA;
else
return PIPE_FORMAT_R8G8B8A8_UNORM;
return st->transcode_astc ? PIPE_FORMAT_DXT5_RGBA :
PIPE_FORMAT_R8G8B8A8_UNORM;
}
}