Prefer BGRA uploading to swizzling
The older BGRA extension is more likely to have stable driver support. Fixes: QTBUG-74150 Change-Id: If321b3024fbdeb9e199880744b9ee915b3b2bf6c Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
a74b2b5f15
commit
55cc93e9d6
@ -114,6 +114,18 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
|
||||
externalFormat = GL_BGRA;
|
||||
internalFormat = GL_RGBA;
|
||||
pixelType = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
|
||||
// Without GL_UNSIGNED_INT_8_8_8_8_REV, BGRA only matches ARGB on little endian:
|
||||
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::BGRATextureFormat) && !sRgbBinding) {
|
||||
// The GL_EXT_texture_format_BGRA8888 extension requires the internal format to match the external.
|
||||
externalFormat = internalFormat = GL_BGRA;
|
||||
pixelType = GL_UNSIGNED_BYTE;
|
||||
} else if (context->isOpenGLES() && context->hasExtension(QByteArrayLiteral("GL_APPLE_texture_format_BGRA8888"))) {
|
||||
// Is only allowed as an external format like OpenGL.
|
||||
externalFormat = GL_BGRA;
|
||||
internalFormat = GL_RGBA;
|
||||
pixelType = GL_UNSIGNED_BYTE;
|
||||
#endif
|
||||
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
|
||||
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
|
||||
GLint swizzle[4] = { GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
|
||||
@ -125,26 +137,9 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
|
||||
externalFormat = internalFormat = GL_RGBA;
|
||||
pixelType = GL_UNSIGNED_BYTE;
|
||||
} else {
|
||||
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
|
||||
// Without GL_UNSIGNED_INT_8_8_8_8_REV, BGRA only matches ARGB on little endian.
|
||||
if (funcs->hasOpenGLExtension(QOpenGLExtensions::BGRATextureFormat) && !sRgbBinding) {
|
||||
// The GL_EXT_texture_format_BGRA8888 extension requires the internal format to match the external.
|
||||
externalFormat = internalFormat = GL_BGRA;
|
||||
pixelType = GL_UNSIGNED_BYTE;
|
||||
} else if (context->isOpenGLES() && context->hasExtension(QByteArrayLiteral("GL_APPLE_texture_format_BGRA8888"))) {
|
||||
// Is only allowed as an external format like OpenGL.
|
||||
externalFormat = GL_BGRA;
|
||||
internalFormat = GL_RGBA;
|
||||
pixelType = GL_UNSIGNED_BYTE;
|
||||
} else {
|
||||
// No support for direct ARGB32 upload.
|
||||
break;
|
||||
}
|
||||
#else
|
||||
// Big endian requires GL_UNSIGNED_INT_8_8_8_8_REV for ARGB to match BGRA
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
targetFormat = image.format();
|
||||
break;
|
||||
case QImage::Format_BGR30:
|
||||
|
Loading…
Reference in New Issue
Block a user