Switch back to disable GL 4.5 by default, add support for logging when enabled

This commit is contained in:
Brad Davis 2016-05-31 13:28:39 -07:00
parent a41de3a60d
commit ab7fed1af8
4 changed files with 26 additions and 15 deletions

View file

@ -6,6 +6,14 @@
#include <QtOpenGL/QGL>
#include <QOpenGLContext>
#include <QtCore/QRegularExpression>
#include <QtCore/QProcessEnvironment>
#ifdef DEBUG
static bool enableDebug = true;
#else
static const QString DEBUG_FLAG("HIFI_ENABLE_OPENGL_45");
static bool enableDebug = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG);
#endif
const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() {
static QSurfaceFormat format;
@ -15,9 +23,9 @@ const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() {
format.setDepthBufferSize(DEFAULT_GL_DEPTH_BUFFER_BITS);
format.setStencilBufferSize(DEFAULT_GL_STENCIL_BUFFER_BITS);
setGLFormatVersion(format);
#ifdef DEBUG
format.setOption(QSurfaceFormat::DebugContext);
#endif
if (enableDebug) {
format.setOption(QSurfaceFormat::DebugContext);
}
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
QSurfaceFormat::setDefaultFormat(format);
});

View file

@ -12,23 +12,30 @@
#include "OffscreenGLCanvas.h"
#include <QtCore/QProcessEnvironment>
#include <QtGui/QOffscreenSurface>
#include <QtGui/QOpenGLDebugLogger>
#include <QtGui/QOpenGLContext>
#include "GLHelpers.h"
#ifdef DEBUG
static bool enableDebugLogger = true;
#else
static const QString DEBUG_FLAG("HIFI_ENABLE_OPENGL_45");
static bool enableDebugLogger = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG);
#endif
OffscreenGLCanvas::OffscreenGLCanvas() : _context(new QOpenGLContext), _offscreenSurface(new QOffscreenSurface){
}
OffscreenGLCanvas::~OffscreenGLCanvas() {
#ifdef DEBUG
if (_logger) {
makeCurrent();
delete _logger;
_logger = nullptr;
}
#endif
_context->doneCurrent();
}
@ -60,7 +67,7 @@ bool OffscreenGLCanvas::makeCurrent() {
qDebug() << "GL Renderer: " << QString((const char*) glGetString(GL_RENDERER));
});
#ifdef DEBUG
if (result && !_logger) {
_logger = new QOpenGLDebugLogger(this);
if (_logger->initialize()) {
@ -71,7 +78,6 @@ bool OffscreenGLCanvas::makeCurrent() {
_logger->startLogging(QOpenGLDebugLogger::LoggingMode::SynchronousLogging);
}
}
#endif
return result;
}

View file

@ -36,10 +36,7 @@ protected:
std::once_flag _reportOnce;
QOpenGLContext* _context;
QOffscreenSurface* _offscreenSurface;
#ifdef DEBUG
QOpenGLDebugLogger* _logger{ nullptr };
#endif
};
#endif // hifi_OffscreenGLCanvas_h

View file

@ -32,19 +32,19 @@
using namespace gpu;
using namespace gpu::gl;
static const QString DEBUG_FLAG("HIFI_DISABLE_OPENGL_45");
bool disableOpenGL45 = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG);
static const QString DEBUG_FLAG("HIFI_ENABLE_OPENGL_45");
static bool enableOpenGL45 = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG);
Backend* GLBackend::createBackend() {
// FIXME provide a mechanism to override the backend for testing
// Where the gpuContext is initialized and where the TRUE Backend is created and assigned
auto version = QOpenGLContextWrapper::currentContextVersion();
GLBackend* result;
if (!disableOpenGL45 && version >= 0x0405) {
qDebug() << "OpenGL 4.5 detected";
if (enableOpenGL45 && version >= 0x0405) {
qDebug() << "Using OpenGL 4.5 backend";
result = new gpu::gl45::GL45Backend();
} else {
qDebug() << "OpenGL 4.5 not detected / enabled, using compatibility backend";
qDebug() << "Using OpenGL 4.1 backend";
result = new gpu::gl41::GL41Backend();
}
result->initInput();