mesa/main: work around chrome/firefox bug

Due to flawed logic, Chromium and Firefox thinks EXT_texture_storage
allows using GL_BGRA8_EXT for *all* texturing, including things like
glTexSubImage2D, which it does not.

However, this bug was introduced in Chromium back in 2016, and there's
also a lot of Electron apps that bundle outdated versions of Chromium.
This means it's going to be a *mess* to fix this properly while staying
within the spec.

I've opened a ticket with Khronos to consider changing the spec to make
this legal, because it seems most other OpenGL implementations allow it.

But in the mean time, let's complain a bit, but accept the behavior.
This way people can at least run browsers with hardware acceleration
again. If we decide to change the spec, we can remove this wording.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10550
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27521>
This commit is contained in:
Erik Faye-Lund 2024-02-08 11:56:42 +01:00 committed by Marge Bot
parent d0cc0e74dd
commit b6b980a904
2 changed files with 20 additions and 3 deletions

View file

@ -2745,7 +2745,7 @@ gles_effective_internal_format_for_format_and_type(GLenum format,
* are required for complete checking between format and type.
*/
static GLenum
_mesa_gles_check_internalformat(const struct gl_context *ctx,
_mesa_gles_check_internalformat(struct gl_context *ctx,
GLenum internalFormat)
{
switch (internalFormat) {
@ -2900,6 +2900,22 @@ _mesa_gles_check_internalformat(const struct gl_context *ctx,
if (!_mesa_is_gles3(ctx))
return GL_INVALID_VALUE;
return GL_NO_ERROR;
case GL_BGRA8_EXT: {
/* This is technically speaking out-of-spec. But too many
* applications seems to depend on it, so let's allow it
* together with a small complaint */
static bool warned = false;
if (!warned) {
_mesa_warning(ctx,
"internalformat = GL_BGRA8_EXT invalid by spec, but too many "
"applications depend on it to error. Please fix the software "
"that causes this problem.");
warned = true;
}
return GL_NO_ERROR;
}
default:
return GL_INVALID_VALUE;
}
@ -2911,7 +2927,7 @@ _mesa_gles_check_internalformat(const struct gl_context *ctx,
* \return error code, or GL_NO_ERROR.
*/
GLenum
_mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
_mesa_gles_error_check_format_and_type(struct gl_context *ctx,
GLenum format, GLenum type,
GLenum internalFormat)
{
@ -2980,6 +2996,7 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
if (type != GL_UNSIGNED_BYTE ||
(internalFormat != GL_BGRA &&
internalFormat != GL_RGBA8 &&
internalFormat != GL_BGRA8_EXT &&
internalFormat != GL_SRGB8_ALPHA8))
return GL_INVALID_OPERATION;
break;

View file

@ -139,7 +139,7 @@ _mesa_es_error_check_format_and_type(const struct gl_context *ctx,
unsigned dimensions);
extern GLenum
_mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
_mesa_gles_error_check_format_and_type(struct gl_context *ctx,
GLenum format, GLenum type,
GLenum internalFormat);
extern GLint