qtbase-qxcbwindow.patch 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. From 0c1831178540462da31fd7a4b6d2e446bc84498b Mon Sep 17 00:00:00 2001
  2. From: Erik Kurzinger <ekurzinger@nvidia.com>
  3. Date: Thu, 13 Jun 2019 08:15:50 -0700
  4. Subject: Track swap interval in QXcbWindow
  5. As per GLX_EXT_swap_control, the GLX swap interval is specified on a
  6. per-drawable basis. However, QGLXContext only tracks it per-context
  7. using the m_swapInterval member. If a new drawable is made current to a
  8. context, it is still necessary to call glXSwapIntervalEXT to change the
  9. swap interval, even if it has been previously called for the same
  10. context with a different drawable. However, currently,
  11. QGLXContext::makeCurrent doesn't do this if its m_swapInterval field
  12. matches the new swap interval. This change removes m_swapInterval from
  13. QGLXContext, instead tracking it in QXcbWindow. This still avoids
  14. unnecessary calls to glXSwapIntervalEXT, while ensuring the swap
  15. interval is always set for new window drawables.
  16. Change-Id: Idc34101476c6af618059f6f3d8925dee743994a3
  17. Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
  18. Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
  19. ---
  20. .../platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp | 6 +++---
  21. src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h | 1 -
  22. src/plugins/platforms/xcb/qxcbwindow.h | 4 ++++
  23. 3 files changed, 7 insertions(+), 4 deletions(-)
  24. diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
  25. index 4adf662152..f26f698e76 100644
  26. --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
  27. +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
  28. @@ -204,7 +204,6 @@ QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlat
  29. , m_shareContext(0)
  30. , m_format(format)
  31. , m_isPBufferCurrent(false)
  32. - , m_swapInterval(-1)
  33. , m_ownsContext(nativeHandle.isNull())
  34. , m_getGraphicsResetStatus(0)
  35. , m_lost(false)
  36. @@ -567,9 +566,9 @@ bool QGLXContext::makeCurrent(QPlatformSurface *surface)
  37. if (success && surfaceClass == QSurface::Window) {
  38. int interval = surface->format().swapInterval();
  39. + QXcbWindow *window = static_cast<QXcbWindow *>(surface);
  40. QXcbScreen *screen = screenForPlatformSurface(surface);
  41. - if (interval >= 0 && m_swapInterval != interval && screen) {
  42. - m_swapInterval = interval;
  43. + if (interval >= 0 && interval != window->swapInterval() && screen) {
  44. typedef void (*qt_glXSwapIntervalEXT)(Display *, GLXDrawable, int);
  45. typedef void (*qt_glXSwapIntervalMESA)(unsigned int);
  46. static qt_glXSwapIntervalEXT glXSwapIntervalEXT = 0;
  47. @@ -588,6 +587,7 @@ bool QGLXContext::makeCurrent(QPlatformSurface *surface)
  48. glXSwapIntervalEXT(m_display, glxDrawable, interval);
  49. else if (glXSwapIntervalMESA)
  50. glXSwapIntervalMESA(interval);
  51. + window->setSwapInterval(interval);
  52. }
  53. }
  54. diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h
  55. index be9d3f5dcb..2a88fd6e59 100644
  56. --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h
  57. +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h
  58. @@ -87,7 +87,6 @@ private:
  59. GLXContext m_shareContext;
  60. QSurfaceFormat m_format;
  61. bool m_isPBufferCurrent;
  62. - int m_swapInterval;
  63. bool m_ownsContext;
  64. GLenum (APIENTRY * m_getGraphicsResetStatus)();
  65. bool m_lost;
  66. diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
  67. index f98cd8a74d..8258cc2dfa 100644
  68. --- a/src/plugins/platforms/xcb/qxcbwindow.h
  69. +++ b/src/plugins/platforms/xcb/qxcbwindow.h
  70. @@ -184,6 +184,9 @@ public:
  71. static void setWindowTitle(const QXcbConnection *conn, xcb_window_t window, const QString &title);
  72. static QString windowTitle(const QXcbConnection *conn, xcb_window_t window);
  73. + int swapInterval() const { return m_swapInterval; }
  74. + void setSwapInterval(int swapInterval) { m_swapInterval = swapInterval; }
  75. +
  76. public Q_SLOTS:
  77. void updateSyncRequestCounter();
  78. @@ -276,6 +279,7 @@ protected:
  79. SyncState m_syncState = NoSyncNeeded;
  80. QXcbSyncWindowRequest *m_pendingSyncRequest = nullptr;
  81. + int m_swapInterval = -1;
  82. };
  83. class QXcbForeignWindow : public QXcbWindow
  84. --
  85. cgit v1.2.1