|
|
2ab645 |
From d4efd5ab810e92202efe672be29136324dd2a3f9 Mon Sep 17 00:00:00 2001
|
|
|
2ab645 |
From: =?UTF-8?q?D=C4=81vis=20Mos=C4=81ns?= <davispuh@gmail.com>
|
|
|
2ab645 |
Date: Mon, 28 Dec 2015 05:43:18 +0200
|
|
|
2ab645 |
Subject: [PATCH] Check for NULL from glGetString
|
|
|
2ab645 |
|
|
|
2ab645 |
glGetString can return NULL pointer in case of error
|
|
|
2ab645 |
so check for it before using.
|
|
|
2ab645 |
|
|
|
2ab645 |
Change-Id: Ia07424c8f2b3ce6dce675514900a509e3ef3b739
|
|
|
2ab645 |
---
|
|
|
2ab645 |
src/particles/qquickimageparticle.cpp | 6 ++++--
|
|
|
2ab645 |
src/quick/scenegraph/qsgcontext.cpp | 22 ++++++++++++++++------
|
|
|
2ab645 |
.../qsgdefaultdistancefieldglyphcache.cpp | 8 +++++---
|
|
|
2ab645 |
src/quick/scenegraph/util/qsgatlastexture.cpp | 4 ++--
|
|
|
2ab645 |
4 files changed, 27 insertions(+), 13 deletions(-)
|
|
|
2ab645 |
|
|
|
2ab645 |
diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp
|
|
|
2ab645 |
index d78a350..b54861e 100644
|
|
|
2ab645 |
--- a/src/particles/qquickimageparticle.cpp
|
|
|
2ab645 |
+++ b/src/particles/qquickimageparticle.cpp
|
|
|
2ab645 |
@@ -1276,14 +1276,16 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node)
|
|
|
2ab645 |
// OS X 10.8.3 introduced a bug in the AMD drivers, for at least the 2011 macbook pros,
|
|
|
2ab645 |
// causing point sprites who read gl_PointCoord in the frag shader to come out as
|
|
|
2ab645 |
// green-red blobs.
|
|
|
2ab645 |
- if (perfLevel < Deformable && strstr((char *) glGetString(GL_VENDOR), "ATI")) {
|
|
|
2ab645 |
+ const char *vendor = (const char *) glGetString(GL_VENDOR);
|
|
|
2ab645 |
+ if (perfLevel < Deformable && vendor && strstr(vendor, "ATI")) {
|
|
|
2ab645 |
perfLevel = Deformable;
|
|
|
2ab645 |
}
|
|
|
2ab645 |
#endif
|
|
|
2ab645 |
|
|
|
2ab645 |
#ifdef Q_OS_LINUX
|
|
|
2ab645 |
// Nouveau drivers can potentially freeze a machine entirely when taking the point-sprite path.
|
|
|
2ab645 |
- if (perfLevel < Deformable && strstr((const char *) glGetString(GL_VENDOR), "nouveau"))
|
|
|
2ab645 |
+ const char *vendor = (const char *) glGetString(GL_VENDOR);
|
|
|
2ab645 |
+ if (perfLevel < Deformable && vendor && strstr(vendor, "nouveau"))
|
|
|
2ab645 |
perfLevel = Deformable;
|
|
|
2ab645 |
#endif
|
|
|
2ab645 |
|
|
|
2ab645 |
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
|
|
|
2ab645 |
index dd6977e..43d549f 100644
|
|
|
2ab645 |
--- a/src/quick/scenegraph/qsgcontext.cpp
|
|
|
2ab645 |
+++ b/src/quick/scenegraph/qsgcontext.cpp
|
|
|
2ab645 |
@@ -624,14 +624,24 @@ void QSGRenderContext::initialize(QOpenGLContext *context)
|
|
|
2ab645 |
m_sg->renderContextInitialized(this);
|
|
|
2ab645 |
|
|
|
2ab645 |
#ifdef Q_OS_LINUX
|
|
|
2ab645 |
+ while (funcs->glGetError() != GL_NO_ERROR);
|
|
|
2ab645 |
+
|
|
|
2ab645 |
const char *vendor = (const char *) funcs->glGetString(GL_VENDOR);
|
|
|
2ab645 |
- if (strstr(vendor, "nouveau"))
|
|
|
2ab645 |
- m_brokenIBOs = true;
|
|
|
2ab645 |
const char *renderer = (const char *) funcs->glGetString(GL_RENDERER);
|
|
|
2ab645 |
- if (strstr(renderer, "llvmpipe"))
|
|
|
2ab645 |
- m_serializedRender = true;
|
|
|
2ab645 |
- if (strstr(vendor, "Hisilicon Technologies") && strstr(renderer, "Immersion.16"))
|
|
|
2ab645 |
- m_brokenIBOs = true;
|
|
|
2ab645 |
+
|
|
|
2ab645 |
+ if (vendor && renderer) {
|
|
|
2ab645 |
+ if (strstr(vendor, "nouveau"))
|
|
|
2ab645 |
+ m_brokenIBOs = true;
|
|
|
2ab645 |
+ if (strstr(renderer, "llvmpipe"))
|
|
|
2ab645 |
+ m_serializedRender = true;
|
|
|
2ab645 |
+ if (strstr(vendor, "Hisilicon Technologies") && strstr(renderer, "Immersion.16"))
|
|
|
2ab645 |
+ m_brokenIBOs = true;
|
|
|
2ab645 |
+ } else {
|
|
|
2ab645 |
+ GLenum err;
|
|
|
2ab645 |
+ while ((err = funcs->glGetError()) != GL_NO_ERROR) {
|
|
|
2ab645 |
+ qWarning("QSGRenderContext::initialize: GL error %x from glGetString", err);
|
|
|
2ab645 |
+ }
|
|
|
2ab645 |
+ }
|
|
|
2ab645 |
#endif
|
|
|
2ab645 |
|
|
|
2ab645 |
emit initialized();
|
|
|
2ab645 |
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
|
|
|
2ab645 |
index dcc485c..43e234b 100644
|
|
|
2ab645 |
--- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
|
|
|
2ab645 |
+++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
|
|
|
2ab645 |
@@ -488,9 +488,11 @@ bool QSGDefaultDistanceFieldGlyphCache::useTextureUploadWorkaround() const
|
|
|
2ab645 |
static bool set = false;
|
|
|
2ab645 |
static bool useWorkaround = false;
|
|
|
2ab645 |
if (!set) {
|
|
|
2ab645 |
- useWorkaround = qstrcmp(reinterpret_cast<const char*>(m_funcs->glGetString(GL_RENDERER)),
|
|
|
2ab645 |
- "Mali-400 MP") == 0;
|
|
|
2ab645 |
- set = true;
|
|
|
2ab645 |
+ const char *renderer = reinterpret_cast<const char*>(m_funcs->glGetString(GL_RENDERER));
|
|
|
2ab645 |
+ if (renderer) {
|
|
|
2ab645 |
+ useWorkaround = qstrcmp(renderer, "Mali-400 MP") == 0;
|
|
|
2ab645 |
+ set = true;
|
|
|
2ab645 |
+ }
|
|
|
2ab645 |
}
|
|
|
2ab645 |
return useWorkaround;
|
|
|
2ab645 |
}
|
|
|
2ab645 |
diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp
|
|
|
2ab645 |
index 8e8e870..d726907 100644
|
|
|
2ab645 |
--- a/src/quick/scenegraph/util/qsgatlastexture.cpp
|
|
|
2ab645 |
+++ b/src/quick/scenegraph/util/qsgatlastexture.cpp
|
|
|
2ab645 |
@@ -150,13 +150,13 @@ Atlas::Atlas(const QSize &size)
|
|
|
2ab645 |
wrongfullyReportsBgra8888Support = false;
|
|
|
2ab645 |
|
|
|
2ab645 |
const char *ext = (const char *) QOpenGLContext::currentContext()->functions()->glGetString(GL_EXTENSIONS);
|
|
|
2ab645 |
- if (!wrongfullyReportsBgra8888Support
|
|
|
2ab645 |
+ if (!wrongfullyReportsBgra8888Support && ext
|
|
|
2ab645 |
&& (strstr(ext, "GL_EXT_bgra")
|
|
|
2ab645 |
|| strstr(ext, "GL_EXT_texture_format_BGRA8888")
|
|
|
2ab645 |
|| strstr(ext, "GL_IMG_texture_format_BGRA8888"))) {
|
|
|
2ab645 |
m_internalFormat = m_externalFormat = GL_BGRA;
|
|
|
2ab645 |
#ifdef Q_OS_IOS
|
|
|
2ab645 |
- } else if (strstr(ext, "GL_APPLE_texture_format_BGRA8888")) {
|
|
|
2ab645 |
+ } else if (ext && strstr(ext, "GL_APPLE_texture_format_BGRA8888")) {
|
|
|
2ab645 |
m_internalFormat = GL_RGBA;
|
|
|
2ab645 |
m_externalFormat = GL_BGRA;
|
|
|
2ab645 |
#endif // IOS
|
|
|
2ab645 |
--
|
|
|
2ab645 |
1.9.3
|
|
|
2ab645 |
|