Mageia Bugzilla – Attachment 9912 Details for
Bug 18904
Plasma+Nvidia: After resume, Plasma desktop icons text fields is unreadable on some systems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
QtBase NV Reset.patch
QtBase NV Reset.patch (text/plain), 7.28 KB, created by
Christian Fesl
on 2018-01-17 18:07:44 CET
(
hide
)
Description:
QtBase NV Reset.patch
Filename:
MIME Type:
Creator:
Christian Fesl
Created:
2018-01-17 18:07:44 CET
Size:
7.28 KB
patch
obsolete
>diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp >index 7640a711a9..80d2619633 100644 >--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp >+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp >@@ -165,6 +165,8 @@ QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlat > , m_isPBufferCurrent(false) > , m_swapInterval(-1) > , m_ownsContext(nativeHandle.isNull()) >+ , m_getGraphicsResetStatus(0) >+ , m_lost(false) > { > if (nativeHandle.isNull()) > init(screen, share); >@@ -174,6 +176,8 @@ QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlat > > void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) > { >+ qDebug() << "Dave - glx init"; >+ > if (m_format.renderableType() == QSurfaceFormat::DefaultRenderableType) > #if defined(QT_OPENGL_ES_2) > m_format.setRenderableType(QSurfaceFormat::OpenGLES); >@@ -200,7 +204,13 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) > glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB"); > > const bool supportsProfiles = glxExt.contains("GLX_ARB_create_context_profile"); >- >+ const bool supportsRobustness = glxExt.contains("GLX_ARB_create_context_profile"); >+ const bool supportsVideoMemoryPurge = glxExt.contains(QByteArrayLiteral("GLX_NV_robustness_video_memory_purge")); >+ >+ qDebug() << "supports robust "<< supportsRobustness; >+ qDebug() << "supports supportsVideoMemoryPurge "<< supportsVideoMemoryPurge; >+ >+ > // Use glXCreateContextAttribsARB if available > // Also, GL ES context creation requires GLX_EXT_create_context_es2_profile > if (glXCreateContextAttribsARB != 0 >@@ -249,8 +259,12 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) > else > contextAttributes << GLX_CONTEXT_PROFILE_MASK_ARB << GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; > } >- >+ > int flags = 0; >+ >+ if (supportsRobustness) { >+ flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB; >+ } > > if (m_format.testOption(QSurfaceFormat::DebugContext)) > flags |= GLX_CONTEXT_DEBUG_BIT_ARB; >@@ -264,19 +278,41 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) > } else if (m_format.renderableType() == QSurfaceFormat::OpenGLES) { > contextAttributes << GLX_CONTEXT_PROFILE_MASK_ARB << GLX_CONTEXT_ES2_PROFILE_BIT_EXT; > } >- >+ >+ //should I try without robustness, and without video memory purge too? >+ //seems excessive given I've already tested for the extension..but kwin does it >+ //if so, probably best merging kwin's GL builder >+ //TODO EGL >+ if (supportsRobustness) { >+ //Dave shoud I - format.testOption(QSurfaceFormat::ResetNotification) ? >+ contextAttributes << GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB; >+ contextAttributes << GLX_LOSE_CONTEXT_ON_RESET_ARB; >+ if (supportsVideoMemoryPurge) { >+ contextAttributes << GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV; >+ contextAttributes << GL_TRUE; >+ } >+ } >+ > contextAttributes << None; >- >- m_context = glXCreateContextAttribsARB(m_display, config, m_shareContext, true, contextAttributes.data()); >- if (!m_context && m_shareContext) { >- // re-try without a shared glx context >- m_context = glXCreateContextAttribsARB(m_display, config, 0, true, contextAttributes.data()); >- if (m_context) >- m_shareContext = 0; >+ if (!m_context) { >+ m_context = glXCreateContextAttribsARB(m_display, config, m_shareContext, true, contextAttributes.data()); >+ if (!m_context && m_shareContext) { >+ // re-try without a shared glx context >+ m_context = glXCreateContextAttribsARB(m_display, config, 0, true, contextAttributes.data()); >+ if (m_context) >+ m_shareContext = 0; >+ } > } >+ qDebug() << "made context? " << m_context; > } > } >- >+ >+ if (supportsRobustness && m_context) { >+ m_getGraphicsResetStatus = reinterpret_cast<GLenum (QOPENGLF_APIENTRYP)()>(getProcAddress("glGetGraphicsResetStatusARB")); >+ } >+ qDebug() << "DAVE: MGRS" << m_getGraphicsResetStatus; >+ >+ > // Could not create a context using glXCreateContextAttribsARB, falling back to glXCreateNewContext. > if (!m_context) { > // requesting an OpenGL ES context requires glXCreateContextAttribsARB, so bail out >@@ -291,6 +327,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) > m_shareContext = 0; > } > } >+ > > // Get the basic surface format details > if (m_context) >@@ -480,11 +517,19 @@ bool QGLXContext::makeCurrent(QPlatformSurface *surface) > QXcbWindow *window = static_cast<QXcbWindow *>(surface); > glxDrawable = window->xcb_window(); > success = glXMakeCurrent(m_display, glxDrawable, m_context); >+ m_lost= false; >+ if (m_getGraphicsResetStatus && m_getGraphicsResetStatus() != GL_NO_ERROR) { >+ m_lost = true; >+ qDebug() << "makeCurrent(): context loss detected" << this; >+ // Drop the surface. Will recreate on the next makeCurrent. >+ window->invalidateSurface(); >+ } > } else if (surfaceClass == QSurface::Offscreen) { > m_isPBufferCurrent = true; > QGLXPbuffer *pbuffer = static_cast<QGLXPbuffer *>(surface); > glxDrawable = pbuffer->pbuffer(); > success = glXMakeContextCurrent(m_display, glxDrawable, glxDrawable, m_context); >+ //DAVE ? > } > > if (success && surfaceClass == QSurface::Window) { >@@ -595,7 +640,7 @@ bool QGLXContext::isSharing() const > > bool QGLXContext::isValid() const > { >- return m_context != 0; >+ return m_context != 0 && !m_lost; > } > > bool QGLXContext::m_queriedDummyContext = false; >diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h >index 3dfe0ac618..e58517e33d 100644 >--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h >+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h >@@ -83,6 +83,8 @@ private: > bool m_isPBufferCurrent; > int m_swapInterval; > bool m_ownsContext; >+ GLenum (APIENTRY * m_getGraphicsResetStatus)(); >+ bool m_lost; > static bool m_queriedDummyContext; > static bool m_supportsThreading; > }; >
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp index 7640a711a9..80d2619633 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -165,6 +165,8 @@ QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlat , m_isPBufferCurrent(false) , m_swapInterval(-1) , m_ownsContext(nativeHandle.isNull()) + , m_getGraphicsResetStatus(0) + , m_lost(false) { if (nativeHandle.isNull()) init(screen, share); @@ -174,6 +176,8 @@ QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlat void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) { + qDebug() << "Dave - glx init"; + if (m_format.renderableType() == QSurfaceFormat::DefaultRenderableType) #if defined(QT_OPENGL_ES_2) m_format.setRenderableType(QSurfaceFormat::OpenGLES); @@ -200,7 +204,13 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB"); const bool supportsProfiles = glxExt.contains("GLX_ARB_create_context_profile"); - + const bool supportsRobustness = glxExt.contains("GLX_ARB_create_context_profile"); + const bool supportsVideoMemoryPurge = glxExt.contains(QByteArrayLiteral("GLX_NV_robustness_video_memory_purge")); + + qDebug() << "supports robust "<< supportsRobustness; + qDebug() << "supports supportsVideoMemoryPurge "<< supportsVideoMemoryPurge; + + // Use glXCreateContextAttribsARB if available // Also, GL ES context creation requires GLX_EXT_create_context_es2_profile if (glXCreateContextAttribsARB != 0 @@ -249,8 +259,12 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) else contextAttributes << GLX_CONTEXT_PROFILE_MASK_ARB << GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; } - + int flags = 0; + + if (supportsRobustness) { + flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB; + } if (m_format.testOption(QSurfaceFormat::DebugContext)) flags |= GLX_CONTEXT_DEBUG_BIT_ARB; @@ -264,19 +278,41 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) } else if (m_format.renderableType() == QSurfaceFormat::OpenGLES) { contextAttributes << GLX_CONTEXT_PROFILE_MASK_ARB << GLX_CONTEXT_ES2_PROFILE_BIT_EXT; } - + + //should I try without robustness, and without video memory purge too? + //seems excessive given I've already tested for the extension..but kwin does it + //if so, probably best merging kwin's GL builder + //TODO EGL + if (supportsRobustness) { + //Dave shoud I - format.testOption(QSurfaceFormat::ResetNotification) ? + contextAttributes << GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB; + contextAttributes << GLX_LOSE_CONTEXT_ON_RESET_ARB; + if (supportsVideoMemoryPurge) { + contextAttributes << GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV; + contextAttributes << GL_TRUE; + } + } + contextAttributes << None; - - m_context = glXCreateContextAttribsARB(m_display, config, m_shareContext, true, contextAttributes.data()); - if (!m_context && m_shareContext) { - // re-try without a shared glx context - m_context = glXCreateContextAttribsARB(m_display, config, 0, true, contextAttributes.data()); - if (m_context) - m_shareContext = 0; + if (!m_context) { + m_context = glXCreateContextAttribsARB(m_display, config, m_shareContext, true, contextAttributes.data()); + if (!m_context && m_shareContext) { + // re-try without a shared glx context + m_context = glXCreateContextAttribsARB(m_display, config, 0, true, contextAttributes.data()); + if (m_context) + m_shareContext = 0; + } } + qDebug() << "made context? " << m_context; } } - + + if (supportsRobustness && m_context) { + m_getGraphicsResetStatus = reinterpret_cast<GLenum (QOPENGLF_APIENTRYP)()>(getProcAddress("glGetGraphicsResetStatusARB")); + } + qDebug() << "DAVE: MGRS" << m_getGraphicsResetStatus; + + // Could not create a context using glXCreateContextAttribsARB, falling back to glXCreateNewContext. if (!m_context) { // requesting an OpenGL ES context requires glXCreateContextAttribsARB, so bail out @@ -291,6 +327,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) m_shareContext = 0; } } + // Get the basic surface format details if (m_context) @@ -480,11 +517,19 @@ bool QGLXContext::makeCurrent(QPlatformSurface *surface) QXcbWindow *window = static_cast<QXcbWindow *>(surface); glxDrawable = window->xcb_window(); success = glXMakeCurrent(m_display, glxDrawable, m_context); + m_lost= false; + if (m_getGraphicsResetStatus && m_getGraphicsResetStatus() != GL_NO_ERROR) { + m_lost = true; + qDebug() << "makeCurrent(): context loss detected" << this; + // Drop the surface. Will recreate on the next makeCurrent. + window->invalidateSurface(); + } } else if (surfaceClass == QSurface::Offscreen) { m_isPBufferCurrent = true; QGLXPbuffer *pbuffer = static_cast<QGLXPbuffer *>(surface); glxDrawable = pbuffer->pbuffer(); success = glXMakeContextCurrent(m_display, glxDrawable, glxDrawable, m_context); + //DAVE ? } if (success && surfaceClass == QSurface::Window) { @@ -595,7 +640,7 @@ bool QGLXContext::isSharing() const bool QGLXContext::isValid() const { - return m_context != 0; + return m_context != 0 && !m_lost; } bool QGLXContext::m_queriedDummyContext = false; diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h index 3dfe0ac618..e58517e33d 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h @@ -83,6 +83,8 @@ private: bool m_isPBufferCurrent; int m_swapInterval; bool m_ownsContext; + GLenum (APIENTRY * m_getGraphicsResetStatus)(); + bool m_lost; static bool m_queriedDummyContext; static bool m_supportsThreading; };
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 18904
:
8150
|
8151
|
8353
|
8758
|
8800
| 9912