From 6c812a3dfdb3e5e2aac0bc4777070f908427b1b1 Mon Sep 17 00:00:00 2001 From: James Hogan Date: Fri, 19 Aug 2022 22:32:58 +0100 Subject: [PATCH] osgXR: Update to 0.5.0 Update 3rdparty/osgXR to version 0.5.0, which primarily gets us build fixes for Windows. Unfortunately one of them requires an API breakage to avoid some apparent preprocessor namespace pollution on Windows, which will require minor source modification in FlightGear (left to the next commit). The ABI is unchanged so binary compatibility is unaffected. --- 3rdparty/osgXR/CHANGELOG.md | 18 ++++++++++++++++++ 3rdparty/osgXR/CMakeLists.txt | 4 ++-- 3rdparty/osgXR/README.md | 2 +- 3rdparty/osgXR/include/osgXR/Settings | 6 +++--- 3rdparty/osgXR/src/Swapchain.cpp | 8 ++++---- 3rdparty/osgXR/src/XRState.cpp | 13 +++++++++---- 3rdparty/osgXR/src/osgXR.cpp | 2 +- 7 files changed, 38 insertions(+), 15 deletions(-) diff --git a/3rdparty/osgXR/CHANGELOG.md b/3rdparty/osgXR/CHANGELOG.md index 7017d34cf..68acd6f64 100644 --- a/3rdparty/osgXR/CHANGELOG.md +++ b/3rdparty/osgXR/CHANGELOG.md @@ -1,3 +1,21 @@ +Version 0.5.0 +------------- + +Highlights: + * Windows build fixes. + +Changed APIs (source incompatible, binary compatible): + * Renamed Settings::BlendMode enumerations to fix windows build: + * Settings::OPAQUE -> Settings::BLEND\_MODE\_OPAQUE. + * Settings::ADDITIVE -> Settings::BLEND\_MODE\_ADDITIVE. + * Settings::ALPHA\_BLEND -> Settings::BLEND\_MODE\_ALPHA\_BLEND. + +Bug fixes: + * Swapchain: Use weak\_ptr::lock() to avoid exception. + +Behind the scenes: + * XRState: Use OSG defs for GL texture formats. + Version 0.3.9 ------------- diff --git a/3rdparty/osgXR/CMakeLists.txt b/3rdparty/osgXR/CMakeLists.txt index 190de9207..88a46658c 100644 --- a/3rdparty/osgXR/CMakeLists.txt +++ b/3rdparty/osgXR/CMakeLists.txt @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.11) set(osgXR_MAJOR_VERSION 0) -set(osgXR_MINOR_VERSION 3) -set(osgXR_PATCH_VERSION 9) +set(osgXR_MINOR_VERSION 5) +set(osgXR_PATCH_VERSION 0) set(osgXR_SOVERSION 6) set(osgXR_VERSION "${osgXR_MAJOR_VERSION}.${osgXR_MINOR_VERSION}.${osgXR_PATCH_VERSION}") diff --git a/3rdparty/osgXR/README.md b/3rdparty/osgXR/README.md index 8be669a1d..3f44dee96 100644 --- a/3rdparty/osgXR/README.md +++ b/3rdparty/osgXR/README.md @@ -41,7 +41,7 @@ Getting Started To import osgXR into a CMake based project, you can use the included CMake module, adding something like this to your CMakeLists.txt: ```cmake -find_package(osgXR 0.3.8 REQUIRED) +find_package(osgXR 0.5.0 REQUIRED) target_link_libraries(target .. diff --git a/3rdparty/osgXR/include/osgXR/Settings b/3rdparty/osgXR/include/osgXR/Settings index 244a1adaf..278d392f4 100644 --- a/3rdparty/osgXR/include/osgXR/Settings +++ b/3rdparty/osgXR/include/osgXR/Settings @@ -163,11 +163,11 @@ class OSGXR_EXPORT Settings : public osg::Referenced { // Matches XrEnvironmentBlendMode /// Display layers with no view of physical world behind. - OPAQUE = 1, + BLEND_MODE_OPAQUE = 1, /// Additively blend layers with view of physical world behind. - ADDITIVE = 2, + BLEND_MODE_ADDITIVE = 2, /// Alpha blend layers with view of physical world behind. - ALPHA_BLEND = 3, + BLEND_MODE_ALPHA_BLEND = 3, } BlendMode; /** * Specify a preferred environment blend mode. diff --git a/3rdparty/osgXR/src/Swapchain.cpp b/3rdparty/osgXR/src/Swapchain.cpp index 9874aca8e..c243b0a0a 100644 --- a/3rdparty/osgXR/src/Swapchain.cpp +++ b/3rdparty/osgXR/src/Swapchain.cpp @@ -31,7 +31,7 @@ class InitialDrawCallback : public osg::Camera::DrawCallback void operator()(osg::RenderInfo& renderInfo) const override { - auto swapchain = (std::shared_ptr)(_swapchain); + auto swapchain = _swapchain.lock(); if (swapchain) swapchain->initialDrawCallback(renderInfo); } @@ -51,14 +51,14 @@ class PreDrawCallback : public osg::Camera::DrawCallback ~PreDrawCallback() { - auto swapchain = (std::shared_ptr)(_swapchain); + auto swapchain = _swapchain.lock(); if (swapchain) swapchain->decNumDrawPasses(); } void operator()(osg::RenderInfo& renderInfo) const override { - auto swapchain = (std::shared_ptr)(_swapchain); + auto swapchain = _swapchain.lock(); if (swapchain) swapchain->preDrawCallback(renderInfo); } @@ -77,7 +77,7 @@ class PostDrawCallback : public osg::Camera::DrawCallback void operator()(osg::RenderInfo& renderInfo) const override { - auto swapchain = (std::shared_ptr)(_swapchain); + auto swapchain = _swapchain.lock(); if (swapchain) swapchain->postDrawCallback(renderInfo); } diff --git a/3rdparty/osgXR/src/XRState.cpp b/3rdparty/osgXR/src/XRState.cpp index 8c98bbe03..3b931fd8e 100644 --- a/3rdparty/osgXR/src/XRState.cpp +++ b/3rdparty/osgXR/src/XRState.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -32,6 +33,10 @@ #include #include +#ifndef GL_DEPTH32F_STENCIL8 +#define GL_DEPTH32F_STENCIL8 0x8cad +#endif + using namespace osgXR; XRState::XRState(Settings *settings, Manager *manager) : @@ -1310,11 +1315,11 @@ int64_t XRState::chooseRGBAFormat(unsigned int bestRGBBits, thisAlphaBits = 8; goto handleRGBA; // Linear floating point RGB(A) - case GL_RGB16F: + case GL_RGB16F_ARB: thisRGBBits = 16 * 3; thisEncoding = Settings::ENCODING_FLOAT; goto handleRGBA; - case GL_RGBA16F: + case GL_RGBA16F_ARB: thisRGBBits = 16 * 3; thisEncoding = Settings::ENCODING_FLOAT; thisAlphaBits = 16; @@ -1382,7 +1387,7 @@ GLenum XRState::chooseFallbackDepthFormat(unsigned int bestDepthBits, return bestStencilBits ? GL_DEPTH32F_STENCIL8 : GL_DEPTH_COMPONENT32F; else if (bestStencilBits) - return GL_DEPTH24_STENCIL8; + return GL_DEPTH24_STENCIL8_EXT; else if (bestDepthBits > 16) return GL_DEPTH_COMPONENT24; else @@ -1427,7 +1432,7 @@ int64_t XRState::chooseDepthFormat(unsigned int bestDepthBits, thisDepthBits = 24; goto handleDepth; #if 0 // crashes nvidia (495.46, with monado) - case GL_DEPTH24_STENCIL8: + case GL_DEPTH24_STENCIL8_EXT: thisDepthBits = 24; thisStencilBits = 8; goto handleDepth; diff --git a/3rdparty/osgXR/src/osgXR.cpp b/3rdparty/osgXR/src/osgXR.cpp index a31147263..c33c4a8c9 100644 --- a/3rdparty/osgXR/src/osgXR.cpp +++ b/3rdparty/osgXR/src/osgXR.cpp @@ -77,7 +77,7 @@ void osgXR::setupViewerDefaults(osgViewer::Viewer *viewer, settings->setApp(appName, appVersion); settings->setFormFactor(Settings::HEAD_MOUNTED_DISPLAY); - settings->preferEnvBlendMode(Settings::OPAQUE); + settings->preferEnvBlendMode(Settings::BLEND_MODE_OPAQUE); if (unitsPerMeter > 0.0f) settings->setUnitsPerMeter(unitsPerMeter); settings->setVRMode(vrMode);