From 772c94f0bc4488444cd9fff60e69590e278f56da Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Fri, 5 Apr 2024 20:06:50 -0300 Subject: [PATCH 1/9] [Vk] Old Adreno driver workaround was buggy Do not apply Adreno workarounds for the Turnip driver. --- RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp | 4 +++- RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp | 6 ++++++ RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index bc7b82eea54..77c29d4219e 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -737,7 +737,9 @@ namespace Ogre rsc->addShaderProfile( "glslvk" ); rsc->addShaderProfile( "glsl" ); - if( rsc->getVendor() == GPU_QUALCOMM ) + // Turnip is the Mesa driver. + // These workarounds are for the proprietary driver. + if( rsc->getVendor() == GPU_QUALCOMM && rsc->getDeviceName().find( "Turnip" ) == String::npos ) { #ifdef OGRE_VK_WORKAROUND_BAD_3D_BLIT Workarounds::mBad3DBlit = true; diff --git a/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp b/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp index ffdd6bc7cf3..aa57d398afc 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp @@ -86,6 +86,12 @@ namespace Ogre const PixelFormatGpu finalPixelFormat = getWorkaroundedPixelFormat( mPixelFormat ); + // Unfortunately this is necessary, which means the abstraction may leak to the user. + // The pixel format is used in PSO generation, which creates a lot of issues I'm not willing + // to fix just because one old driver is broken. Setting mPixelFormat here fixes all issues so + // far encountered with old Adreno drivers. + mPixelFormat = finalPixelFormat; + VkImageCreateInfo imageInfo; makeVkStruct( imageInfo, VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO ); imageInfo.imageType = getVulkanTextureType(); diff --git a/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp b/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp index fc12fd1b5f4..5ed4ba5644e 100644 --- a/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp +++ b/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp @@ -122,7 +122,8 @@ namespace Ogre #ifdef OGRE_VK_WORKAROUND_ADRENO_UBO64K Workarounds::mAdrenoUbo64kLimitTriggered = false; Workarounds::mAdrenoUbo64kLimit = 0u; - if( renderSystem->getCapabilities()->getVendor() == GPU_QUALCOMM ) + if( renderSystem->getCapabilities()->getVendor() == GPU_QUALCOMM && + renderSystem->getCapabilities()->getDeviceName().find( "Turnip" ) == String::npos ) { mConstBufferMaxSize = std::min( mConstBufferMaxSize, 64u * 1024u - mConstBufferAlignment ); From cb24984a20fe0bba94f990a82a5c54a972c9788a Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Wed, 1 May 2024 15:33:26 -0300 Subject: [PATCH 2/9] [GL3+] Fix leak parsing GLSL shaders (#445) --- .../GL3Plus/include/GLSL/OgreGLSLPreprocessor.h | 10 ++++++++++ .../GL3Plus/src/GLSL/OgreGLSLPreprocessor.cpp | 6 ++++++ RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp | 4 ++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/RenderSystems/GL3Plus/include/GLSL/OgreGLSLPreprocessor.h b/RenderSystems/GL3Plus/include/GLSL/OgreGLSLPreprocessor.h index 9d5c47f6160..a21b7c1b2ba 100644 --- a/RenderSystems/GL3Plus/include/GLSL/OgreGLSLPreprocessor.h +++ b/RenderSystems/GL3Plus/include/GLSL/OgreGLSLPreprocessor.h @@ -521,6 +521,16 @@ namespace Ogre */ char *Parse( const char *iSource, size_t iLength, size_t &oLength ); + /** Parse the input string as a preamble (i.e. to define a lot of enums). + @param iSource + The source text containing preamble macros. + @param iLength + The length of iSource text in characters. + @return + False on errors. True on success. + */ + bool ParsePreamble( const char *iSource, size_t iLength ); + /** * An error handler function type. * The default implementation just drops a note to stderr and diff --git a/RenderSystems/GL3Plus/src/GLSL/OgreGLSLPreprocessor.cpp b/RenderSystems/GL3Plus/src/GLSL/OgreGLSLPreprocessor.cpp index dbcb6845a73..5dbd8c55172 100644 --- a/RenderSystems/GL3Plus/src/GLSL/OgreGLSLPreprocessor.cpp +++ b/RenderSystems/GL3Plus/src/GLSL/OgreGLSLPreprocessor.cpp @@ -1437,4 +1437,10 @@ namespace Ogre return retval.Buffer; } + bool CPreprocessor::ParsePreamble( const char *iSource, size_t iLength ) + { + Token retval = Parse( Token( Token::TK_TEXT, iSource, iLength ) ); + return retval.Type != Token::TK_ERROR; + } + } // namespace Ogre diff --git a/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp b/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp index 8cf99c165de..9fcc5b90c47 100644 --- a/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp +++ b/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp @@ -163,7 +163,6 @@ namespace Ogre replaceVersionMacros(); // Mask out vulkan_layout() macros - size_t unusedVal = 0; const String preamble = "#define vulkan_layout(x)\n" "#define vulkan( x )\n" @@ -180,7 +179,7 @@ namespace Ogre "#define vkSampler2DArray( a, b ) a\n" "#define vkSampler3D( a, b ) a\n" "#define vkSamplerCube( a, b ) a\n"; - cpp.Parse( preamble.c_str(), preamble.size(), unusedVal ); + cpp.ParsePreamble( preamble.c_str(), preamble.size() ); // Pass all user-defined macros to preprocessor if( !mPreprocessorDefines.empty() ) @@ -240,6 +239,7 @@ namespace Ogre const char *src = mSource.c_str(); size_t src_len = mSource.size(); char *out = cpp.Parse( src, src_len, out_size ); + if( !out || !out_size ) { mCompileError = true; From e1b25f323e128bf990b6b8e78633b2e8e20aeb8a Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Wed, 1 May 2024 15:33:26 -0300 Subject: [PATCH 3/9] [GL3+] Fix leak parsing GLSL shaders (#445) --- .../GL3Plus/include/GLSL/OgreGLSLPreprocessor.h | 10 ++++++++++ .../GL3Plus/src/GLSL/OgreGLSLPreprocessor.cpp | 8 +++++++- RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp | 3 +-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/RenderSystems/GL3Plus/include/GLSL/OgreGLSLPreprocessor.h b/RenderSystems/GL3Plus/include/GLSL/OgreGLSLPreprocessor.h index 0814cefa571..0237c6b879e 100644 --- a/RenderSystems/GL3Plus/include/GLSL/OgreGLSLPreprocessor.h +++ b/RenderSystems/GL3Plus/include/GLSL/OgreGLSLPreprocessor.h @@ -508,6 +508,16 @@ namespace Ogre { */ char *Parse (const char *iSource, size_t iLength, size_t &oLength); + /** Parse the input string as a preamble (i.e. to define a lot of enums). + @param iSource + The source text containing preamble macros. + @param iLength + The length of iSource text in characters. + @return + False on errors. True on success. + */ + bool ParsePreamble( const char *iSource, size_t iLength ); + /** * An error handler function type. * The default implementation just drops a note to stderr and diff --git a/RenderSystems/GL3Plus/src/GLSL/OgreGLSLPreprocessor.cpp b/RenderSystems/GL3Plus/src/GLSL/OgreGLSLPreprocessor.cpp index 4189b949faa..0377096eb59 100644 --- a/RenderSystems/GL3Plus/src/GLSL/OgreGLSLPreprocessor.cpp +++ b/RenderSystems/GL3Plus/src/GLSL/OgreGLSLPreprocessor.cpp @@ -1442,4 +1442,10 @@ namespace Ogre { return retval.Buffer; } -} // namespace Ogre + bool CPreprocessor::ParsePreamble( const char *iSource, size_t iLength ) + { + Token retval = Parse( Token( Token::TK_TEXT, iSource, iLength ) ); + return retval.Type != Token::TK_ERROR; + } + +} // namespace Ogre diff --git a/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp b/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp index f87ac651022..a484bc474e6 100644 --- a/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp +++ b/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp @@ -167,7 +167,6 @@ namespace Ogre { replaceVersionMacros(); // Mask out vulkan_layout() macros - size_t unusedVal = 0; const String preamble = "#define vulkan_layout(x)\n" "#define vulkan( x )\n" @@ -184,7 +183,7 @@ namespace Ogre { "#define vkSampler2DArray( a, b ) a\n" "#define vkSampler3D( a, b ) a\n" "#define vkSamplerCube( a, b ) a\n"; - cpp.Parse( preamble.c_str(), preamble.size(), unusedVal ); + cpp.ParsePreamble( preamble.c_str(), preamble.size() ); // Pass all user-defined macros to preprocessor if (!mPreprocessorDefines.empty ()) From 7f4981161c7934d145f574c58988e867bea8fe54 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Wed, 1 May 2024 15:41:20 -0300 Subject: [PATCH 4/9] [D3D11] Fix leak on shutdown (#445) --- RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp b/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp index 9ba71046f8a..ea5917ab4f7 100644 --- a/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp +++ b/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp @@ -898,6 +898,7 @@ namespace Ogre SAFE_DELETE( mDriverList ); mActiveD3DDriver = D3D11Driver(); mDevice.ReleaseAll(); + SAFE_DELETE( mVendorExtension ); LogManager::getSingleton().logMessage("D3D11: Shutting down cleanly."); SAFE_DELETE( mHardwareBufferManager ); SAFE_DELETE( mGpuProgramManager ); From 5d5112021ace97ec09f508289df92c403c9aa3aa Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Sun, 5 May 2024 12:34:50 -0300 Subject: [PATCH 5/9] Fix broken link --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cfa92f219ae..50ebae79c3f 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,8 @@ pacman -S freeimage freetype2 libxaw libxrandr mesa zziplib cmake gcc We provide quick download-build scripts under the [Scripts/BuildScripts/output](Scripts/BuildScripts/output) folder. -You can download all of these scripts [as a compressed 7zip file](https://bintray.com/darksylinc/ogre-next/download_file?file_path=build_ogre_scripts-master.7z) +You can download all of these scripts [as a compressed 7zip file](https://github.com/OGRECave/ogre-next/releases/download/bin-releases/build_ogre_scripts-master.7z). +We also have an archive if you're looking for [scripts to build older versions](https://github.com/OGRECave/ogre-next/releases/bin-releases/). If you're on Linux, make sure to first install the dependencies (i.e. run the sudo apt-get above) From 08e9d74994681a6f04ea6f3cb2a44aeae23670f2 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Sun, 12 May 2024 21:06:30 -0300 Subject: [PATCH 6/9] Fix doc typo --- .../Vulkan/include/Windowing/Android/OgreVulkanAndroidWindow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RenderSystems/Vulkan/include/Windowing/Android/OgreVulkanAndroidWindow.h b/RenderSystems/Vulkan/include/Windowing/Android/OgreVulkanAndroidWindow.h index c4dac6f8b6f..37b6c76dd08 100644 --- a/RenderSystems/Vulkan/include/Windowing/Android/OgreVulkanAndroidWindow.h +++ b/RenderSystems/Vulkan/include/Windowing/Android/OgreVulkanAndroidWindow.h @@ -82,7 +82,7 @@ namespace Ogre /// While this sounds convenient, beware that Swappy will often downgrade vSyncInterval /// until it finds something that can be met & sustained. /// That means if your game runs between 40fps and 60fps on a 60hz screen, after some time - /// swappy will downgrade vSyncInterval to 2 so that the game render at perfect 30fps. + /// Swappy will downgrade vSyncInterval to 2 so that the game renders at perfect 30fps. /// /// This may result in a better experience considering framerates jump a lot due to /// thermal throttling on phones. But it may also cause undesired or unexplainable From 734663d5f6d07e6f374acf675f6737aa30828719 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Tue, 11 Jun 2024 19:58:40 -0300 Subject: [PATCH 7/9] Dump debug shader output if shader was cached Fix by user bishopnator https://forums.ogre3d.org/viewtopic.php?t=97263 --- OgreMain/src/OgreHlms.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OgreMain/src/OgreHlms.cpp b/OgreMain/src/OgreHlms.cpp index c209413f298..c544f79c202 100644 --- a/OgreMain/src/OgreHlms.cpp +++ b/OgreMain/src/OgreHlms.cpp @@ -2148,6 +2148,12 @@ namespace Ogre codeCache.shaders[i] = compileShaderCode( source[i], "", finalHash, static_cast( i ) ); + + if( mDebugOutput ) + { + debugDumpFile.write( source[i].c_str(), + static_cast( source[i].size() ) ); + } } } From 6f1b0d0ffda59bd116b0d7654cffcf3891058108 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Wed, 12 Jun 2024 11:27:23 -0300 Subject: [PATCH 8/9] Fix doc typo Thanks user bishopnator for spotting it --- Docs/src/manual/Ogre3.0.Changes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Docs/src/manual/Ogre3.0.Changes.md b/Docs/src/manual/Ogre3.0.Changes.md index 811f2d8a909..6a467468ad0 100644 --- a/Docs/src/manual/Ogre3.0.Changes.md +++ b/Docs/src/manual/Ogre3.0.Changes.md @@ -18,13 +18,13 @@ When enabled, the project names will be `OgreNext` instead of `Ogre`. e.g. the f | Old Name | New Name | |----------------------------|--------------------------------| -| OgreMain.dll | OgreMain.dll | +| OgreMain.dll | OgreNextMain.dll | | OgreHlmsPbs.dll | OgreNextHlmsPbs.dll | | OgreHlmsUnlit.dll | OgreNextHlmsUnlit.dll | | OgreMeshLodGenerator.dll | OgreNextMeshLodGenerator.dll | | OgreOverlay.dll | OgreNextOverlay.dll | | OgreSceneFormat.dll | OgreNextSceneFormat.dll | -| libOgreMain.so | libOgreMain.so | +| libOgreMain.so | libOgreNextMain.so | | libOgreHlmsPbs.so | libOgreNextHlmsPbs.so | | libOgreHlmsUnlit.so | libOgreNextHlmsUnlit.so | | libOgreMeshLodGenerator.so | libOgreNextMeshLodGenerator.so | From 3b711b42046b9391036fd693c9ba317b188860c0 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Mon, 17 Jun 2024 18:12:36 -0300 Subject: [PATCH 9/9] Fix Terra crash when building w/ specific CMake variable Terra was crashing if OGRE_CONFIG_ENABLE_FINE_LIGHT_MASK_GRANULARITY was enabled. --- .../Media/Hlms/Terra/Any/500.Structs_piece_vs_piece_ps.any | 1 + Samples/Media/Hlms/Terra/Any/800.VertexShader_piece_vs.any | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Samples/Media/Hlms/Terra/Any/500.Structs_piece_vs_piece_ps.any b/Samples/Media/Hlms/Terra/Any/500.Structs_piece_vs_piece_ps.any index ea4e6717ae9..b270cb1de25 100644 --- a/Samples/Media/Hlms/Terra/Any/500.Structs_piece_vs_piece_ps.any +++ b/Samples/Media/Hlms/Terra/Any/500.Structs_piece_vs_piece_ps.any @@ -96,6 +96,7 @@ struct CellData @undefpiece( DeclareObjLightMask ) @property( hlms_fine_light_mask || hlms_forwardplus_fine_light_mask ) + // Currently unimplemented (also makes little sense since there's nothing fine granularity to do). @property( syntax == metal ) @piece( DeclareObjLightMask )uint objLightMask = 0xFFFFFFFFu;@end @else diff --git a/Samples/Media/Hlms/Terra/Any/800.VertexShader_piece_vs.any b/Samples/Media/Hlms/Terra/Any/800.VertexShader_piece_vs.any index 383e6e688f6..85d127d247f 100644 --- a/Samples/Media/Hlms/Terra/Any/800.VertexShader_piece_vs.any +++ b/Samples/Media/Hlms/Terra/Any/800.VertexShader_piece_vs.any @@ -136,11 +136,14 @@ @property( syntax == metal || lower_gpu_overhead ) @property( hlms_fine_light_mask || hlms_forwardplus_fine_light_mask ) - outVs.objLightMask = worldMaterialIdx[inVs_drawId].z; + // Currently unimplemented (also makes little sense since there's nothing fine granularity to do). + outVs.objLightMask = 0xFFFFFFFF; + // outVs.objLightMask = worldMaterialIdx[inVs_drawId].z; @end @property( use_planar_reflections ) - outVs.planarReflectionIdx = (ushort)(worldMaterialIdx[inVs_drawId].w); + #error "Unimplemented Feature: Using Terra as Planar Reflections" + // outVs.planarReflectionIdx = (ushort)(worldMaterialIdx[inVs_drawId].w); @end @else @property( (!hlms_shadowcaster || alpha_test) && !lower_gpu_overhead )