Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-63180

[macOS] Sharing OpenGL contexts doesn't work when explicitly requesting version "3.2 Core"

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.10.0 RC
    • 5.10
    • QPA
    • None
    • macOS 10.12.5, iMac Retina 5k 2015, AMD Radeon R9 M390
    • macOS
    • 12aa50175268064b3da36473ec0196cbdb1bdf7f

    Description

      If context sharing is enabled with

      QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
      

      and default surface format is set using

      QSurfaceFormat format;
      format.setVersion(3, 2);
      format.setProfile(QSurfaceFormat::CoreProfile);
      QSurfaceFormat::setDefaultFormat(format);
      

      and then you set the format of a QQuickWidget / QOpenGLWidget to the global shared context with

      QQuickWidget foo;
      QOpenGLContext *globalSharedContext = QOpenGLContext::globalShareContext();
      foo.setFormat(globalSharedContext->format());
      

      Then the shared OpenGL context for "foo" fails to be created. You get the error message: "QCocoaGLContext: Falling back to unshared context".

      This is because the globalSharedContext "advertises" that it is version 4.1, whereas it's actually 3.2.

      If you either modify the format of foo to be "3.2" (which would be used by default because of the defaultSurfaceFormat), or use "4.1" everywhere instead, everything works.

      My assumption is the following:
      Once the global context is created, its format is updated in updateFormatFromContext, which uses glGetString to parse out the version.

      That version is always reported as 4.1 for a Core profile, regardless if either 3.2 Core or 4.1 Core is requested.
      Internally for macOS though it does seem to make a difference, because sharing between 3.2 global context and 4.1 qquickwidget context is not possible.

      Sharing between "3.2 and 3.2", and "4.1 and 4.1" works fine though, regardless of the fact that the advertised version by glGetString is "4.1".

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sorvig Morten Sørvig
            alexandru.croitor Alexandru Croitor
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes