Merge lp:~stellarium/stellarium/gz_insufficient-shader-level into lp:stellarium

Proposed by gzotti
Status: Superseded
Proposed branch: lp:~stellarium/stellarium/gz_insufficient-shader-level
Merge into: lp:stellarium
Diff against target: 394 lines (+213/-106)
4 files modified
src/StelMainView.cpp (+188/-54)
src/StelMainView.hpp (+2/-1)
src/core/modules/Planet.cpp (+4/-0)
src/main.cpp (+19/-51)
To merge this branch: bzr merge lp:~stellarium/stellarium/gz_insufficient-shader-level
Reviewer Review Type Date Requested Status
gzotti Needs Resubmitting
Fabien Chéreau Needs Fixing
Review via email: mp+240312@code.launchpad.net

This proposal has been superseded by a proposal from 2014-11-11.

Commit message

Better OpenGL startup diagnostics and error messaging towards the user.

To post a comment you must log in.
Revision history for this message
Fabien Chéreau (xalioth) wrote :

It's fine for me, but it would be good to also allow user to click on something like "Understood, don't show me this again" which will set the option in the config file

review: Needs Fixing
7113. By gzotti

removed command line option to ignore OpenGL version errors, same functionality will be taken by config flag.

7114. By gzotti

added config option main/ignore_opengl_warning to suppress further notice.

Revision history for this message
gzotti (georg-zotti) wrote :

OK, I changed this from command line option to config.ini setting.

I don't see a "Run Once" option in the QMessagebox buttons (Ignore without saving), but this whole addition should just be enough to catch most "does not run", "black screen", etc. bug reports. What would be nice would be GLSL1.20 fallback planet shaders for OpenGL2.1-only systems. (No shadows, just Phong model.) I also wonder about the GLSL answer string on OpenGL ES2.0, I have no system to test.

review: Needs Resubmitting
Revision history for this message
Fabien Chéreau (xalioth) wrote :

Please also get rid of QGLFormat and related deprecated classes.

review: Needs Fixing
7115. By gzotti

Removed QGLFormat-based startup tests for OpenGL capabilities. (Old version just commented away)

Revision history for this message
gzotti (georg-zotti) wrote :

OK, I could remove all QGLFormat things in the startup tests. But the context creation in StelMainView l.306 was something I did not dare touching. I cannot test the GLES tests, have no ANGLE build system here.

The old version is only commented away, I would remove it on merge.

review: Needs Resubmitting
7116. By gzotti

better startup hardware diagnostics esp. for ANGLE users

7117. By gzotti

Formatting fix for nicer OpenGL version message. (Thanks AW)

7118. By gzotti

Improved startup test and diagnostic for ANGLE.

7119. By gzotti

prettified detected OpenGL version string.

7120. By gzotti

code cleanup

Revision history for this message
gzotti (georg-zotti) wrote :

The only thing that remains appears to be changing the (Stel)QGLWidget and other QGL... classes. On http://qt-project.org/wiki/New-Features-in-Qt-5.4 you can read there will be a QOpenGLWidget to replace QGLWidget. I would prefer to make this (hopefully easy) change after Qt5.4 is out, and merge this now so that our test builds and RCs can be tested and diagnosed on the various hardware already now.

review: Needs Resubmitting
Revision history for this message
Alexander Wolf (alexwolf) wrote :

QOpenGLWidget & QGLWidget should be used with ifdef's IMHO (if we not set minimal Qt as 5.4.0)

7121. By gzotti

added two more test for detection of obviously unusable systems.

7122. By gzotti

Reactivate 0.12 line smoothing for AngleMeasure and CompassMarks plugins and activate it for Gridline drawing on capable systems. It really looks better. Compilation should not fail on ANGLE or other OpenGLES builds.

7123. By gzotti

Started migration towards QOpenGLwidget for Qt5.4. THIS COMPILES, BUT DOES NOT YET RUN!

7124. By gzotti

added a test for minimal Mesa version (10) if Mesa is used.
changed conditional compiling with the new QtOpenGL... classes from checking Qt version (>=5.4) to a single #define. Migration towards using these new classes is not finished, help wanted...

7125. By gzotti

