Merge lp:~stellarium/stellarium/gz-opengl-init into lp:stellarium

Proposed by gzotti
Status: Merged
Merged at revision: 7042
Proposed branch: lp:~stellarium/stellarium/gz-opengl-init
Merge into: lp:stellarium
Diff against target: 276 lines (+128/-49)
4 files modified
src/CLIProcessor.cpp (+4/-1)
src/StelMainView.cpp (+119/-48)
src/StelMainView.hpp (+3/-0)
src/core/StelOpenGL.hpp (+2/-0)
To merge this branch: bzr merge lp:~stellarium/stellarium/gz-opengl-init
Reviewer Review Type Date Requested Status
Alexander Wolf Approve
gzotti Needs Resubmitting
Fabien Chéreau Needs Fixing
Review via email: mp+234455@code.launchpad.net

Commit message

Added optional more startup diagnostics for tracking down OpenGL-related issues.

To post a comment you must log in.
Revision history for this message
Alexander Wolf (alexwolf) wrote :

I think CLI option should be --dump-opengl-details instead --opengldetails

6949. By gzotti

typofix, bad function name.

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

Hm... Maybe it should be short --debug?

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

Please fix whitespaces

review: Needs Fixing
6950. By gzotti

renamed command-line option

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

We may consider a more global --debug option, this could give OpenGL and other extended messages. I saw this qApp->property() trick to check...

@ Fabien: sorry, I don't see which? Or do you mean those double-spaces that are formed from assembling the strings? If this is an issue, how do I elegantly prevent "NOT" becoming " NOT " in the "<<" concatenation?

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

@ Fabien sorry, I just saw the detailed comments in the mail. I did not touch that, must have happened during merge.

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

No I mean the chnages in bool StelSkyItem::event(QEvent * e) ....
There is no visible changes here, so it must be line ending or white spaces..

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

@ Fabien: I can only guess it's the usual Linux/Windows line-ending thing where BZR (or QtCreator?) apparently injects a CRLF on (my) Windows and diff marks those lines changed. These lines are new functions that came in during latest merge with trunk.

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

OK, then the culprit is in the other patch..

On Fri, Sep 12, 2014 at 2:04 PM, gzotti <email address hidden> wrote:

> @ Fabien: I can only guess it's the usual Linux/Windows line-ending thing
> where BZR (or QtCreator?) apparently injects a CRLF on (my) Windows and
> diff marks those lines changed. These lines are new functions that came in
> during latest merge with trunk.
> --
>
> https://code.launchpad.net/~stellarium/stellarium/gz-opengl-init/+merge/234455
> You are reviewing the proposed merge of
> lp:~stellarium/stellarium/gz-opengl-init into lp:stellarium.
>

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

Any other objections, then?

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

