From 29993a31713451ca7577a4666a77359263513b03 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sun, 7 Jan 2024 19:05:06 +0100 Subject: [PATCH 1/2] Main: Pass - alias compute shader to vertex shader storage as both cannot be active at the same time anyway --- OgreMain/include/OgreGpuProgram.h | 4 +++- OgreMain/include/OgrePass.h | 3 +-- OgreMain/src/OgrePass.cpp | 11 ++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/OgreMain/include/OgreGpuProgram.h b/OgreMain/include/OgreGpuProgram.h index 6a7c23b0b9d..b9a4cb0e05b 100644 --- a/OgreMain/include/OgreGpuProgram.h +++ b/OgreMain/include/OgreGpuProgram.h @@ -55,7 +55,9 @@ namespace Ogre { GPT_COMPUTE_PROGRAM }; enum { - GPT_COUNT = GPT_COMPUTE_PROGRAM + 1 + GPT_COUNT = GPT_COMPUTE_PROGRAM + 1, + /// max programs that can be active in a pipeline (e.g compute is separate) + GPT_PIPELINE_COUNT = GPT_HULL_PROGRAM + 1 }; /** Defines a program which runs on the GPU such as a vertex or fragment program. diff --git a/OgreMain/include/OgrePass.h b/OgreMain/include/OgrePass.h index d9a2d48aaf5..2f1e3c378ae 100644 --- a/OgreMain/include/OgrePass.h +++ b/OgreMain/include/OgrePass.h @@ -220,8 +220,7 @@ namespace Ogre { typedef std::vector ContentTypeLookup; mutable ContentTypeLookup mShadowContentTypeLookup; - /// Vertex program details - std::unique_ptr mProgramUsage[GPT_COUNT]; + std::unique_ptr mProgramUsage[GPT_PIPELINE_COUNT]; /// Number of pass iterations to perform size_t mPassIterationCount; /// Point size, applies when not using per-vertex point size diff --git a/OgreMain/src/OgrePass.cpp b/OgreMain/src/OgrePass.cpp index d83c3d12883..9bf98e35b2a 100644 --- a/OgreMain/src/OgrePass.cpp +++ b/OgreMain/src/OgrePass.cpp @@ -249,7 +249,7 @@ namespace Ogre { mIlluminationStage = oth.mIlluminationStage; mLightMask = oth.mLightMask; - for(int i = 0; i < GPT_COUNT; i++) + for(int i = 0; i < GPT_PIPELINE_COUNT; i++) { auto& programUsage = mProgramUsage[i]; auto& othUsage = oth.mProgramUsage[i]; @@ -882,12 +882,12 @@ namespace Ogre { } std::unique_ptr& Pass::getProgramUsage(GpuProgramType programType) { - return mProgramUsage[programType]; + return mProgramUsage[programType % GPT_PIPELINE_COUNT]; } const std::unique_ptr& Pass::getProgramUsage(GpuProgramType programType) const { - return mProgramUsage[programType]; + return mProgramUsage[programType % GPT_PIPELINE_COUNT]; } bool Pass::hasGpuProgram(GpuProgramType programType) const { @@ -896,8 +896,9 @@ namespace Ogre { const GpuProgramPtr& Pass::getGpuProgram(GpuProgramType programType) const { OGRE_LOCK_MUTEX(mGpuProgramChangeMutex); - OgreAssert(mProgramUsage[programType], "check whether program is available using hasGpuProgram()"); - return mProgramUsage[programType]->getProgram(); + auto programType_ = programType % GPT_PIPELINE_COUNT; + OgreAssert(mProgramUsage[programType_], "check whether program is available using hasGpuProgram()"); + return mProgramUsage[programType_]->getProgram(); } //----------------------------------------------------------------------- const String& Pass::getGpuProgramName(GpuProgramType type) const From 5c732b5feb44d975ff7a211c367170721629e413 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sun, 7 Jan 2024 19:41:15 +0100 Subject: [PATCH 2/2] Overlay: ProfileSessionListener - fix crash in finializeSession --- .../Overlay/src/OgreOverlayProfileSessionListener.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Components/Overlay/src/OgreOverlayProfileSessionListener.cpp b/Components/Overlay/src/OgreOverlayProfileSessionListener.cpp index 8b210c1f0b9..81b94a45609 100644 --- a/Components/Overlay/src/OgreOverlayProfileSessionListener.cpp +++ b/Components/Overlay/src/OgreOverlayProfileSessionListener.cpp @@ -110,11 +110,10 @@ namespace Ogre OverlayContainer* container = dynamic_cast(mProfileGui); if (container) { - for (const auto& p : container->getChildren()) + while (!container->getChildren().empty()) { - OverlayElement* element = p.second; - OverlayContainer* parent = element->getParent(); - if (parent) parent->removeChild(element->getName()); + OverlayElement* element = container->getChildren().cbegin()->second; + container->removeChild(element->getName()); OverlayManager::getSingleton().destroyOverlayElement(element); } }