From 9a30073f27b0786186a8214e94cd20c27db8ea2b Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 2 Oct 2018 09:20:41 -0700 Subject: [PATCH] Only enable debug GL context on demand --- libraries/gl/src/gl/Context.cpp | 7 +++++-- libraries/gl/src/gl/GLHelpers.cpp | 6 +++++- tests-manual/qml/src/MacQml.cpp | 18 ------------------ 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/libraries/gl/src/gl/Context.cpp b/libraries/gl/src/gl/Context.cpp index cd2b19beec..a3e01018b5 100644 --- a/libraries/gl/src/gl/Context.cpp +++ b/libraries/gl/src/gl/Context.cpp @@ -31,6 +31,10 @@ using namespace gl; bool Context::enableDebugLogger() { +#if defined(Q_OS_MAC) + // OSX does not support GL_KHR_debug or GL_ARB_debug_output + return false; +#else #if defined(DEBUG) || defined(USE_GLES) static bool enableDebugLogger = true; #else @@ -45,6 +49,7 @@ bool Context::enableDebugLogger() { } }); return enableDebugLogger; +#endif } @@ -233,7 +238,6 @@ GLAPI PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context(); - void Context::create(QOpenGLContext* shareContext) { assert(0 != _hwnd); assert(0 == _hdc); @@ -351,7 +355,6 @@ void Context::create(QOpenGLContext* shareContext) { #endif - OffscreenContext::~OffscreenContext() { _window->deleteLater(); } diff --git a/libraries/gl/src/gl/GLHelpers.cpp b/libraries/gl/src/gl/GLHelpers.cpp index ba27a13f58..15a41c3dc1 100644 --- a/libraries/gl/src/gl/GLHelpers.cpp +++ b/libraries/gl/src/gl/GLHelpers.cpp @@ -13,6 +13,8 @@ #include #include +#include "Context.h" + size_t evalGLFormatSwapchainPixelSize(const QSurfaceFormat& format) { size_t pixelSize = format.redBufferSize() + format.greenBufferSize() + format.blueBufferSize() + format.alphaBufferSize(); // We don't apply the length of the swap chain into this pixelSize since it is not vsible for the Process (on windows). @@ -97,7 +99,9 @@ const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() { #else format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile); #endif - format.setOption(QSurfaceFormat::DebugContext); + if (gl::Context::enableDebugLogger()) { + format.setOption(QSurfaceFormat::DebugContext); + } // Qt Quick may need a depth and stencil buffer. Always make sure these are available. format.setDepthBufferSize(DEFAULT_GL_DEPTH_BUFFER_BITS); format.setStencilBufferSize(DEFAULT_GL_STENCIL_BUFFER_BITS); diff --git a/tests-manual/qml/src/MacQml.cpp b/tests-manual/qml/src/MacQml.cpp index 13d8642822..9c5f91041e 100644 --- a/tests-manual/qml/src/MacQml.cpp +++ b/tests-manual/qml/src/MacQml.cpp @@ -7,24 +7,6 @@ #include using TextureAndFence = hifi::qml::OffscreenSurface::TextureAndFence; -// -//void MacQml::destroySurface(QmlInfo& qmlInfo) { -// auto& surface = qmlInfo.surface; -// auto& currentTexture = qmlInfo.texture; -// if (currentTexture) { -// auto readFence = _glf.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); -// glFlush(); -// _discardLamdba(currentTexture, readFence); -// } -// auto webView = surface->getRootItem(); -// if (webView) { -// // stop loading -// QMetaObject::invokeMethod(webView, "stop"); -// webView->setProperty(URL_PROPERTY, "about:blank"); -// } -// surface->pause(); -// surface.reset(); -//} void MacQml::update() { auto rootItem =_surface->getRootItem();