It's OK for me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CLIProcessor.cpp'
2--- src/CLIProcessor.cpp 2014-06-12 13:47:38 +0000
3+++ src/CLIProcessor.cpp 2014-09-12 11:42:18 +0000
4@@ -54,7 +54,8 @@
5 << "--config-file (or -c) : Use an alternative name for the config file\n"
6 << "--user-dir (or -u) : Use an alternative user data directory\n"
7 //<< "--safe-mode (or -s) : Disable GL shaders and use older GL engine\n"
8- //<< " Try this is you have graphics problems\n"
9+ << "--dump-opengl-details (or -d) : dump information about OpenGL support to logfile\n"
10+ << " Try this is you have graphics problems\n"
11 << "--full-screen (or -f) : With argument \"yes\" or \"no\" over-rides\n"
12 << " the full screen setting in the config file\n"
13 << "--screenshot-dir : Specify directory to save screenshots\n"
14@@ -120,6 +121,8 @@
15 QString projectionType, screenshotDir, multiresImage, startupScript;
16 try
17 {
18+ bool dumpOpenGLDetails = argsGetOption(argList, "-d", "--dump-opengl-details");
19+ qApp->setProperty("dump_OpenGL_details", dumpOpenGLDetails);
20 fullScreen = argsGetYesNoOption(argList, "-f", "--full-screen", -1);
21 landscapeId = argsGetOptionWithArg(argList, "", "--landscape", "").toString();
22 homePlanet = argsGetOptionWithArg(argList, "", "--home-planet", "").toString();
23
24=== modified file 'src/StelMainView.cpp'
25--- src/StelMainView.cpp 2014-08-25 06:42:05 +0000
26+++ src/StelMainView.cpp 2014-09-12 11:42:18 +0000
27@@ -48,6 +48,8 @@
28 #include <QWindow>
29 #include <QDeclarativeContext>
30 #include <QPinchGesture>
31+#include <QOpenGLShader>
32+#include <QOpenGLShaderProgram>
33
34 #include <clocale>
35
36@@ -71,7 +73,7 @@
37 private:
38 double previousPaintTime;
39 void onSizeChanged();
40- void pinchTriggered(QPinchGesture *gesture);
41+ void pinchTriggered(QPinchGesture *gesture);
42 bool gestureEvent(QGestureEvent *event);
43 };
44
45@@ -91,7 +93,7 @@
46 setObjectName("SkyItem");
47 setFlag(QGraphicsItem::ItemHasNoContents, false);
48 setAcceptHoverEvents(true);
49- setAcceptTouchEvents(true);
50+ setAcceptTouchEvents(true);
51 grabGesture(Qt::PinchGesture);
52 setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton);
53 connect(this, &StelSkyItem::widthChanged, this, &StelSkyItem::onSizeChanged);
54@@ -165,51 +167,51 @@
55 StelApp::getInstance().handleWheel(&newEvent);
56 }
57
58-bool StelSkyItem::event(QEvent * e)
59-{
60- switch (e->type()){
61- case QEvent::TouchBegin:
62- case QEvent::TouchUpdate:
63- case QEvent::TouchEnd:
64- {
65- QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
66- QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
67-
68- if (touchPoints.count() == 1)
69- setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton);
70-
71- return true;
72- }
73- break;
74-
75- case QEvent::Gesture:
76- setAcceptedMouseButtons(0);
77- return gestureEvent(static_cast<QGestureEvent*>(e));
78- break;
79-
80- default:
81- return false;
82- }
83-}
84-
85-bool StelSkyItem::gestureEvent(QGestureEvent *event)
86-{
87- if (QGesture *pinch = event->gesture(Qt::PinchGesture))
88- pinchTriggered(static_cast<QPinchGesture *>(pinch));
89-
90- return true;
91-}
92-
93-void StelSkyItem::pinchTriggered(QPinchGesture *gesture)
94-{
95- QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags();
96- if (changeFlags & QPinchGesture::ScaleFactorChanged) {
97- qreal zoom = gesture->scaleFactor();
98-
99- if (zoom < 2 && zoom > 0.5){
100- StelApp::getInstance().handlePinch(zoom, true);
101- }
102- }
103+bool StelSkyItem::event(QEvent * e)
104+{
105+ switch (e->type()){
106+ case QEvent::TouchBegin:
107+ case QEvent::TouchUpdate:
108+ case QEvent::TouchEnd:
109+ {
110+ QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
111+ QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
112+
113+ if (touchPoints.count() == 1)
114+ setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton);
115+
116+ return true;
117+ }
118+ break;
119+
120+ case QEvent::Gesture:
121+ setAcceptedMouseButtons(0);
122+ return gestureEvent(static_cast<QGestureEvent*>(e));
123+ break;
124+
125+ default:
126+ return false;
127+ }
128+}
129+
130+bool StelSkyItem::gestureEvent(QGestureEvent *event)
131+{
132+ if (QGesture *pinch = event->gesture(Qt::PinchGesture))
133+ pinchTriggered(static_cast<QPinchGesture *>(pinch));
134+
135+ return true;
136+}
137+
138+void StelSkyItem::pinchTriggered(QPinchGesture *gesture)
139+{
140+ QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags();
141+ if (changeFlags & QPinchGesture::ScaleFactorChanged) {
142+ qreal zoom = gesture->scaleFactor();
143+
144+ if (zoom < 2 && zoom > 0.5){
145+ StelApp::getInstance().handlePinch(zoom, true);
146+ }
147+ }
148 }
149
150 void StelSkyItem::keyPressEvent(QKeyEvent* event)
151@@ -347,6 +349,10 @@
152 qDebug() << "GL renderer is" << QString(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
153 qDebug() << "GL Shading Language version is" << QString(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
154
155+ // Only give extended info if called on command line, for diagnostic.
156+ if (qApp->property("dump_OpenGL_details").toBool())
157+ dumpOpenGLdiagnostics();
158+
159 stelApp= new StelApp();
160 stelApp->setGui(gui);
161 stelApp->init(conf);
162@@ -354,7 +360,6 @@
163 actionMgr->addAction("actionSave_Screenshot_Global", N_("Miscellaneous"), N_("Save screenshot"), this, "saveScreenShot()", "Ctrl+S");
164 actionMgr->addAction("actionSet_Full_Screen_Global", N_("Display Options"), N_("Full-screen mode"), this, "fullScreen", "F11");
165
166-
167 StelPainter::initGLShaders();
168
169 setResizeMode(QDeclarativeView::SizeRootObjectToView);
170@@ -448,6 +453,72 @@
171 return ver.join(", ");
172 }
173
174+void StelMainView::dumpOpenGLdiagnostics() const
175+{
176+ // GZ: Debug info about OpenGL capabilities.
177+ QOpenGLContext *context = QOpenGLContext::currentContext();
178+ if (context)
179+ {
180+ context->functions()->initializeOpenGLFunctions();
181+ qDebug() << "initializeOpenGLFunctions()...";
182+ }
183+ else
184+ qDebug() << "No OpenGL context";
185+
186+ QOpenGLFunctions::OpenGLFeatures oglFeatures=context->functions()->openGLFeatures();
187+ qDebug() << "OpenGL Features:";
188+ qDebug() << " - glActiveTexture() function is" << (oglFeatures&QOpenGLFunctions::Multitexture ? "" : "NOT") << "available.";
189+ qDebug() << " - Shader functions are" << (oglFeatures&QOpenGLFunctions::Shaders ? "" : "NOT ") << "available.";
190+ qDebug() << " - Vertex and index buffer functions are" << (oglFeatures&QOpenGLFunctions::Buffers ? "" : "NOT") << "available.";
191+ qDebug() << " - Framebuffer object functions are" << (oglFeatures&QOpenGLFunctions::Framebuffers ? "" : "NOT") << "available.";
192+ qDebug() << " - glBlendColor() is" << (oglFeatures&QOpenGLFunctions::BlendColor ? "" : "NOT") << "available.";
193+ qDebug() << " - glBlendEquation() is" << (oglFeatures&QOpenGLFunctions::BlendEquation ? "" : "NOT") << "available.";
194+ qDebug() << " - glBlendEquationSeparate() is" << (oglFeatures&QOpenGLFunctions::BlendEquationSeparate ? "" : "NOT") << "available.";
195+ qDebug() << " - glBlendFuncSeparate() is" << (oglFeatures&QOpenGLFunctions::BlendFuncSeparate ? "" : "NOT") << "available.";
196+ qDebug() << " - Blend subtract mode is" << (oglFeatures&QOpenGLFunctions::BlendSubtract ? "" : "NOT") << "available.";
197+ qDebug() << " - Compressed texture functions are" << (oglFeatures&QOpenGLFunctions::CompressedTextures ? "" : "NOT") << "available.";
198+ qDebug() << " - glSampleCoverage() function is" << (oglFeatures&QOpenGLFunctions::Multisample ? "" : "NOT") << "available.";
199+ qDebug() << " - Separate stencil functions are" << (oglFeatures&QOpenGLFunctions::StencilSeparate ? "" : "NOT") << "available.";
200+ qDebug() << " - Non power of two textures are" << (oglFeatures&QOpenGLFunctions::NPOTTextures ? "" : "NOT") << "available.";
201+ qDebug() << " - Non power of two textures can" << (oglFeatures&QOpenGLFunctions::NPOTTextureRepeat ? "" : "NOT") << "use GL_REPEAT as wrap parameter.";
202+ qDebug() << " - The fixed function pipeline is" << (oglFeatures&QOpenGLFunctions::FixedFunctionPipeline ? "" : "NOT") << "available.";
203+
204+ qDebug() << "OpenGL shader capabilities and details:";
205+ qDebug() << " - Vertex Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::Vertex, context) ? "YES" : "NO");
206+ qDebug() << " - Fragment Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::Fragment, context) ? "YES" : "NO");
207+ qDebug() << " - Geometry Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::Geometry, context) ? "YES" : "NO");
208+ qDebug() << " - TessellationControl Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::TessellationControl, context) ? "YES" : "NO");
209+ qDebug() << " - TessellationEvaluation Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::TessellationEvaluation, context) ? "YES" : "NO");
210+ qDebug() << " - Compute Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::Compute, context) ? "YES" : "NO");
211+
212+ // GZ: List available extensions. Not sure if this is in any way useful?
213+ QSet<QByteArray> extensionSet=context->extensions();
214+ qDebug() << "We have" << extensionSet.count() << "OpenGL extensions:";
215+ QMap<QString, QString> extensionMap;
216+ QSetIterator<QByteArray> iter(extensionSet);
217+ while (iter.hasNext())
218+ {
219+ extensionMap.insert(QString(iter.peekNext()), QString(iter.peekNext()));
220+ iter.next();
221+ }
222+ QMapIterator<QString, QString> iter2(extensionMap);
223+ while (iter2.hasNext())
224+ qDebug() << " - " << iter2.next().key();
225+
226+ QFunctionPointer programParameterPtr =context->getProcAddress("glProgramParameteri");
227+ if (programParameterPtr == 0)
228+ qDebug() << "glProgramParameteri cannot be resolved here. BAD!";
229+ //else
230+ // qDebug() << "glProgramParameteri can be resolved. GOOD!";
231+ programParameterPtr =context->getProcAddress("glProgramParameteriEXT");
232+ if (programParameterPtr == 0)
233+ qDebug() << "glProgramParameteriEXT cannot be resolved here. BAD!";
234+ //else
235+ // qDebug() << "glProgramParameteriEXT can be resolved here. GOOD!";
236+
237+}
238+
239+
240 void StelMainView::deinit()
241 {
242 deinitGL();
243
244=== modified file 'src/StelMainView.hpp'
245--- src/StelMainView.hpp 2014-06-09 01:02:28 +0000
246+++ src/StelMainView.hpp 2014-09-12 11:42:18 +0000
247@@ -25,6 +25,7 @@
248 #include <QDeclarativeView>
249 #include <QCoreApplication>
250 #include <QEventLoop>
251+#include <QOpenGLContext>
252
253 class QDeclarativeItem;
254 class QGLWidget;
255@@ -147,6 +148,8 @@
256 void startMainLoop();
257
258 QString getSupportedOpenGLVersion() const;
259+ //! provide extensive OpenGL dignostics in logfile.
260+ void dumpOpenGLdiagnostics() const;
261
262 //! The StelMainView singleton
263 static StelMainView* singleton;
264
265=== modified file 'src/core/StelOpenGL.hpp'
266--- src/core/StelOpenGL.hpp 2014-07-02 16:31:14 +0000
267+++ src/core/StelOpenGL.hpp 2014-09-12 11:42:18 +0000
268@@ -98,6 +98,8 @@
269 #define glIsRenderbuffer(...) GLFUNC_(glIsRenderbuffer(__VA_ARGS__))
270 #define glIsShader(...) GLFUNC_(glIsShader(__VA_ARGS__))
271 #define glLinkProgram(...) GLFUNC_(glLinkProgram(__VA_ARGS__))
272+#define glProgramParameteri(...) GLFUNC_(glProgramParameteri(__VA_ARGS__)) // GZ TRIAL
273+#define glProgramParameteriEXT(...) GLFUNC_(glProgramParameteriEXT(__VA_ARGS__)) // GZ TRIAL
274 #define glReleaseShaderCompiler(...) GLFUNC_(glReleaseShaderCompiler(__VA_ARGS__))
275 #define glRenderbufferStorage(...) GLFUNC_(glRenderbufferStorage(__VA_ARGS__))
276 #define glSampleCoverage(...) GLFUNC_(glSampleCoverage(__VA_ARGS__))