From 9de4c490ba424359cd19b6097c179ec503586674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B6glund?= Date: Fri, 28 Jun 2013 20:04:33 +0200 Subject: [PATCH] kwin: Add GLPlatform::preferBufferSubData() This method returns true when glMapBufferRange() is likely to perform worse than glBufferSubData() when updating an unused range in a buffer object. This is the case with the NVIDIA driver, where glMapBufferRange() will force thread serialization. The driver tracks which ranges of the buffer are in use, so calls to glBufferSubData() should not cause a pipeline stall. --- libkwineffects/kwinglplatform.cpp | 10 +++++++++- libkwineffects/kwinglplatform.h | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/libkwineffects/kwinglplatform.cpp b/libkwineffects/kwinglplatform.cpp index b0d20f4545..3783a21273 100644 --- a/libkwineffects/kwinglplatform.cpp +++ b/libkwineffects/kwinglplatform.cpp @@ -602,6 +602,7 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) } m_chipset = "Unknown"; + m_preferBufferSubData = false; // Mesa classic drivers @@ -794,8 +795,10 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) if (m_driver == Driver_NVidia && m_chipClass < NV40) m_supportsGLSL = false; // High likelihood of software emulation - if (m_driver == Driver_NVidia) + if (m_driver == Driver_NVidia) { m_looseBinding = true; + m_preferBufferSubData = true; + } if (m_chipClass < NV20) { m_recommendedCompositor = XRenderCompositing; @@ -1051,6 +1054,11 @@ CompositingType GLPlatform::recommendedCompositor() const return m_recommendedCompositor; } +bool GLPlatform::preferBufferSubData() const +{ + return m_preferBufferSubData; +} + bool GLPlatform::isGLES() const { #ifdef KWIN_HAVE_OPENGLES diff --git a/libkwineffects/kwinglplatform.h b/libkwineffects/kwinglplatform.h index 55e23f6545..36a0e15e16 100644 --- a/libkwineffects/kwinglplatform.h +++ b/libkwineffects/kwinglplatform.h @@ -307,6 +307,14 @@ public: **/ CompositingType recommendedCompositor() const; + /** + * Returns true if glMapBufferRange() is likely to perform worse than glBufferSubData() + * when updating an unused range of a buffer object, and false otherwise. + * + * @since 4.11 + */ + bool preferBufferSubData() const; + /** * @returns a human readable form of the @p version. * @since 4.9 @@ -359,6 +367,7 @@ private: bool m_textureNPOT: 1; bool m_limitedNPOT: 1; bool m_virtualMachine: 1; + bool m_preferBufferSubData: 1; static GLPlatform *s_platform; };