Check GL version and/or extension for using texture format GL_R8
BUG: 344301 FIXED-IN: 5.2.1 REVIEW: 122615
This commit is contained in:
parent
891c3fe83c
commit
7bbb68aad6
4 changed files with 21 additions and 1 deletions
|
@ -47,6 +47,7 @@ bool GLTexturePrivate::s_supportsARGB32 = false;
|
||||||
bool GLTexturePrivate::s_supportsUnpack = false;
|
bool GLTexturePrivate::s_supportsUnpack = false;
|
||||||
bool GLTexturePrivate::s_supportsTextureStorage = false;
|
bool GLTexturePrivate::s_supportsTextureStorage = false;
|
||||||
bool GLTexturePrivate::s_supportsTextureSwizzle = false;
|
bool GLTexturePrivate::s_supportsTextureSwizzle = false;
|
||||||
|
bool GLTexturePrivate::s_supportsTextureFormatRG = false;
|
||||||
uint GLTexturePrivate::s_textureObjectCounter = 0;
|
uint GLTexturePrivate::s_textureObjectCounter = 0;
|
||||||
uint GLTexturePrivate::s_fbo = 0;
|
uint GLTexturePrivate::s_fbo = 0;
|
||||||
|
|
||||||
|
@ -290,12 +291,16 @@ void GLTexturePrivate::initStatic()
|
||||||
hasGLExtension("GL_ARB_framebuffer_object") || hasGLExtension(QByteArrayLiteral("GL_EXT_framebuffer_object"));
|
hasGLExtension("GL_ARB_framebuffer_object") || hasGLExtension(QByteArrayLiteral("GL_EXT_framebuffer_object"));
|
||||||
s_supportsTextureStorage = hasGLVersion(4, 2) || hasGLExtension(QByteArrayLiteral("GL_ARB_texture_storage"));
|
s_supportsTextureStorage = hasGLVersion(4, 2) || hasGLExtension(QByteArrayLiteral("GL_ARB_texture_storage"));
|
||||||
s_supportsTextureSwizzle = hasGLVersion(3, 3) || hasGLExtension(QByteArrayLiteral("GL_ARB_texture_swizzle"));
|
s_supportsTextureSwizzle = hasGLVersion(3, 3) || hasGLExtension(QByteArrayLiteral("GL_ARB_texture_swizzle"));
|
||||||
|
// see https://www.opengl.org/registry/specs/ARB/texture_rg.txt
|
||||||
|
s_supportsTextureFormatRG = hasGLVersion(3, 0) || hasGLExtension(QByteArrayLiteral("GL_ARB_texture_rg"));
|
||||||
s_supportsARGB32 = true;
|
s_supportsARGB32 = true;
|
||||||
s_supportsUnpack = true;
|
s_supportsUnpack = true;
|
||||||
} else {
|
} else {
|
||||||
s_supportsFramebufferObjects = true;
|
s_supportsFramebufferObjects = true;
|
||||||
s_supportsTextureStorage = hasGLVersion(3, 0) || hasGLExtension(QByteArrayLiteral("GL_EXT_texture_storage"));
|
s_supportsTextureStorage = hasGLVersion(3, 0) || hasGLExtension(QByteArrayLiteral("GL_EXT_texture_storage"));
|
||||||
s_supportsTextureSwizzle = hasGLVersion(3, 0);
|
s_supportsTextureSwizzle = hasGLVersion(3, 0);
|
||||||
|
// see https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_rg.txt
|
||||||
|
s_supportsTextureFormatRG = hasGLVersion(3, 0) || hasGLExtension(QByteArrayLiteral("GL_EXT_texture_rg"));
|
||||||
|
|
||||||
// QImage::Format_ARGB32_Premultiplied is a packed-pixel format, so it's only
|
// QImage::Format_ARGB32_Premultiplied is a packed-pixel format, so it's only
|
||||||
// equivalent to GL_BGRA/GL_UNSIGNED_BYTE on little-endian systems.
|
// equivalent to GL_BGRA/GL_UNSIGNED_BYTE on little-endian systems.
|
||||||
|
@ -653,4 +658,9 @@ bool GLTexture::supportsSwizzle()
|
||||||
return GLTexturePrivate::s_supportsTextureSwizzle;
|
return GLTexturePrivate::s_supportsTextureSwizzle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GLTexture::supportsFormatRG()
|
||||||
|
{
|
||||||
|
return GLTexturePrivate::s_supportsTextureFormatRG;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace KWin
|
} // namespace KWin
|
||||||
|
|
|
@ -127,6 +127,15 @@ public:
|
||||||
*/
|
*/
|
||||||
static bool supportsSwizzle();
|
static bool supportsSwizzle();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns @c true if texture formats R* are supported, and @c false otherwise.
|
||||||
|
*
|
||||||
|
* This requires OpenGL 3.0, GL_ARB_texture_rg or OpenGL ES 3.0 or GL_EXT_texture_rg.
|
||||||
|
*
|
||||||
|
* @since 5.2.1
|
||||||
|
**/
|
||||||
|
static bool supportsFormatRG();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QExplicitlySharedDataPointer<GLTexturePrivate> d_ptr;
|
QExplicitlySharedDataPointer<GLTexturePrivate> d_ptr;
|
||||||
GLTexture(GLTexturePrivate& dd);
|
GLTexture(GLTexturePrivate& dd);
|
||||||
|
|
|
@ -74,6 +74,7 @@ public:
|
||||||
static bool s_supportsUnpack;
|
static bool s_supportsUnpack;
|
||||||
static bool s_supportsTextureStorage;
|
static bool s_supportsTextureStorage;
|
||||||
static bool s_supportsTextureSwizzle;
|
static bool s_supportsTextureSwizzle;
|
||||||
|
static bool s_supportsTextureFormatRG;
|
||||||
static GLuint s_fbo;
|
static GLuint s_fbo;
|
||||||
static uint s_textureObjectCounter;
|
static uint s_textureObjectCounter;
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -2252,7 +2252,7 @@ bool SceneOpenGLShadow::prepareBackend()
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
// Check if the image is alpha-only in practice, and if so convert it to an 8-bpp format
|
// Check if the image is alpha-only in practice, and if so convert it to an 8-bpp format
|
||||||
if (!GLPlatform::instance()->isGLES() && GLTexture::supportsSwizzle()) {
|
if (!GLPlatform::instance()->isGLES() && GLTexture::supportsSwizzle() && GLTexture::supportsFormatRG()) {
|
||||||
QImage alphaImage(image.size(), QImage::Format_Indexed8); // Change to Format_Alpha8 w/ Qt 5.5
|
QImage alphaImage(image.size(), QImage::Format_Indexed8); // Change to Format_Alpha8 w/ Qt 5.5
|
||||||
bool alphaOnly = true;
|
bool alphaOnly = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue