Module: Mesa Branch: main Commit: 4cb9c77e8e08507b5c181a480259e42b43dd647e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4cb9c77e8e08507b5c181a480259e42b43dd647e
Author: Jesse Natalie <jenat...@microsoft.com> Date: Thu Jan 11 15:46:07 2024 -0800 mesa: Consider mesa format in addition to internal format for mip/cube completeness Prior to 06b526de, the mesa format was used for these completeness checks. That was to address the case where a *different* internal format selected the *same* mesa format, and the texture shouldn't be considered compatible. But this didn't address the case where the *same* internal format selected a *different* mesa format, e.g. because the type passed to the TexImage API was different. An old WGL demo app called TexFilter.exe tries to redefine a mipped RGBA16 texture as RGBA8. This incorrect logic caused Mesa to try to copy the RGBA16 data from the smaller mips into the newly created RGBA8 data, because it thought that the texture was still mip-complete, despite the format changing. Cc: mesa-stable Reviewed-By: Mike Blumenkrantz <michael.blumenkra...@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27023> --- src/mesa/main/texobj.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 20e14ee21ee..5c960c730bf 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -817,7 +817,8 @@ _mesa_test_texobj_completeness( const struct gl_context *ctx, return; } if (t->Image[face][baseLevel]->InternalFormat != - baseImage->InternalFormat) { + baseImage->InternalFormat || + t->Image[face][baseLevel]->TexFormat != baseImage->TexFormat) { incomplete(t, BASE, "Cube face format mismatch"); return; } @@ -876,7 +877,8 @@ _mesa_test_texobj_completeness( const struct gl_context *ctx, incomplete(t, MIPMAP, "TexImage[%d] is missing", i); return; } - if (img->InternalFormat != baseImage->InternalFormat) { + if (img->InternalFormat != baseImage->InternalFormat || + img->TexFormat != baseImage->TexFormat) { incomplete(t, MIPMAP, "Format[i] != Format[baseLevel]"); return; }