Fix glCopyTexImage support for BGRA color buffers.
Neither GL_EXT_texture_format_BGRA8888 nor
GL_APPLE_texture_format_BGRA8888 make mention of GL_BGRA_EXT
or GL_BGRA8_EXT being accepted as the internalformat parameter of
glCopyTexImage2D, but there's a reasonable assumption that textures
with BGRA format can be used as the read color buffer.
GL_EXT_texture_format_BGRA8888 does mention that the format is
color-renderable, and GL_APPLE_texture_format_BGRA8888 adds it to table
3.2 (but fails to mention changes to table 3.16).
Bug swiftshader:96
Change-Id: I6d18faeaded73164a2c6af87ae6109fc77825964
Reviewed-on: https://swiftshader-review.googlesource.com/17448
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/OpenGL/libGLES_CM/libGLES_CM.cpp b/src/OpenGL/libGLES_CM/libGLES_CM.cpp
index 75fb538..93ff16a 100644
--- a/src/OpenGL/libGLES_CM/libGLES_CM.cpp
+++ b/src/OpenGL/libGLES_CM/libGLES_CM.cpp
@@ -920,7 +920,9 @@
if(colorbufferFormat != GL_RGBA &&
colorbufferFormat != GL_RGBA4_OES &&
colorbufferFormat != GL_RGB5_A1_OES &&
- colorbufferFormat != GL_RGBA8_OES)
+ colorbufferFormat != GL_RGBA8_OES &&
+ colorbufferFormat != GL_BGRA_EXT && // GL_EXT_texture_format_BGRA8888
+ colorbufferFormat != GL_BGRA8_EXT) // GL_EXT_texture_format_BGRA8888
{
return error(GL_INVALID_OPERATION);
}
@@ -929,6 +931,7 @@
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
return error(GL_INVALID_OPERATION);
+ case GL_BGRA_EXT: // GL_EXT_texture_format_BGRA8888 doesn't mention the format to be accepted by glCopyTexImage2D.
default:
return error(GL_INVALID_ENUM);
}
diff --git a/src/OpenGL/libGLESv2/utilities.cpp b/src/OpenGL/libGLESv2/utilities.cpp
index 8e1bc05..6a0a417 100644
--- a/src/OpenGL/libGLESv2/utilities.cpp
+++ b/src/OpenGL/libGLESv2/utilities.cpp
@@ -623,7 +623,8 @@
break;
case GL_LUMINANCE_ALPHA:
case GL_RGBA:
- if(baseColorbufferFormat != GL_RGBA)
+ if(baseColorbufferFormat != GL_RGBA &&
+ baseColorbufferFormat != GL_BGRA_EXT) // GL_EXT_texture_format_BGRA8888 / GL_APPLE_texture_format_BGRA8888
{
return error(GL_INVALID_OPERATION, false);
}
@@ -656,6 +657,7 @@
case GL_DEPTH_COMPONENT:
case GL_DEPTH_STENCIL_OES:
return error(GL_INVALID_OPERATION, false);
+ case GL_BGRA_EXT: // GL_EXT_texture_format_BGRA8888 nor GL_APPLE_texture_format_BGRA8888 mention the format to be accepted by glCopyTexImage2D.
default:
return error(GL_INVALID_ENUM, false);
}