diff --git a/glxbackend.cpp b/glxbackend.cpp index 8b2360a8b0..24fcbebf74 100644 --- a/glxbackend.cpp +++ b/glxbackend.cpp @@ -112,6 +112,12 @@ void GlxBackend::init() qWarning() << "NO VSYNC! glXGetVideoSync, glXSwapInterval, glXIsDirect" << bool(glXGetVideoSync) << bool(glXSwapInterval) << glXIsDirect(display(), ctxbuffer); } + if (glPlatform->isVirtualBox()) { + // VirtualBox does not support glxQueryDrawable + // this should actually be in kwinglutils_funcs, but QueryDrawable seems not to be provided by an extension + // and the GLPlatform has not been initialized at the moment when initGLX() is called. + glXQueryDrawable = NULL; + } setIsDirectRendering(bool(glXIsDirect(display(), ctxbuffer))); kDebug(1212) << "DB:" << isDoubleBuffer() << ", Direct:" << isDirectRendering() << endl; } diff --git a/libkwineffects/kwinglplatform.cpp b/libkwineffects/kwinglplatform.cpp index b936c79117..ce6c9edfe9 100644 --- a/libkwineffects/kwinglplatform.cpp +++ b/libkwineffects/kwinglplatform.cpp @@ -430,6 +430,8 @@ QString GLPlatform::driverToString(Driver driver) return "softpipe"; case Driver_Llvmpipe: return "LLVMpipe"; + case Driver_VirtualBox: + return "VirtualBox (Chromium)"; default: return "Unknown"; @@ -505,7 +507,8 @@ GLPlatform::GLPlatform() m_supportsGLSL(false), m_limitedGLSL(false), m_textureNPOT(false), - m_limitedNPOT(false) + m_limitedNPOT(false), + m_virtualMachine(false) { } @@ -709,6 +712,19 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) m_driver = Driver_Swrast; } + // Virtual Hardware + // ==================================================== + else if (m_vendor == "Humper" && m_renderer == "Chromium") { + // Virtual Box + m_driver = Driver_VirtualBox; + + const int index = versionTokens.indexOf("Chromium"); + if (versionTokens.count() > index) + m_driverVersion = parseVersionString(versionTokens.at(index + 1)); + else + m_driverVersion = 0; + } + // Driver/GPU specific features // ==================================================== @@ -769,6 +785,10 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) // Software emulation does not provide GLSL m_limitedGLSL = m_supportsGLSL = false; } + + if (isVirtualBox()) { + m_virtualMachine = true; + } } static void print(const QString &label, const QString &setting) @@ -810,6 +830,7 @@ void GLPlatform::printResults() const print("Requires strict binding:", !m_looseBinding ? "yes" : "no"); print("GLSL shaders:", m_supportsGLSL ? (m_limitedGLSL ? "limited" : "yes") : "no"); print("Texture NPOT support:", m_textureNPOT ? (m_limitedNPOT ? "limited" : "yes") : "no"); + print("Virtual Machine:", m_virtualMachine ? "yes" : "no"); } bool GLPlatform::supports(GLFeature feature) const @@ -908,6 +929,11 @@ bool GLPlatform::isIntel() const return m_chipClass >= I8XX && m_chipClass <= UnknownIntel; } +bool GLPlatform::isVirtualBox() const +{ + return m_driver == Driver_VirtualBox; +} + bool GLPlatform::isSoftwareEmulation() const { return m_driver == Driver_Softpipe || m_driver == Driver_Swrast || m_driver == Driver_Llvmpipe; @@ -943,5 +969,10 @@ bool GLPlatform::isLooseBinding() const return m_looseBinding; } +bool GLPlatform::isVirtualMachine() const +{ + return m_virtualMachine; +} + } // namespace KWin diff --git a/libkwineffects/kwinglplatform.h b/libkwineffects/kwinglplatform.h index 8940681ad3..a961efe9d7 100644 --- a/libkwineffects/kwinglplatform.h +++ b/libkwineffects/kwinglplatform.h @@ -96,6 +96,7 @@ enum Driver { Driver_Swrast, Driver_Softpipe, Driver_Llvmpipe, + Driver_VirtualBox, Driver_Unknown }; @@ -238,12 +239,24 @@ public: */ bool isIntel() const; + /** + * @returns @c true if the "GPU" is a VirtualBox GPU, and @c false otherwise. + * @since 4.10 + **/ + bool isVirtualBox() const; + /** * @returns @c true if OpenGL is emulated in software. * @since 4.7 **/ bool isSoftwareEmulation() const; + /** + * @returns @c true if the driver is known to be from a virtual machine. + * @since 4.10 + **/ + bool isVirtualMachine() const; + /** * @returns the GL_VERSION string as provided by the driver. * @since 4.9 @@ -326,6 +339,7 @@ private: bool m_limitedGLSL: 1; bool m_textureNPOT: 1; bool m_limitedNPOT: 1; + bool m_virtualMachine: 1; static GLPlatform *s_platform; }; diff --git a/opengltest/opengltest.cpp b/opengltest/opengltest.cpp index 17641e2faf..b0b8f59857 100644 --- a/opengltest/opengltest.cpp +++ b/opengltest/opengltest.cpp @@ -125,6 +125,11 @@ int main(int argc, char *argv[]) return 0; } + // Direct context also works with VirtualBox's driver + const GLubyte *renderer = glGetString(GL_RENDERER); + if (strstr((const char *)vendor, "Humper") && strstr((const char *)renderer, "Chromium")) + return 0; + return 1; } diff --git a/workspace.cpp b/workspace.cpp index e86e39e15a..75972d4954 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -2188,6 +2188,12 @@ QString Workspace::supportInformation() const } else { support.append(" no\n"); } + support.append("Virtual Machine: "); + if (platform->isVirtualMachine()) { + support.append(" yes\n"); + } else { + support.append(" no\n"); + } if (effects->compositingType() == OpenGL2Compositing) { support.append("OpenGL 2 Shaders are used\n");