merged with trunk r7172

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/StelMainView.cpp'
2--- src/StelMainView.cpp 2014-10-26 13:26:29 +0000
3+++ src/StelMainView.cpp 2014-11-11 14:09:15 +0000
4@@ -46,6 +46,7 @@
5 #include <QTimer>
6 #include <QWidget>
7 #include <QWindow>
8+#include <QMessageBox>
9 #include <QDeclarativeContext>
10 #ifdef Q_OS_WIN
11 #include <QPinchGesture>
12@@ -344,17 +345,197 @@
13 Q_ASSERT(glWidget->isValid());
14 glWidget->makeCurrent();
15
16- // Debug info about supported version of OpenGL and vendor/renderer
17- qDebug() << "OpenGL versions supported:" << getSupportedOpenGLVersion();
18+ // Find out lots of debug info about supported version of OpenGL and vendor/renderer
19+ QOpenGLContext* context=QOpenGLContext::currentContext();
20+ QSurfaceFormat format=context->format();
21+
22+ bool openGLerror=false;
23+ if (format.renderableType()==QSurfaceFormat::OpenGL || format.renderableType()==QSurfaceFormat::OpenGLES)
24+ {
25+ qDebug() << "Detected:" << (format.renderableType()==QSurfaceFormat::OpenGL ? "OpenGL" : "OpenGL ES" ) << QString("%1.%2").arg(format.majorVersion()).arg(format.minorVersion());
26+ }
27+ else
28+ {
29+ openGLerror=true;
30+ qDebug() << "Neither OpenGL nor OpenGL ES detected: Unsupported Format!";
31+ }
32+
33 qDebug() << "Driver version string:" << QString(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
34 qDebug() << "GL vendor is" << QString(reinterpret_cast<const char*>(glGetString(GL_VENDOR)));
35- qDebug() << "GL renderer is" << QString(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
36- qDebug() << "GL Shading Language version is" << QString(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
37-
38+ QString glRenderer(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
39+ qDebug() << "GL renderer is" << glRenderer;
40+
41+ // Minimal required version of OpenGL for Qt5 is 2.1 and OpenGL Shading Language may be 1.20 (or OpenGL ES is 2.0 and GLSL ES is 1.0).
42+ // As of V0.13.0..1, we use OpenGL Shading Language 1.30, i.e. we need in fact OpenGL 3.0 and above.
43+ // If platform does not even support minimal OpenGL version for Qt5, then tell the user about troubles and quit from application.
44+ if ( openGLerror ||
45+ ((format.renderableType()==QSurfaceFormat::OpenGL ) && (format.version() < QPair<int, int>(2, 1))) ||
46+ ((format.renderableType()==QSurfaceFormat::OpenGLES) && (format.version() < QPair<int, int>(2, 0))) )
47+ {
48+ #ifdef Q_OS_WIN
49+ qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, graphics hardware, or use MESA (or ANGLE) version.";
50+ QMessageBox::critical(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, graphics hardware, or use MESA (or ANGLE) version."), QMessageBox::Abort, QMessageBox::Abort);
51+ #else
52+ qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, or graphics hardware.";
53+ QMessageBox::critical(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, or graphics hardware."), QMessageBox::Abort, QMessageBox::Abort);
54+ #endif
55+ exit(0);
56+ }
57+ // This call requires OpenGL2+.
58+ QString glslString(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
59+ qDebug() << "GL Shading Language version is" << glslString;
60+
61 // Only give extended info if called on command line, for diagnostic.
62 if (qApp->property("dump_OpenGL_details").toBool())
63 dumpOpenGLdiagnostics();
64
65+#ifdef Q_OS_WIN
66+ // If we have ANGLE, check esp. for insufficient ps_2 level.
67+ if (glRenderer.startsWith("ANGLE"))
68+ {
69+ QRegExp angleVsPsRegExp(" vs_(\\d)_(\\d) ps_(\\d)_(\\d)");
70+ int angleVSPSpos=angleVsPsRegExp.indexIn(glRenderer);
71+
72+ if (angleVSPSpos >-1)
73+ {
74+ float vsVersion=angleVsPsRegExp.cap(1).toFloat() + 0.1*angleVsPsRegExp.cap(2).toFloat();
75+ float psVersion=angleVsPsRegExp.cap(3).toFloat() + 0.1*angleVsPsRegExp.cap(4).toFloat();
76+ qDebug() << "VS Version Number after parsing: " << vsVersion;
77+ qDebug() << "PS Version Number after parsing: " << psVersion;
78+ if ((vsVersion<2.0) || (psVersion<3.0))
79+ {
80+ openGLerror=true;
81+ qDebug() << "This is not enough: we need DirectX9 with vs_2_0 and ps_3_0 or later.";
82+ qDebug() << "You should update graphics drivers, graphics hardware, or use the OpenGL-MESA version.";
83+ qDebug() << "Else, please try to use an older version like 0.12.4, and try there with --safe-mode";
84+
85+ if (conf->value("main/ignore_opengl_warning", false).toBool())
86+ {
87+ qDebug() << "Config option main/ignore_opengl_warning found, continuing. Expect problems.";
88+ }
89+ else
90+ {
91+ qDebug() << "You can try to run in an unsupported degraded mode by ignoring the warning and continuing.";
92+ qDebug() << "But more than likely problems will persist.";
93+ QMessageBox::StandardButton answerButton=
94+ QMessageBox::critical(0, "Stellarium", q_("Your DirectX/OpenGL ES subsystem has problems. See log for details.\nIgnore and suppress this notice in the future and try to continue in degraded mode anyway?"),
95+ QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
96+ if (answerButton == QMessageBox::Abort)
97+ {
98+ qDebug() << "Aborting due to ANGLE OpenGL ES / DirectX vs or ps version problems.";
99+ exit(0);
100+ }
101+ else
102+ {
103+ qDebug() << "Ignoring all warnings, continuing without further question.";
104+ conf->setValue("main/ignore_opengl_warning", true);
105+ }
106+ }
107+ }
108+ else
109+ qDebug() << "vs/ps version is fine, we should not see a graphics problem.";
110+ }
111+ else
112+ {
113+ qDebug() << "Cannot parse ANGLE shader version string. This may indicate future problems.";
114+ qDebug() << "Please send a bug report that includes this log file and states if Stellarium runs or has problems.";
115+ }
116+ }
117+#endif
118+
119+
120+
121+ // If GLSL version is less than 1.30 or GLSL ES 1.00, Stellarium cannot run properly. Depending on whatever driver/implementation details,
122+ // Stellarium may crash or show only minor graphical errors. We show a soft-crash panel that can be suppressed by a startup option.
123+ QRegExp glslRegExp("^(\\d\\.\\d\\d)");
124+ int pos=glslRegExp.indexIn(glslString);
125+ QRegExp glslesRegExp("ES (\\d\\.\\d\\d)");
126+ int posES=glslesRegExp.indexIn(glslString);
127+ if (pos >-1)
128+ {
129+ float glslVersion=glslRegExp.cap(1).toFloat();
130+ qDebug() << "GLSL Version Number after parsing: " << glslVersion;
131+ if (glslVersion<1.3)
132+ {
133+ openGLerror=true;
134+ qDebug() << "This is not enough: we need GLSL1.30 or later.";
135+ qDebug() << "You should update graphics drivers, graphics hardware, or use the MESA version.";
136+ qDebug() << "Else, please try to use an older version like 0.12.4, and try there with --safe-mode";
137+
138+ if (conf->value("main/ignore_opengl_warning", false).toBool())
139+ {
140+ qDebug() << "Config option main/ignore_opengl_warning found, continuing. Expect problems.";
141+ }
142+ else
143+ {
144+ qDebug() << "You can try to run in an unsupported degraded mode by ignoring the warning and continuing.";
145+ qDebug() << "But more than likely problems will persist.";
146+ QMessageBox::StandardButton answerButton=
147+ QMessageBox::critical(0, "Stellarium", q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and suppress this notice in the future and try to continue in degraded mode anyway?"),
148+ QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
149+ if (answerButton == QMessageBox::Abort)
150+ {
151+ qDebug() << "Aborting due to OpenGL/GLSL version problems.";
152+ exit(0);
153+ }
154+ else
155+ {
156+ qDebug() << "Ignoring all warnings, continuing without further question.";
157+ conf->setValue("main/ignore_opengl_warning", true);
158+ }
159+ }
160+ }
161+ else
162+ qDebug() << "GLSL version is fine, we should not see a graphics problem.";
163+ }
164+ else if (posES >-1)
165+ {
166+ float glslesVersion=glslesRegExp.cap(1).toFloat();
167+ qDebug() << "GLSL ES Version Number after parsing: " << glslesVersion;
168+ if (glslesVersion<1.0)
169+ {
170+ openGLerror=true;
171+ qDebug() << "This is not enough: we need GLSL ES 1.00 or later.";
172+ qDebug() << "You should update graphics drivers, graphics hardware, or use the OpenGL-MESA version.";
173+ qDebug() << "Else, please try to use an older version like 0.12.4, and try there with --safe-mode";
174+
175+ if (conf->value("main/ignore_opengl_warning", false).toBool())
176+ {
177+ qDebug() << "Config option main/ignore_opengl_warning found, continuing. Expect problems.";
178+ }
179+ else
180+ {
181+ qDebug() << "You can try to run in an unsupported degraded mode by ignoring the warning and continuing.";
182+ qDebug() << "But more than likely problems will persist.";
183+ QMessageBox::StandardButton answerButton=
184+ QMessageBox::critical(0, "Stellarium", q_("Your OpenGL ES subsystem has problems. See log for details.\nIgnore and suppress this notice in the future and try to continue in degraded mode anyway?"),
185+ QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
186+ if (answerButton == QMessageBox::Abort)
187+ {
188+ qDebug() << "Aborting due to OpenGL ES/GLSL ES version problems.";
189+ exit(0);
190+ }
191+ else
192+ {
193+ qDebug() << "Ignoring all warnings, continuing without further question.";
194+ conf->setValue("main/ignore_opengl_warning", true);
195+ }
196+ }
197+ }
198+ else
199+ {
200+ if (openGLerror)
201+ qDebug() << "GLSL ES version is OK, but there were previous errors, expect problems.";
202+ else
203+ qDebug() << "GLSL ES version is fine, we should not see a graphics problem.";
204+ }
205+ }
206+ else
207+ {
208+ qDebug() << "Cannot parse GLSL (ES) version string. This may indicate future problems.";
209+ qDebug() << "Please send a bug report that includes this log file and states if Stellarium works or has problems.";
210+ }
211+
212 stelApp= new StelApp();
213 stelApp->setGui(gui);
214 stelApp->init(conf);
215@@ -406,55 +587,6 @@
216 startMainLoop();
217 }
218
219-QString StelMainView::getSupportedOpenGLVersion() const
220-{
221- int version = QGLFormat::openGLVersionFlags();
222- QStringList ver;
223-
224- if (version&QGLFormat::OpenGL_Version_1_1)
225- ver << "1.1";
226- if (version&QGLFormat::OpenGL_Version_1_2)
227- ver << "1.2";
228- if (version&QGLFormat::OpenGL_Version_1_3)
229- ver << "1.3";
230- if (version&QGLFormat::OpenGL_Version_1_4)
231- ver << "1.4";
232- if (version&QGLFormat::OpenGL_Version_1_5)
233- ver << "1.5";
234- if (version&QGLFormat::OpenGL_Version_2_0)
235- ver << "2.0";
236- if (version&QGLFormat::OpenGL_Version_2_1)
237- ver << "2.1";
238- if (version&QGLFormat::OpenGL_Version_3_0)
239- ver << "3.0";
240- if (version&QGLFormat::OpenGL_Version_3_1)
241- ver << "3.1";
242- if (version&QGLFormat::OpenGL_Version_3_2)
243- ver << "3.2";
244- if (version&QGLFormat::OpenGL_Version_3_3)
245- ver << "3.3";
246- if (version&QGLFormat::OpenGL_Version_4_0)
247- ver << "4.0";
248- if (version&QGLFormat::OpenGL_Version_4_1)
249- ver << "4.1";
250- if (version&QGLFormat::OpenGL_Version_4_2)
251- ver << "4.2";
252- if (version&QGLFormat::OpenGL_Version_4_3)
253- ver << "4.3";
254- if (version&QGLFormat::OpenGL_ES_CommonLite_Version_1_0)
255- ver << "1.0 (ES CL)";
256- if (version&QGLFormat::OpenGL_ES_CommonLite_Version_1_1)
257- ver << "1.1 (ES CL)";
258- if (version&QGLFormat::OpenGL_ES_Common_Version_1_0)
259- ver << "1.0 (ES C)";
260- if (version&QGLFormat::OpenGL_ES_Common_Version_1_1)
261- ver << "1.1 (ES C)";
262- if (version&QGLFormat::OpenGL_ES_Version_2_0)
263- ver << "2.0 (ES)";
264-
265- return ver.join(", ");
266-}
267-
268 void StelMainView::dumpOpenGLdiagnostics() const
269 {
270 // GZ: Debug info about OpenGL capabilities.
271@@ -507,6 +639,8 @@
272 QMapIterator<QString, QString> iter2(extensionMap);
273 while (iter2.hasNext())
274 qDebug() << " -" << iter2.next().key();
275+ // Apparently EXT_gpu_shader4 is required for GLSL1.3. (http://en.wikipedia.org/wiki/OpenGL#OpenGL_3.0).
276+ qDebug() << "EXT_gpu_shader4" << (extensionSet.contains(("EXT_gpu_shader4")) ? "present, OK." : "MISSING!");
277
278 QFunctionPointer programParameterPtr =context->getProcAddress("glProgramParameteri");
279 if (programParameterPtr == 0)
280
281=== modified file 'src/StelMainView.hpp'
282--- src/StelMainView.hpp 2014-11-04 10:59:12 +0000
283+++ src/StelMainView.hpp 2014-11-11 14:09:15 +0000
284@@ -145,7 +145,8 @@
285 //! Start the display loop
286 void startMainLoop();
287
288- QString getSupportedOpenGLVersion() const;
289+ //QString getSupportedOpenGLVersion() const;
290+ //QPair getSupportedOpenGLVersion() const;
291 //! provide extensive OpenGL dignostics in logfile.
292 void dumpOpenGLdiagnostics() const;
293
294
295=== modified file 'src/core/modules/Planet.cpp'
296--- src/core/modules/Planet.cpp 2014-11-08 20:24:59 +0000
297+++ src/core/modules/Planet.cpp 2014-11-11 14:09:15 +0000
298@@ -1271,6 +1271,10 @@
299 {
300 delete planetShaderProgram;
301 planetShaderProgram = NULL;
302+ delete ringPlanetShaderProgram;
303+ ringPlanetShaderProgram = NULL;
304+ delete moonShaderProgram;
305+ moonShaderProgram = NULL;
306 }
307
308 void Planet::draw3dModel(StelCore* core, StelProjector::ModelViewTranformP transfo, float screenSz, bool drawOnlyRing)
309
310=== modified file 'src/main.cpp'
311--- src/main.cpp 2014-09-27 11:37:20 +0000
312+++ src/main.cpp 2014-11-11 14:09:15 +0000
313@@ -43,7 +43,6 @@
314 #include <QFile>
315 #include <QFileInfo>
316 #include <QFontDatabase>
317-#include <QGLFormat>
318 #include <QGuiApplication>
319 #include <QSettings>
320 #include <QSplashScreen>
321@@ -344,55 +343,24 @@
322 app.installTranslator(&trans);
323
324 StelMainView mainWin;
325-
326- bool appCanRun = true;
327- // some basic diagnostics
328- if (!QGLFormat::hasOpenGL()){
329- qWarning() << "Oops... This system does not support OpenGL.";
330- QMessageBox::warning(0, "Stellarium", q_("This system does not support OpenGL."));
331- appCanRun = false;
332- }
333-
334- if (!(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_1) && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0)) // Check supported version of OpenGL
335- {
336- // OK, minimal required version of OpenGL is 2.1 and OpenGL Shading Language is 1.20 (or OpenGL ES is 2.0 and GLSL ES is 2.0).
337- // Recommended OpenGL 3.0 and OpenGL Shading Language 1.30 and above.
338- // If platform does not support this version then say to user about troubles and quit from application.
339- #ifdef Q_OS_WIN
340- qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, graphics hardware, or use MESA (or ANGLE) version.";
341- QMessageBox::warning(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, graphics hardware, or use MESA (or ANGLE) version."));
342- #else
343- qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, or graphics hardware.";
344- QMessageBox::warning(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, or graphics hardware."));
345- #endif
346- appCanRun = false;
347- }
348-
349- if (appCanRun)
350- {
351- mainWin.init(confSettings);
352- splash.finish(&mainWin);
353- app.exec();
354- mainWin.deinit();
355-
356- delete confSettings;
357- StelLogger::deinit();
358-
359- #ifdef Q_OS_WIN
360- if(timerGrain)
361- timeEndPeriod(timerGrain);
362- #endif //Q_OS_WIN
363- #ifdef Q_OS_MAC
364- delete(newArgv);
365- delete(option);
366- delete(value);
367- #endif
368-
369- return 0;
370- }
371- else
372- {
373- app.quit();
374- }
375+ mainWin.init(confSettings); // May exit(0) when OpenGL subsystem insufficient
376+ splash.finish(&mainWin);
377+ app.exec();
378+ mainWin.deinit();
379+
380+ delete confSettings;
381+ StelLogger::deinit();
382+
383+ #ifdef Q_OS_WIN
384+ if(timerGrain)
385+ timeEndPeriod(timerGrain);
386+ #endif //Q_OS_WIN
387+ #ifdef Q_OS_MAC
388+ delete(newArgv);
389+ delete(option);
390+ delete(value);
391+ #endif
392+
393+ return 0;
394 }
395