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.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27023>
(cherry picked from commit 4cb9c77e8e08507b5c181a480259e42b43dd647e)
This commit is contained in:
Jesse Natalie 2024-01-11 15:46:07 -08:00 committed by Eric Engestrom
parent 04ffe4771e
commit f19b7d8dfc
2 changed files with 5 additions and 3 deletions

View file

@ -284,7 +284,7 @@
"description": "mesa: Consider mesa format in addition to internal format for mip/cube completeness",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -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;
}