display: change default OpenGL version for Qt gui
authorJinhyung Jo <jinhyung.jo@samsung.com>
Tue, 25 Oct 2016 02:56:30 +0000 (11:56 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Fri, 2 Dec 2016 08:31:06 +0000 (17:31 +0900)
There are 2 issues:
With some Radeon GPU,
the Qt5 library makes runtime errors infinitely with glCreateShader
like below in Qt5 internal implementations:
'Implicit version number 110 not supported by GL3 forward compatible context'
The issue that VIGS uses OpenGL version 2,
    : starts with the force legacy option(gl_version=2).
    : User's GPU driver does not support OpenGL version 3.2.

In order to avoid these problems, use the OpenGL 3.2 Core Profile
instead of the OpenGL 3.1 to create shared context.
And after creating the shared context, reset to OpenGL versio 2.1.

Change-Id: I2d67580827b1eda53478adccf774d9ab1342b42a
Signed-off-by: Jinhyung Jo <jinhyung.jo@samsung.com>
tizen/src/ui/displayglwidget.cpp
tizen/src/ui/qt5.c
tizen/src/ui/qt5_supplement.cpp

index 6ccb3eb..0a9d06d 100644 (file)
@@ -341,7 +341,9 @@ void DisplayGLWidget::drawMultiTouchPoints()
 /* override */
 void DisplayGLWidget::initializeGL()
 {
-    qDebug("initialize GL");
+    qDebug("initialize GL: OpenGL %d.%d(Profile: %d)",
+           format().majorVersion(), format().minorVersion(),
+           format().profile());
 
     mFuncs = QOpenGLContext::currentContext()->functions();
 
index 0b19be6..ee84ff5 100644 (file)
@@ -141,7 +141,7 @@ void maru_early_qt5_display_init(bool isOnscreen)
     char *icon_path = g_malloc0(sizeof(char) * path_len);
     snprintf(icon_path, path_len, "%s%s%s",
         get_bin_path(), SDK_EMULATOR_ICONS_PATH, EMULATOR_ICON_FILE);
-    fprintf(stdout, "application icon path: %s\n", icon_path);
+    LOG_TRACE("application icon path: %s\n", icon_path);
 
     set_application_icon(icon_path);
     g_free(icon_path);
index 83e8355..4ae6a2b 100644 (file)
@@ -227,13 +227,6 @@ const char *qt5_get_version(void)
 
 static void qt5_gui_init(void)
 {
-    QCoreApplication::setApplicationName(EMULATOR_TITLE);
-
-    qInfo() << "* Qt version (compile time):" << QT_VERSION_STR;
-    qInfo() << "* Qt version (runtime):" << qVersion();
-    qInfo() << "* working path:" << QDir::currentPath();
-    qInfo() << "* binary path:" << QCoreApplication::applicationDirPath();
-
     uiInfo = new UiInformation();
 
     /* parameter parsing */
@@ -464,37 +457,66 @@ void qt5_early_prepare(bool isOnscreen)
         sfcFormat.setAlphaBufferSize(8);
         sfcFormat.setDepthBufferSize(24);
         sfcFormat.setStencilBufferSize(8);
-#ifdef CONFIG_DARWIN
-        // The default OpenGL version for QSurfaceFormat is 2.0.
-        if (!isForceLegacy) {
+
+        if (isForceLegacy) {
+            sfcFormat.setMajorVersion(2);
+            sfcFormat.setMinorVersion(1);
+        } else {
             sfcFormat.setMajorVersion(3);
             sfcFormat.setMinorVersion(2);
             sfcFormat.setProfile(QSurfaceFormat::CoreProfile);
         }
-#else
-        sfcFormat.setMajorVersion(3);
-        sfcFormat.setMinorVersion(1);
-#endif
         QSurfaceFormat::setDefaultFormat(sfcFormat);
     }
 
     qt5App = new QApplication(argc, argv);
 
-    /* add the path in the application's main() function, right after the
-     * QApplication object is created */
-    qt5App->addLibraryPath(QDir::currentPath()); //TODO: consider a symbolic link
+    // add the path in the application's main() function,
+    // right after the QApplication object is created.
+    // TODO: consider a symbolic link
+    qt5App->addLibraryPath(QDir::currentPath());
 
     qInstallMessageHandler(qMessageOutput);
-
-    qDebug() << "* Qt plugin library path:" << QCoreApplication::libraryPaths();
-
 #ifdef CONFIG_WIN32
     eventFilter = new EventFilter();
     qt5App->installNativeEventFilter(eventFilter);
 #endif
     if (qt5IsOnscreen) {
         qt5GLContext = QOpenGLContext::globalShareContext();
+        qDebug("* Qt global share context: OpenGL %d.%d(Profile:%d)",
+               qt5GLContext->format().majorVersion(),
+               qt5GLContext->format().minorVersion(),
+               qt5GLContext->format().profile());
+
+// There are 2 issues:
+// With some Radeon GPU, the Qt5 library makes error with glCreateShader,
+// compilation error like below in Qt5 internal implementations:
+// Implicit version number 110 not supported by GL3 forward compatible context
+// And the issue that happens with the force legacy.(gl_version=2).
+// This code is W/A to experience,
+// I do not know the exact cause and solution.(IMHO, it is a Qt's bug.)
+// On Mac OS X(macOS), must explicitly usr the OpenGL version, exclude.
+#ifndef CONFIG_DARWIN
+        if (!isForceLegacy) {
+            QSurfaceFormat defFormat = QSurfaceFormat::defaultFormat();
+            defFormat.setMajorVersion(2);
+            defFormat.setMinorVersion(1);
+            defFormat.setProfile(QSurfaceFormat::NoProfile);
+            QSurfaceFormat::setDefaultFormat(defFormat);
+        }
+#endif
+        qDebug("* Qt requested default format: OpenGL %d.%d(Profile:%d)",
+               QSurfaceFormat::defaultFormat().majorVersion(),
+               QSurfaceFormat::defaultFormat().minorVersion(),
+               QSurfaceFormat::defaultFormat().profile());
     }
+    QCoreApplication::setApplicationName(EMULATOR_TITLE);
+
+    qInfo() << "* Qt version (compile time):" << QT_VERSION_STR;
+    qInfo() << "* Qt version (runtime):" << qVersion();
+    qInfo() << "* working path:" << QDir::currentPath();
+    qInfo() << "* binary path:" << QCoreApplication::applicationDirPath();
+    qInfo() << "* Qt plugin library path:" << QCoreApplication::libraryPaths();
 }
 
 void qt5_prepare(void)