From 231d60995b1841dd9cd0914f24090327116fd8a8 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Mon, 1 Aug 2022 11:34:43 +0200 Subject: [PATCH] \#5534 remove OSG 3.4 support and require at least 3.6.5 support --- CMakeLists.txt | 5 +- apps/opencs/view/render/scenewidget.cpp | 11 -- apps/openmw/engine.cpp | 2 - apps/openmw/mwgui/loadingscreen.cpp | 6 - apps/openmw/mwrender/skyutil.cpp | 7 - appveyor.yml | 70 ---------- components/sceneutil/lightmanager.cpp | 173 +++++++++++------------- components/sdlutil/sdlcursormanager.cpp | 9 +- 8 files changed, 84 insertions(+), 199 deletions(-) delete mode 100644 appveyor.yml diff --git a/CMakeLists.txt b/CMakeLists.txt index 549e5d6c34..ccfb50658f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -407,10 +407,7 @@ if(NOT HAVE_STDINT_H) endif() if(OPENMW_USE_SYSTEM_OSG) - find_package(OpenSceneGraph 3.4.0 REQUIRED ${USED_OSG_COMPONENTS}) - if (${OPENSCENEGRAPH_VERSION} VERSION_GREATER 3.6.2 AND ${OPENSCENEGRAPH_VERSION} VERSION_LESS 3.6.5) - message(FATAL_ERROR "OpenSceneGraph version ${OPENSCENEGRAPH_VERSION} has critical regressions which cause crashes. Please upgrade to 3.6.5 or later. We strongly recommend using the tip of the official 'OpenSceneGraph-3.6' branch or the tip of '3.6' OpenMW/osg (OSGoS).") - endif() + find_package(OpenSceneGraph 3.6.5 REQUIRED ${USED_OSG_COMPONENTS}) if(OSG_STATIC) find_package(OSGPlugins REQUIRED COMPONENTS ${USED_OSG_PLUGINS}) diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 578723ccd8..5d875f4829 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -97,14 +96,6 @@ RenderWidget::~RenderWidget() try { CompositeViewer::get().removeView(mView); - -#if OSG_VERSION_LESS_THAN(3,6,5) - // before OSG 3.6.4, the default font was a static object, and if it wasn't attached to the scene when a graphics context was destroyed, it's program wouldn't be released. - // 3.6.4 moved it into the object cache, which meant it usually got released, but not here. - // 3.6.5 improved cleanup with osgViewer::CompositeViewer::removeView so it more reliably released associated state for objects in the object cache. - osg::ref_ptr graphicsContext = mView->getCamera()->getGraphicsContext(); - osgText::Font::getDefaultFont()->releaseGLObjects(graphicsContext->getState()); -#endif } catch(const std::exception& e) { @@ -146,9 +137,7 @@ CompositeViewer::CompositeViewer() // https://gitlab.com/OpenMW/openmw/-/issues/5481 setThreadingModel(osgViewer::ViewerBase::SingleThreaded); -#if OSG_VERSION_GREATER_OR_EQUAL(3,5,5) setUseConfigureAffinity(false); -#endif // disable the default setting of viewer.done() by pressing Escape. setKeyEventSetsDone(0); diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index bb20451474..53a27ebd9b 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -1032,10 +1032,8 @@ void OMW::Engine::go() mViewer = new osgViewer::Viewer; mViewer->setReleaseContextAtEndOfFrameHint(false); -#if OSG_VERSION_GREATER_OR_EQUAL(3,5,5) // Do not try to outsmart the OS thread scheduler (see bug #4785). mViewer->setUseConfigureAffinity(false); -#endif mEnvironment.setFrameRateLimit(Settings::Manager::getFloat("framerate limit", "Video")); diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 61eca3d1d0..e52b1b24ba 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -1,12 +1,10 @@ #include "loadingscreen.hpp" #include -#include #include #include -#include #include #include @@ -305,12 +303,8 @@ namespace MWGui mCopyFramebufferToTextureCallback = new CopyFramebufferToTextureCallback(mTexture); } -#if OSG_VERSION_GREATER_OR_EQUAL(3, 5, 10) mViewer->getCamera()->removeInitialDrawCallback(mCopyFramebufferToTextureCallback); mViewer->getCamera()->addInitialDrawCallback(mCopyFramebufferToTextureCallback); -#else - mViewer->getCamera()->setInitialDrawCallback(mCopyFramebufferToTextureCallback); -#endif mCopyFramebufferToTextureCallback->reset(); mSplashImage->setBackgroundImage(""); diff --git a/apps/openmw/mwrender/skyutil.cpp b/apps/openmw/mwrender/skyutil.cpp index 29a82f7eb0..3c2cd1c6e9 100644 --- a/apps/openmw/mwrender/skyutil.cpp +++ b/apps/openmw/mwrender/skyutil.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -855,12 +854,8 @@ namespace MWRender osg::ref_ptr oqn = new osg::OcclusionQueryNode; oqn->setQueriesEnabled(true); -#if OSG_VERSION_GREATER_OR_EQUAL(3, 6, 5) // With OSG 3.6.5, the method of providing user defined query geometry has been completely replaced osg::ref_ptr queryGeom = new osg::QueryGeometry(oqn->getName()); -#else - osg::ref_ptr queryGeom = oqn->getQueryGeometry(); -#endif // Make it fast! A DYNAMIC query geometry means we can't break frame until the flare is rendered (which is rendered after all the other geometry, // so that would be pretty bad). STATIC should be safe, since our node's local bounds are static, thus computeBounds() which modifies the queryGeometry @@ -881,9 +876,7 @@ namespace MWRender // Still need a proper bounding sphere. oqn->setInitialBound(queryGeom->getBound()); -#if OSG_VERSION_GREATER_OR_EQUAL(3, 6, 5) oqn->setQueryGeometry(queryGeom.release()); -#endif osg::StateSet* queryStateSet = new osg::StateSet; if (queryVisible) diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 95f070a662..0000000000 --- a/appveyor.yml +++ /dev/null @@ -1,70 +0,0 @@ -version: "{build}" - -branches: - only: - - master - - /openmw-.*$/ - - appveyor - -environment: - matrix: - - msvc: 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - - msvc: 2019 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - -platform: - - x64 - -configuration: -# - Debug - - Release -# - RelWithDebInfo - -# We want the git revision for versioning, -# so shallow clones don't work. -clone_depth: 1 - -cache: - - C:\projects\openmw\deps\Bullet-2.89-msvc2017-win64-double.7z - - C:\projects\openmw\deps\MyGUI-3.4.1-msvc2017-win64.7z - - C:\projects\openmw\deps\MyGUI-3.4.1-msvc2019-win64.7z - - C:\projects\openmw\deps\OSGoS-3.6.5-b02abe2-msvc2017-win64.7z - - C:\projects\openmw\deps\OSGoS-3.6.5-b02abe2-msvc2019-win64.7z - - C:\projects\openmw\deps\ffmpeg-4.2.2-dev-win64.zip - - C:\projects\openmw\deps\ffmpeg-4.2.2-win64.zip - - C:\projects\openmw\deps\OpenAL-Soft-1.20.1.zip - - C:\projects\openmw\deps\SDL2-2.0.18.zip - -clone_folder: C:\projects\openmw - -install: - - set PATH=C:\Program Files\Git\mingw64\bin;%PATH% - -before_build: - - cmd: git submodule update --init --recursive - - cmd: sh %APPVEYOR_BUILD_FOLDER%\CI\before_script.msvc.sh -c %configuration% -p %PLATFORM% -v %msvc% -V -i %APPVEYOR_BUILD_FOLDER%\install - -build_script: - - cmd: if %PLATFORM%==x64 set build=MSVC%msvc%_64 - - cmd: msbuild %build%\OpenMW.sln /t:Build /p:Configuration=%configuration% /m:2 /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - cmd: cmake --install %build% --config %configuration% - -after_build: - - cmd: if %PLATFORM%==x64 7z a OpenMW_MSVC%msvc%_%platform%_%appveyor_pull_request_number%_%appveyor_pull_request_head_commit%.zip %APPVEYOR_BUILD_FOLDER%\install -xr"!*.pdb" - #- cmd: if %PLATFORM%==x64 7z a OpenMW_MSVC%msvc%_%platform%_%appveyor_pull_request_number%_%appveyor_pull_request_head_commit%_pdb.zip %APPVEYOR_BUILD_FOLDER%\MSVC%msvc%_64\%configuration%\*.pdb - -test: off - -#notifications: -# - provider: Email -# to: -# - -# on_build_failure: true -# on_build_status_changed: true - -artifacts: - - path: OpenMW_MSVC%msvc%_%platform%_%appveyor_pull_request_number%_%appveyor_pull_request_head_commit%.zip - name: OpenMW_MSVC%msvc%_%platform%_%appveyor_pull_request_number%_%appveyor_pull_request_head_commit% - #- path: OpenMW_MSVC%msvc%_%platform%_%appveyor_pull_request_number%_%appveyor_pull_request_head_commit%_pdb.zip - # name: OpenMW_MSVC%msvc%_%platform%_%appveyor_pull_request_number%_%appveyor_pull_request_head_commit%_pdb diff --git a/components/sceneutil/lightmanager.cpp b/components/sceneutil/lightmanager.cpp index e24cdcf6f3..12aefe4c52 100644 --- a/components/sceneutil/lightmanager.cpp +++ b/components/sceneutil/lightmanager.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -77,9 +76,9 @@ namespace SceneUtil namespace { const std::unordered_map lightingMethodSettingMap = { - {"legacy", LightingMethod::FFP}, - {"shaders compatibility", LightingMethod::PerObjectUniform}, - {"shaders", LightingMethod::SingleUBO}, + {"legacy", LightingMethod::FFP}, + {"shaders compatibility", LightingMethod::PerObjectUniform}, + {"shaders", LightingMethod::SingleUBO}, }; } @@ -101,10 +100,10 @@ namespace SceneUtil }; LightBuffer(int count) - : mData(new osg::FloatArray(3*4*count)) - , mEndian(osg::getCpuByteOrder()) - , mCount(count) - , mCachedSunPos(osg::Vec4()) + : mData(new osg::FloatArray(3*4*count)) + , mEndian(osg::getCpuByteOrder()) + , mCount(count) + , mCachedSunPos(osg::Vec4()) { } @@ -199,40 +198,40 @@ namespace SceneUtil private: class Offsets { - public: - Offsets() + public: + Offsets() : mStride(12) - { - mValues[Diffuse] = 0; - mValues[Ambient] = 1; - mValues[Specular] = 2; - mValues[DiffuseSign] = 3; - mValues[Position] = 4; - mValues[AttenuationRadius] = 8; - } + { + mValues[Diffuse] = 0; + mValues[Ambient] = 1; + mValues[Specular] = 2; + mValues[DiffuseSign] = 3; + mValues[Position] = 4; + mValues[AttenuationRadius] = 8; + } - Offsets(int offsetColors, int offsetPosition, int offsetAttenuationRadius, int stride) + Offsets(int offsetColors, int offsetPosition, int offsetAttenuationRadius, int stride) : mStride((offsetAttenuationRadius + sizeof(GLfloat) * osg::Vec4::num_components + stride) / 4) - { - constexpr auto sizeofFloat = sizeof(GLfloat); - const auto diffuseOffset = offsetColors / sizeofFloat; + { + constexpr auto sizeofFloat = sizeof(GLfloat); + const auto diffuseOffset = offsetColors / sizeofFloat; - mValues[Diffuse] = diffuseOffset; - mValues[Ambient] = diffuseOffset + 1; - mValues[Specular] = diffuseOffset + 2; - mValues[DiffuseSign] = diffuseOffset + 3; - mValues[Position] = offsetPosition / sizeofFloat; - mValues[AttenuationRadius] = offsetAttenuationRadius / sizeofFloat; - } + mValues[Diffuse] = diffuseOffset; + mValues[Ambient] = diffuseOffset + 1; + mValues[Specular] = diffuseOffset + 2; + mValues[DiffuseSign] = diffuseOffset + 3; + mValues[Position] = offsetPosition / sizeofFloat; + mValues[AttenuationRadius] = offsetAttenuationRadius / sizeofFloat; + } - int get(int index, LayoutOffset slot) const - { - return mStride * index + mValues[slot]; - } + int get(int index, LayoutOffset slot) const + { + return mStride * index + mValues[slot]; + } - private: - int mStride; - std::array mValues; + private: + int mStride; + std::array mValues; }; void configureLayout(const Offsets& offsets, int size) @@ -276,11 +275,11 @@ namespace SceneUtil auto method = lightManager->getLightingMethod(); switch (method) { - case LightingMethod::FFP: + case LightingMethod::FFP: { break; } - case LightingMethod::PerObjectUniform: + case LightingMethod::PerObjectUniform: { osg::Matrixf lightMat; configurePosition(lightMat, light->getPosition()); @@ -291,7 +290,7 @@ namespace SceneUtil stateset->addUniform(lightManager->generateLightBufferUniform(lightMat), mode); break; } - case LightingMethod::SingleUBO: + case LightingMethod::SingleUBO: { osg::ref_ptr buffer = new LightBuffer(lightManager->getMaxLightsInScene()); @@ -302,11 +301,7 @@ namespace SceneUtil osg::ref_ptr ubo = new osg::UniformBufferObject; buffer->getData()->setBufferObject(ubo); -#if OSG_VERSION_GREATER_OR_EQUAL(3,5,7) osg::ref_ptr ubb = new osg::UniformBufferBinding(static_cast(Resource::SceneManager::UBOBinding::LightBuffer), buffer->getData(), 0, buffer->getData()->getTotalDataSize()); -#else - osg::ref_ptr ubb = new osg::UniformBufferBinding(static_cast(Resource::SceneManager::UBOBinding::LightBuffer), ubo, 0, buffer->getData()->getTotalDataSize()); -#endif stateset->setAttributeAndModes(ubb, mode); break; @@ -321,7 +316,7 @@ namespace SceneUtil DisableLight(int index) : mIndex(index) {} DisableLight(const DisableLight& copy,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) - : osg::StateAttribute(copy,copyop), mIndex(copy.mIndex) {} + : osg::StateAttribute(copy,copyop), mIndex(copy.mIndex) {} META_StateAttribute(SceneUtil, DisableLight, osg::StateAttribute::LIGHT) @@ -364,7 +359,7 @@ namespace SceneUtil FFPLightStateAttribute(size_t index, const std::vector>& lights) : mIndex(index), mLights(lights) {} FFPLightStateAttribute(const FFPLightStateAttribute& copy,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) - : osg::StateAttribute(copy,copyop), mIndex(copy.mIndex), mLights(copy.mLights) {} + : osg::StateAttribute(copy,copyop), mIndex(copy.mIndex), mLights(copy.mLights) {} unsigned int getMember() const override { @@ -562,11 +557,11 @@ namespace SceneUtil { public: CollectLightCallback() - : mLightManager(nullptr) { } + : mLightManager(nullptr) { } CollectLightCallback(const CollectLightCallback& copy, const osg::CopyOp& copyop) - : NodeCallback(copy, copyop) - , mLightManager(nullptr) { } + : NodeCallback(copy, copyop) + , mLightManager(nullptr) { } META_Object(SceneUtil, CollectLightCallback) @@ -614,11 +609,7 @@ namespace SceneUtil for (size_t i = 0; i < mStateSet.size(); ++i) { auto& buffer = lightManager->getUBOManager()->getLightBuffer(i); -#if OSG_VERSION_GREATER_OR_EQUAL(3,5,7) osg::ref_ptr ubb = new osg::UniformBufferBinding(static_cast(Resource::SceneManager::UBOBinding::LightBuffer), buffer->getData(), 0, buffer->getData()->getTotalDataSize()); -#else - osg::ref_ptr ubb = new osg::UniformBufferBinding(static_cast(Resource::SceneManager::UBOBinding::LightBuffer), buffer->getData()->getBufferObject(), 0, buffer->getData()->getTotalDataSize()); -#endif mStateSet[i]->setAttributeAndModes(ubb, osg::StateAttribute::ON); } } @@ -667,10 +658,10 @@ namespace SceneUtil }; UBOManager::UBOManager(int lightCount) - : mDummyProgram(new osg::Program) - , mInitLayout(false) - , mDirty({ true, true }) - , mTemplate(new LightBuffer(lightCount)) + : mDummyProgram(new osg::Program) + , mInitLayout(false) + , mDirty({ true, true }) + , mTemplate(new LightBuffer(lightCount)) { static const std::string dummyVertSource = generateDummyShader(lightCount); @@ -768,9 +759,9 @@ namespace SceneUtil ext->glGetActiveUniformsiv(handle, index.size(), index.data(), GL_UNIFORM_ARRAY_STRIDE, &stride); std::array names = { - "LightBuffer[0].packedColors", - "LightBuffer[0].position", - "LightBuffer[0].attenuation", + "LightBuffer[0].packedColors", + "LightBuffer[0].position", + "LightBuffer[0].attenuation", }; std::vector indices(names.size()); std::vector offsets(names.size()); @@ -801,12 +792,12 @@ namespace SceneUtil } LightManager::LightManager(bool ffp) - : mStartLight(0) - , mLightingMask(~0u) - , mSun(nullptr) - , mPointLightRadiusMultiplier(1.f) - , mPointLightFadeEnd(0.f) - , mPointLightFadeStart(0.f) + : mStartLight(0) + , mLightingMask(~0u) + , mSun(nullptr) + , mPointLightRadiusMultiplier(1.f) + , mPointLightFadeEnd(0.f) + , mPointLightFadeStart(0.f) { osg::GLExtensions* exts = osg::GLExtensions::Get(0, false); bool supportsUBO = exts && exts->isUniformBufferObjectSupported; @@ -854,16 +845,16 @@ namespace SceneUtil } LightManager::LightManager(const LightManager ©, const osg::CopyOp ©op) - : osg::Group(copy, copyop) - , mStartLight(copy.mStartLight) - , mLightingMask(copy.mLightingMask) - , mSun(copy.mSun) - , mLightingMethod(copy.mLightingMethod) - , mPointLightRadiusMultiplier(copy.mPointLightRadiusMultiplier) - , mPointLightFadeEnd(copy.mPointLightFadeEnd) - , mPointLightFadeStart(copy.mPointLightFadeStart) - , mMaxLights(copy.mMaxLights) - , mPPLightBuffer(copy.mPPLightBuffer) + : osg::Group(copy, copyop) + , mStartLight(copy.mStartLight) + , mLightingMask(copy.mLightingMask) + , mSun(copy.mSun) + , mLightingMethod(copy.mLightingMethod) + , mPointLightRadiusMultiplier(copy.mPointLightRadiusMultiplier) + , mPointLightFadeEnd(copy.mPointLightFadeEnd) + , mPointLightFadeStart(copy.mPointLightFadeStart) + , mMaxLights(copy.mMaxLights) + , mPPLightBuffer(copy.mPPLightBuffer) { } @@ -980,15 +971,15 @@ namespace SceneUtil mLightingMethod = method; switch (method) { - case LightingMethod::FFP: - mStateSetGenerator = std::make_unique(); - break; - case LightingMethod::SingleUBO: - mStateSetGenerator = std::make_unique(); - break; - case LightingMethod::PerObjectUniform: - mStateSetGenerator = std::make_unique(); - break; + case LightingMethod::FFP: + mStateSetGenerator = std::make_unique(); + break; + case LightingMethod::SingleUBO: + mStateSetGenerator = std::make_unique(); + break; + case LightingMethod::PerObjectUniform: + mStateSetGenerator = std::make_unique(); + break; } mStateSetGenerator->mLightManager = this; } @@ -1219,19 +1210,19 @@ namespace SceneUtil } LightSource::LightSource() - : mRadius(0.f) - , mActorFade(1.f) - , mLastAppliedFrame(0) + : mRadius(0.f) + , mActorFade(1.f) + , mLastAppliedFrame(0) { setUpdateCallback(new CollectLightCallback); mId = sLightId++; } LightSource::LightSource(const LightSource ©, const osg::CopyOp ©op) - : osg::Node(copy, copyop) - , mRadius(copy.mRadius) - , mActorFade(copy.mActorFade) - , mLastAppliedFrame(copy.mLastAppliedFrame) + : osg::Node(copy, copyop) + , mRadius(copy.mRadius) + , mActorFade(copy.mActorFade) + , mLastAppliedFrame(copy.mLastAppliedFrame) { mId = sLightId++; diff --git a/components/sdlutil/sdlcursormanager.cpp b/components/sdlutil/sdlcursormanager.cpp index 626930291d..de48f4ce68 100644 --- a/components/sdlutil/sdlcursormanager.cpp +++ b/components/sdlutil/sdlcursormanager.cpp @@ -1,6 +1,5 @@ #include "sdlcursormanager.hpp" -#include #include #include @@ -13,14 +12,13 @@ #include #include #include -#include #include #include #include "imagetosurface.hpp" -#if defined(OSG_LIBRARY_STATIC) && (!defined(ANDROID) || OSG_VERSION_GREATER_THAN(3, 6, 5)) +#if defined(OSG_LIBRARY_STATIC) && !defined(ANDROID) // Sets the default windowing system interface according to the OS. // Necessary for OpenSceneGraph to do some things, like decompression. USE_GRAPHICSWINDOW() @@ -28,12 +26,7 @@ USE_GRAPHICSWINDOW() namespace CursorDecompression { - // macOS builds use the OSG fork that includes DXTC commit - #if OSG_VERSION_GREATER_OR_EQUAL(3, 5, 8) || defined(__APPLE__) static const bool DXTCSupported = true; - #else - static const bool DXTCSupported = false; - #endif class MyGraphicsContext { public: