mesa/st: force nearest-filtering for fp32 textures

OpenGL 3.0 requires ARB_texture_float, which technically speaking
requires linear-filtering support for FP32 textures. However, because a
lot of early implementations just ignore this and does nearest filtering
instead due to lack of hardware features for this, this functionality
was never added to the OpenGL CTS.

The result is that FP32 is a feature that is required on paper, but
is unreliable to be used by applications in practice. This is mostly
fine; for most filterable use-cases (e.g colors), FP16 is fine and saves
a bunch of bandwidth, and for cases where you really need the extra bits
(depth-reads etc), filtering is usually not what's wanted.

To save drivers that doesn't support filtering of FP32 filtering from
having to manually whack the state, and get needless CSOs in the CSO
caches, let's force this in early, where we already do the same for
integer textures.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18292>
This commit is contained in:
Erik Faye-Lund
2022-08-29 10:38:59 +02:00
committed by Marge Bot
parent ec222a20da
commit 8abb5c8b41
3 changed files with 11 additions and 1 deletions

View File

@@ -685,6 +685,12 @@ struct gl_constants
*/
GLboolean ForceIntegerTexNearest;
/**
* Treat 32-bit floating-point textures using GL_LINEAR filters as
* GL_NEAREST.
*/
GLboolean ForceFloat32TexNearest;
/**
* Does the driver support real 32-bit integers? (Otherwise, integers are
* simulated via floats.)

View File

@@ -70,7 +70,8 @@ st_convert_sampler(const struct st_context *st,
sampler->seamless_cube_map |= seamless_cube_map;
if (texobj->_IsIntegerFormat) {
if (texobj->_IsIntegerFormat ||
(texobj->_IsFloat && st->ctx->Const.ForceFloat32TexNearest)) {
sampler->min_img_filter = PIPE_TEX_FILTER_NEAREST;
sampler->min_mip_filter = PIPE_TEX_FILTER_NEAREST;
sampler->mag_img_filter = PIPE_TEX_FILTER_NEAREST;

View File

@@ -699,6 +699,9 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
ctx->Const.NoClippingOnCopyTex = screen->get_param(screen,
PIPE_CAP_NO_CLIP_ON_COPY_TEX);
ctx->Const.ForceFloat32TexNearest =
!screen->get_param(screen, PIPE_CAP_TEXTURE_FLOAT_LINEAR);
ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].PositionAlwaysInvariant = options->vs_position_always_invariant;
ctx->Const.ShaderCompilerOptions[MESA_SHADER_TESS_EVAL].PositionAlwaysPrecise = options->vs_position_always_precise;