mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 04:24:47 +02:00
Enable KHR_robustness option
This commit is contained in:
parent
fcda85a3d1
commit
6b34b0971f
3 changed files with 41 additions and 21 deletions
|
@ -139,6 +139,7 @@ option(BUILD_MANUAL_TESTS "Build manual tests" ${BUILD_MANUAL_TESTS_OPTION})
|
||||||
option(BUILD_TOOLS "Build tools" ${BUILD_TOOLS_OPTION})
|
option(BUILD_TOOLS "Build tools" ${BUILD_TOOLS_OPTION})
|
||||||
option(BUILD_INSTALLER "Build installer" ${BUILD_INSTALLER_OPTION})
|
option(BUILD_INSTALLER "Build installer" ${BUILD_INSTALLER_OPTION})
|
||||||
option(USE_GLES "Use OpenGL ES" ${GLES_OPTION})
|
option(USE_GLES "Use OpenGL ES" ${GLES_OPTION})
|
||||||
|
option(USE_KHR_ROBUSTNESS "Use KHR_robustness" OFF)
|
||||||
option(DISABLE_QML "Disable QML" ${DISABLE_QML_OPTION})
|
option(DISABLE_QML "Disable QML" ${DISABLE_QML_OPTION})
|
||||||
option(DISABLE_KTX_CACHE "Disable KTX Cache" OFF)
|
option(DISABLE_KTX_CACHE "Disable KTX Cache" OFF)
|
||||||
option(
|
option(
|
||||||
|
@ -149,6 +150,10 @@ option(
|
||||||
|
|
||||||
set(PLATFORM_QT_GL OpenGL)
|
set(PLATFORM_QT_GL OpenGL)
|
||||||
|
|
||||||
|
if (USE_KHR_ROBUSTNESS)
|
||||||
|
add_definitions(-DUSE_KHR_ROBUSTNESS)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (USE_GLES)
|
if (USE_GLES)
|
||||||
add_definitions(-DUSE_GLES)
|
add_definitions(-DUSE_GLES)
|
||||||
add_definitions(-DGPU_POINTER_STORAGE_SHARED)
|
add_definitions(-DGPU_POINTER_STORAGE_SHARED)
|
||||||
|
|
|
@ -27,6 +27,10 @@
|
||||||
#include "GLHelpers.h"
|
#include "GLHelpers.h"
|
||||||
#include "QOpenGLContextWrapper.h"
|
#include "QOpenGLContextWrapper.h"
|
||||||
|
|
||||||
|
#if defined(GL_CUSTOM_CONTEXT)
|
||||||
|
#include <QtPlatformHeaders/QWGLNativeContext>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace gl;
|
using namespace gl;
|
||||||
|
|
||||||
#if defined(GL_CUSTOM_CONTEXT)
|
#if defined(GL_CUSTOM_CONTEXT)
|
||||||
|
@ -42,7 +46,10 @@ std::atomic<size_t> Context::_totalSwapchainMemoryUsage { 0 };
|
||||||
size_t Context::getSwapchainMemoryUsage() { return _totalSwapchainMemoryUsage.load(); }
|
size_t Context::getSwapchainMemoryUsage() { return _totalSwapchainMemoryUsage.load(); }
|
||||||
|
|
||||||
size_t Context::evalSurfaceMemoryUsage(uint32_t width, uint32_t height, uint32_t pixelSize) {
|
size_t Context::evalSurfaceMemoryUsage(uint32_t width, uint32_t height, uint32_t pixelSize) {
|
||||||
return width * height * pixelSize;
|
size_t result = width;
|
||||||
|
result *= height;
|
||||||
|
result *= pixelSize;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Context::updateSwapchainMemoryUsage(size_t prevSize, size_t newSize) {
|
void Context::updateSwapchainMemoryUsage(size_t prevSize, size_t newSize) {
|
||||||
|
@ -126,7 +133,7 @@ void Context::clear() {
|
||||||
#if defined(GL_CUSTOM_CONTEXT)
|
#if defined(GL_CUSTOM_CONTEXT)
|
||||||
|
|
||||||
static void setupPixelFormatSimple(HDC hdc) {
|
static void setupPixelFormatSimple(HDC hdc) {
|
||||||
// FIXME build the PFD based on the
|
// FIXME build the PFD based on the
|
||||||
static const PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
|
static const PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
|
||||||
{
|
{
|
||||||
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
|
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
|
||||||
|
@ -176,6 +183,7 @@ static void setupPixelFormatSimple(HDC hdc) {
|
||||||
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
|
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||||
|
|
||||||
// Context create flag bits
|
// Context create flag bits
|
||||||
|
#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
|
||||||
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||||
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||||
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
|
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
|
||||||
|
@ -196,17 +204,17 @@ GLAPI PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
|
||||||
Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
|
Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
|
||||||
|
|
||||||
#if defined(GL_CUSTOM_CONTEXT)
|
#if defined(GL_CUSTOM_CONTEXT)
|
||||||
bool Context::makeCurrent() {
|
bool Context::makeCurrent() {
|
||||||
BOOL result = wglMakeCurrent(_hdc, _hglrc);
|
BOOL result = wglMakeCurrent(_hdc, _hglrc);
|
||||||
assert(result);
|
assert(result);
|
||||||
updateSwapchainMemoryCounter();
|
updateSwapchainMemoryCounter();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
void Context::swapBuffers() {
|
void Context::swapBuffers() {
|
||||||
SwapBuffers(_hdc);
|
SwapBuffers(_hdc);
|
||||||
}
|
}
|
||||||
void Context::doneCurrent() {
|
void Context::doneCurrent() {
|
||||||
wglMakeCurrent(0, 0);
|
wglMakeCurrent(0, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -305,11 +313,18 @@ void Context::create(QOpenGLContext* shareContext) {
|
||||||
#else
|
#else
|
||||||
contextAttribs.push_back(WGL_CONTEXT_CORE_PROFILE_BIT_ARB);
|
contextAttribs.push_back(WGL_CONTEXT_CORE_PROFILE_BIT_ARB);
|
||||||
#endif
|
#endif
|
||||||
contextAttribs.push_back(WGL_CONTEXT_FLAGS_ARB);
|
{
|
||||||
if (enableDebugLogger()) {
|
int contextFlags = 0;
|
||||||
contextAttribs.push_back(WGL_CONTEXT_DEBUG_BIT_ARB);
|
if (enableDebugLogger()) {
|
||||||
} else {
|
contextFlags |= WGL_CONTEXT_DEBUG_BIT_ARB;
|
||||||
contextAttribs.push_back(0);
|
}
|
||||||
|
#ifdef USE_KHR_ROBUSTNESS
|
||||||
|
contextFlags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
||||||
|
#endif
|
||||||
|
if (contextFlags != 0) {
|
||||||
|
contextAttribs.push_back(WGL_CONTEXT_FLAGS_ARB);
|
||||||
|
contextAttribs.push_back(contextFlags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
contextAttribs.push_back(0);
|
contextAttribs.push_back(0);
|
||||||
HGLRC shareHglrc = nullptr;
|
HGLRC shareHglrc = nullptr;
|
||||||
|
@ -323,8 +338,8 @@ void Context::create(QOpenGLContext* shareContext) {
|
||||||
if (_hglrc != 0) {
|
if (_hglrc != 0) {
|
||||||
createWrapperContext();
|
createWrapperContext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_hglrc == 0) {
|
if (_hglrc == 0) {
|
||||||
// fallback, if the context creation failed, or USE_CUSTOM_CONTEXT is false
|
// fallback, if the context creation failed, or USE_CUSTOM_CONTEXT is false
|
||||||
qtCreate(shareContext);
|
qtCreate(shareContext);
|
||||||
|
|
|
@ -23,7 +23,7 @@ class QOpenGLContext;
|
||||||
class QThread;
|
class QThread;
|
||||||
class QOpenGLDebugMessage;
|
class QOpenGLDebugMessage;
|
||||||
|
|
||||||
#if defined(Q_OS_WIN) && defined(USE_GLES)
|
#if defined(Q_OS_WIN) && (defined(USE_GLES) || defined(USE_KHR_ROBUSTNESS))
|
||||||
//#if defined(Q_OS_WIN)
|
//#if defined(Q_OS_WIN)
|
||||||
#define GL_CUSTOM_CONTEXT
|
#define GL_CUSTOM_CONTEXT
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue