From 2e3cf3a6a60fc4a067f7cfc74c76e28216cef88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Tue, 10 May 2022 17:23:24 +0200 Subject: [PATCH] mesa: Make sure to fallback to handling the original choose texture format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is possible for st_ChooseTextureFormat to return MESA_FORMAT_NONE when samples is forced to 2. Always allow to fallback to the original case. Fixes: 89c94502b6650fed222abd3588e9c927811580aa Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6441 Signed-off-by: Corentin Noël Reviewed-by: Marek Olšák Part-of: --- src/mesa/main/teximage.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index edea906239e..ce64681c37b 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2824,7 +2824,7 @@ _mesa_choose_texture_format(struct gl_context *ctx, GLenum internalFormat, GLenum format, GLenum type, unsigned samples) { - mesa_format f; + mesa_format f = MESA_FORMAT_NONE; /* see if we've already chosen a format for the previous level */ if (level > 0) { @@ -2843,6 +2843,7 @@ _mesa_choose_texture_format(struct gl_context *ctx, } if (samples > 0) { + unsigned trySamples = samples; /* TODO: This somewhat duplicates the logic in st_texture_storage. */ /* Find msaa sample count which is actually supported. For example, * if the user requests 1x but only 4x or 8x msaa is supported, we'll @@ -2850,19 +2851,22 @@ _mesa_choose_texture_format(struct gl_context *ctx, */ if (ctx->Const.MaxSamples > 1 && samples == 1) { /* don't try num_samples = 1 with drivers that support real msaa */ - samples = 2; + trySamples = 2; } - for (; samples <= ctx->Const.MaxSamples; samples++) { + for (; trySamples <= ctx->Const.MaxSamples; trySamples++) { f = st_ChooseTextureFormat(ctx, target, internalFormat, - format, type, samples); - if (f != PIPE_FORMAT_NONE) + format, type, trySamples); + if (f != MESA_FORMAT_NONE) break; } - } else { + } + + if (f == MESA_FORMAT_NONE) { f = st_ChooseTextureFormat(ctx, target, internalFormat, format, type, samples); } + assert(f != MESA_FORMAT_NONE); return f; }