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
=== modified file 'src/CLIProcessor.cpp'
--- src/CLIProcessor.cpp 2014-06-12 13:47:38 +0000
+++ src/CLIProcessor.cpp 2014-09-12 11:42:18 +0000
@@ -54,7 +54,8 @@
54 << "--config-file (or -c) : Use an alternative name for the config file\n"54 << "--config-file (or -c) : Use an alternative name for the config file\n"
55 << "--user-dir (or -u) : Use an alternative user data directory\n"55 << "--user-dir (or -u) : Use an alternative user data directory\n"
56 //<< "--safe-mode (or -s) : Disable GL shaders and use older GL engine\n"56 //<< "--safe-mode (or -s) : Disable GL shaders and use older GL engine\n"
57 //<< " Try this is you have graphics problems\n"57 << "--dump-opengl-details (or -d) : dump information about OpenGL support to logfile\n"
58 << " Try this is you have graphics problems\n"
58 << "--full-screen (or -f) : With argument \"yes\" or \"no\" over-rides\n"59 << "--full-screen (or -f) : With argument \"yes\" or \"no\" over-rides\n"
59 << " the full screen setting in the config file\n"60 << " the full screen setting in the config file\n"
60 << "--screenshot-dir : Specify directory to save screenshots\n"61 << "--screenshot-dir : Specify directory to save screenshots\n"
@@ -120,6 +121,8 @@
120 QString projectionType, screenshotDir, multiresImage, startupScript;121 QString projectionType, screenshotDir, multiresImage, startupScript;
121 try122 try
122 {123 {
124 bool dumpOpenGLDetails = argsGetOption(argList, "-d", "--dump-opengl-details");
125 qApp->setProperty("dump_OpenGL_details", dumpOpenGLDetails);
123 fullScreen = argsGetYesNoOption(argList, "-f", "--full-screen", -1);126 fullScreen = argsGetYesNoOption(argList, "-f", "--full-screen", -1);
124 landscapeId = argsGetOptionWithArg(argList, "", "--landscape", "").toString();127 landscapeId = argsGetOptionWithArg(argList, "", "--landscape", "").toString();
125 homePlanet = argsGetOptionWithArg(argList, "", "--home-planet", "").toString();128 homePlanet = argsGetOptionWithArg(argList, "", "--home-planet", "").toString();
126129
=== modified file 'src/StelMainView.cpp'
--- src/StelMainView.cpp 2014-08-25 06:42:05 +0000
+++ src/StelMainView.cpp 2014-09-12 11:42:18 +0000
@@ -48,6 +48,8 @@
48#include <QWindow>48#include <QWindow>
49#include <QDeclarativeContext>49#include <QDeclarativeContext>
50#include <QPinchGesture>50#include <QPinchGesture>
51#include <QOpenGLShader>
52#include <QOpenGLShaderProgram>
5153
52#include <clocale>54#include <clocale>
5355
@@ -71,7 +73,7 @@
71private:73private:
72 double previousPaintTime;74 double previousPaintTime;
73 void onSizeChanged();75 void onSizeChanged();
74 void pinchTriggered(QPinchGesture *gesture);76 void pinchTriggered(QPinchGesture *gesture);
75 bool gestureEvent(QGestureEvent *event);77 bool gestureEvent(QGestureEvent *event);
76};78};
7779
@@ -91,7 +93,7 @@
91 setObjectName("SkyItem");93 setObjectName("SkyItem");
92 setFlag(QGraphicsItem::ItemHasNoContents, false);94 setFlag(QGraphicsItem::ItemHasNoContents, false);
93 setAcceptHoverEvents(true);95 setAcceptHoverEvents(true);
94 setAcceptTouchEvents(true);96 setAcceptTouchEvents(true);
95 grabGesture(Qt::PinchGesture);97 grabGesture(Qt::PinchGesture);
96 setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton);98 setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton);
97 connect(this, &StelSkyItem::widthChanged, this, &StelSkyItem::onSizeChanged);99 connect(this, &StelSkyItem::widthChanged, this, &StelSkyItem::onSizeChanged);
@@ -165,51 +167,51 @@
165 StelApp::getInstance().handleWheel(&newEvent);167 StelApp::getInstance().handleWheel(&newEvent);
166}168}
167169
168bool StelSkyItem::event(QEvent * e)170bool StelSkyItem::event(QEvent * e)
169{171{
170 switch (e->type()){172 switch (e->type()){
171 case QEvent::TouchBegin:173 case QEvent::TouchBegin:
172 case QEvent::TouchUpdate:174 case QEvent::TouchUpdate:
173 case QEvent::TouchEnd:175 case QEvent::TouchEnd:
174 {176 {
175 QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);177 QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
176 QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();178 QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
177179
178 if (touchPoints.count() == 1)180 if (touchPoints.count() == 1)
179 setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton);181 setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton);
180182
181 return true;183 return true;
182 }184 }
183 break;185 break;
184186
185 case QEvent::Gesture:187 case QEvent::Gesture:
186 setAcceptedMouseButtons(0);188 setAcceptedMouseButtons(0);
187 return gestureEvent(static_cast<QGestureEvent*>(e));189 return gestureEvent(static_cast<QGestureEvent*>(e));
188 break;190 break;
189191
190 default:192 default:
191 return false;193 return false;
192 }194 }
193}195}
194196
195bool StelSkyItem::gestureEvent(QGestureEvent *event)197bool StelSkyItem::gestureEvent(QGestureEvent *event)
196{198{
197 if (QGesture *pinch = event->gesture(Qt::PinchGesture))199 if (QGesture *pinch = event->gesture(Qt::PinchGesture))
198 pinchTriggered(static_cast<QPinchGesture *>(pinch));200 pinchTriggered(static_cast<QPinchGesture *>(pinch));
199201
200 return true;202 return true;
201}203}
202204
203void StelSkyItem::pinchTriggered(QPinchGesture *gesture)205void StelSkyItem::pinchTriggered(QPinchGesture *gesture)
204{206{
205 QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags();207 QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags();
206 if (changeFlags & QPinchGesture::ScaleFactorChanged) {208 if (changeFlags & QPinchGesture::ScaleFactorChanged) {
207 qreal zoom = gesture->scaleFactor();209 qreal zoom = gesture->scaleFactor();
208210
209 if (zoom < 2 && zoom > 0.5){211 if (zoom < 2 && zoom > 0.5){
210 StelApp::getInstance().handlePinch(zoom, true);212 StelApp::getInstance().handlePinch(zoom, true);
211 }213 }
212 }214 }
213}215}
214216
215void StelSkyItem::keyPressEvent(QKeyEvent* event)217void StelSkyItem::keyPressEvent(QKeyEvent* event)
@@ -347,6 +349,10 @@
347 qDebug() << "GL renderer is" << QString(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));349 qDebug() << "GL renderer is" << QString(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
348 qDebug() << "GL Shading Language version is" << QString(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));350 qDebug() << "GL Shading Language version is" << QString(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
349 351
352 // Only give extended info if called on command line, for diagnostic.
353 if (qApp->property("dump_OpenGL_details").toBool())
354 dumpOpenGLdiagnostics();
355
350 stelApp= new StelApp();356 stelApp= new StelApp();
351 stelApp->setGui(gui);357 stelApp->setGui(gui);
352 stelApp->init(conf);358 stelApp->init(conf);
@@ -354,7 +360,6 @@
354 actionMgr->addAction("actionSave_Screenshot_Global", N_("Miscellaneous"), N_("Save screenshot"), this, "saveScreenShot()", "Ctrl+S");360 actionMgr->addAction("actionSave_Screenshot_Global", N_("Miscellaneous"), N_("Save screenshot"), this, "saveScreenShot()", "Ctrl+S");
355 actionMgr->addAction("actionSet_Full_Screen_Global", N_("Display Options"), N_("Full-screen mode"), this, "fullScreen", "F11");361 actionMgr->addAction("actionSet_Full_Screen_Global", N_("Display Options"), N_("Full-screen mode"), this, "fullScreen", "F11");
356 362
357
358 StelPainter::initGLShaders();363 StelPainter::initGLShaders();
359364
360 setResizeMode(QDeclarativeView::SizeRootObjectToView);365 setResizeMode(QDeclarativeView::SizeRootObjectToView);
@@ -448,6 +453,72 @@
448 return ver.join(", ");453 return ver.join(", ");
449}454}
450455
456void StelMainView::dumpOpenGLdiagnostics() const
457{
458 // GZ: Debug info about OpenGL capabilities.
459 QOpenGLContext *context = QOpenGLContext::currentContext();
460 if (context)
461 {
462 context->functions()->initializeOpenGLFunctions();
463 qDebug() << "initializeOpenGLFunctions()...";
464 }
465 else
466 qDebug() << "No OpenGL context";
467
468 QOpenGLFunctions::OpenGLFeatures oglFeatures=context->functions()->openGLFeatures();
469 qDebug() << "OpenGL Features:";
470 qDebug() << " - glActiveTexture() function is" << (oglFeatures&QOpenGLFunctions::Multitexture ? "" : "NOT") << "available.";
471 qDebug() << " - Shader functions are" << (oglFeatures&QOpenGLFunctions::Shaders ? "" : "NOT ") << "available.";
472 qDebug() << " - Vertex and index buffer functions are" << (oglFeatures&QOpenGLFunctions::Buffers ? "" : "NOT") << "available.";
473 qDebug() << " - Framebuffer object functions are" << (oglFeatures&QOpenGLFunctions::Framebuffers ? "" : "NOT") << "available.";
474 qDebug() << " - glBlendColor() is" << (oglFeatures&QOpenGLFunctions::BlendColor ? "" : "NOT") << "available.";
475 qDebug() << " - glBlendEquation() is" << (oglFeatures&QOpenGLFunctions::BlendEquation ? "" : "NOT") << "available.";
476 qDebug() << " - glBlendEquationSeparate() is" << (oglFeatures&QOpenGLFunctions::BlendEquationSeparate ? "" : "NOT") << "available.";
477 qDebug() << " - glBlendFuncSeparate() is" << (oglFeatures&QOpenGLFunctions::BlendFuncSeparate ? "" : "NOT") << "available.";
478 qDebug() << " - Blend subtract mode is" << (oglFeatures&QOpenGLFunctions::BlendSubtract ? "" : "NOT") << "available.";
479 qDebug() << " - Compressed texture functions are" << (oglFeatures&QOpenGLFunctions::CompressedTextures ? "" : "NOT") << "available.";
480 qDebug() << " - glSampleCoverage() function is" << (oglFeatures&QOpenGLFunctions::Multisample ? "" : "NOT") << "available.";
481 qDebug() << " - Separate stencil functions are" << (oglFeatures&QOpenGLFunctions::StencilSeparate ? "" : "NOT") << "available.";
482 qDebug() << " - Non power of two textures are" << (oglFeatures&QOpenGLFunctions::NPOTTextures ? "" : "NOT") << "available.";
483 qDebug() << " - Non power of two textures can" << (oglFeatures&QOpenGLFunctions::NPOTTextureRepeat ? "" : "NOT") << "use GL_REPEAT as wrap parameter.";
484 qDebug() << " - The fixed function pipeline is" << (oglFeatures&QOpenGLFunctions::FixedFunctionPipeline ? "" : "NOT") << "available.";
485
486 qDebug() << "OpenGL shader capabilities and details:";
487 qDebug() << " - Vertex Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::Vertex, context) ? "YES" : "NO");
488 qDebug() << " - Fragment Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::Fragment, context) ? "YES" : "NO");
489 qDebug() << " - Geometry Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::Geometry, context) ? "YES" : "NO");
490 qDebug() << " - TessellationControl Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::TessellationControl, context) ? "YES" : "NO");
491 qDebug() << " - TessellationEvaluation Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::TessellationEvaluation, context) ? "YES" : "NO");
492 qDebug() << " - Compute Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::Compute, context) ? "YES" : "NO");
493
494 // GZ: List available extensions. Not sure if this is in any way useful?
495 QSet<QByteArray> extensionSet=context->extensions();
496 qDebug() << "We have" << extensionSet.count() << "OpenGL extensions:";
497 QMap<QString, QString> extensionMap;
498 QSetIterator<QByteArray> iter(extensionSet);
499 while (iter.hasNext())
500 {
501 extensionMap.insert(QString(iter.peekNext()), QString(iter.peekNext()));
502 iter.next();
503 }
504 QMapIterator<QString, QString> iter2(extensionMap);
505 while (iter2.hasNext())
506 qDebug() << " - " << iter2.next().key();
507
508 QFunctionPointer programParameterPtr =context->getProcAddress("glProgramParameteri");
509 if (programParameterPtr == 0)
510 qDebug() << "glProgramParameteri cannot be resolved here. BAD!";
511 //else
512 // qDebug() << "glProgramParameteri can be resolved. GOOD!";
513 programParameterPtr =context->getProcAddress("glProgramParameteriEXT");
514 if (programParameterPtr == 0)
515 qDebug() << "glProgramParameteriEXT cannot be resolved here. BAD!";
516 //else
517 // qDebug() << "glProgramParameteriEXT can be resolved here. GOOD!";
518
519}
520
521
451void StelMainView::deinit()522void StelMainView::deinit()
452{523{
453 deinitGL();524 deinitGL();
454525
=== modified file 'src/StelMainView.hpp'
--- src/StelMainView.hpp 2014-06-09 01:02:28 +0000
+++ src/StelMainView.hpp 2014-09-12 11:42:18 +0000
@@ -25,6 +25,7 @@
25#include <QDeclarativeView>25#include <QDeclarativeView>
26#include <QCoreApplication>26#include <QCoreApplication>
27#include <QEventLoop>27#include <QEventLoop>
28#include <QOpenGLContext>
2829
29class QDeclarativeItem;30class QDeclarativeItem;
30class QGLWidget;31class QGLWidget;
@@ -147,6 +148,8 @@
147 void startMainLoop();148 void startMainLoop();
148 149
149 QString getSupportedOpenGLVersion() const;150 QString getSupportedOpenGLVersion() const;
151 //! provide extensive OpenGL dignostics in logfile.
152 void dumpOpenGLdiagnostics() const;
150153
151 //! The StelMainView singleton154 //! The StelMainView singleton
152 static StelMainView* singleton;155 static StelMainView* singleton;
153156
=== modified file 'src/core/StelOpenGL.hpp'
--- src/core/StelOpenGL.hpp 2014-07-02 16:31:14 +0000
+++ src/core/StelOpenGL.hpp 2014-09-12 11:42:18 +0000
@@ -98,6 +98,8 @@
98#define glIsRenderbuffer(...) GLFUNC_(glIsRenderbuffer(__VA_ARGS__))98#define glIsRenderbuffer(...) GLFUNC_(glIsRenderbuffer(__VA_ARGS__))
99#define glIsShader(...) GLFUNC_(glIsShader(__VA_ARGS__))99#define glIsShader(...) GLFUNC_(glIsShader(__VA_ARGS__))
100#define glLinkProgram(...) GLFUNC_(glLinkProgram(__VA_ARGS__))100#define glLinkProgram(...) GLFUNC_(glLinkProgram(__VA_ARGS__))
101#define glProgramParameteri(...) GLFUNC_(glProgramParameteri(__VA_ARGS__)) // GZ TRIAL
102#define glProgramParameteriEXT(...) GLFUNC_(glProgramParameteriEXT(__VA_ARGS__)) // GZ TRIAL
101#define glReleaseShaderCompiler(...) GLFUNC_(glReleaseShaderCompiler(__VA_ARGS__))103#define glReleaseShaderCompiler(...) GLFUNC_(glReleaseShaderCompiler(__VA_ARGS__))
102#define glRenderbufferStorage(...) GLFUNC_(glRenderbufferStorage(__VA_ARGS__))104#define glRenderbufferStorage(...) GLFUNC_(glRenderbufferStorage(__VA_ARGS__))
103#define glSampleCoverage(...) GLFUNC_(glSampleCoverage(__VA_ARGS__))105#define glSampleCoverage(...) GLFUNC_(glSampleCoverage(__VA_ARGS__))