From da8ca4ec1ac291813a6ce70d3efb8cb15ac2e416 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Sun, 17 Oct 2021 22:26:57 -0300 Subject: [PATCH] [Vulkan] Fix compute shader mixup of Root Layouts --- OgreMain/src/OgreHlmsCompute.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/OgreMain/src/OgreHlmsCompute.cpp b/OgreMain/src/OgreHlmsCompute.cpp index 1948cd38394..c01762ed05a 100644 --- a/OgreMain/src/OgreHlmsCompute.cpp +++ b/OgreMain/src/OgreHlmsCompute.cpp @@ -280,6 +280,22 @@ namespace Ogre Hash hashVal; OGRE_HASH128_FUNC( outString.c_str(), outString.size(), IdString::Seed, &hashVal ); + const RenderSystemCapabilities *capabilities = mRenderSystem->getCapabilities(); + + if( capabilities->hasCapability( RSC_EXPLICIT_API ) ) + { + // If two shaders have the exact same source code but different + // Root Layout, we should treat them differently + RootLayout rootLayout; + memset( &rootLayout, 0, sizeof( rootLayout ) ); + rootLayout.mCompute = true; + job->setupRootLayout( rootLayout ); + + Hash hashValTmp[2] = { hashVal, Hash() }; + OGRE_HASH128_FUNC( &rootLayout, sizeof( rootLayout ), IdString::Seed, &hashValTmp[1] ); + OGRE_HASH128_FUNC( hashValTmp, sizeof( hashValTmp ), IdString::Seed, &hashVal ); + } + CompiledShaderMap::const_iterator itor = mCompiledShaderCache.find( hashVal ); if( itor != mCompiledShaderCache.end() ) {