From 76d3d0c581029e1dd22dc46566a8a99a8b2de390 Mon Sep 17 00:00:00 2001 From: Carlos Lopez Date: Tue, 19 Mar 2024 14:24:14 -0400 Subject: [PATCH] fix(cp2077): only use layout slot 14 --- src/common/shaderReplaceMod.hpp | 16 ++++++++++++++++ src/cp2077/addon.cpp | 2 ++ 2 files changed, 18 insertions(+) diff --git a/src/common/shaderReplaceMod.hpp b/src/common/shaderReplaceMod.hpp index c0b777ae..e204cb36 100644 --- a/src/common/shaderReplaceMod.hpp +++ b/src/common/shaderReplaceMod.hpp @@ -39,6 +39,7 @@ namespace ShaderReplaceMod { static float* _shaderInjection = nullptr; static size_t _shaderInjectionSize = 0; + static int32_t expectedLayoutInjectionIndex = -1; static CustomShaders* _customShaders = nullptr; @@ -143,6 +144,17 @@ namespace ShaderReplaceMod { } } + + if (expectedLayoutInjectionIndex != -1 && cbvIndex != expectedLayoutInjectionIndex) { + std::stringstream s; + s << "on_create_pipeline_layout(" + << "Pipeline layout index mismatch, actual: " << cbvIndex + << ", expected: " << expectedLayoutInjectionIndex + << ")"; + reshade::log_message(reshade::log_level::debug, s.str().c_str()); + return false; + } + if (pcCount != 0) { std::stringstream s; s << "on_create_pipeline_layout(" @@ -153,6 +165,10 @@ namespace ShaderReplaceMod { return false; } + + + + uint32_t oldCount = param_count; uint32_t newCount = oldCount + 1; reshade::api::pipeline_layout_param* newParams = new reshade::api::pipeline_layout_param[newCount]; diff --git a/src/cp2077/addon.cpp b/src/cp2077/addon.cpp index 65f7c8d9..5eb03188 100644 --- a/src/cp2077/addon.cpp +++ b/src/cp2077/addon.cpp @@ -278,6 +278,8 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID) { switch (fdwReason) { case DLL_PROCESS_ATTACH: if (!reshade::register_addon(hModule)) return FALSE; + + ShaderReplaceMod::expectedLayoutInjectionIndex = 14; break; case DLL_PROCESS_DETACH: reshade::unregister_addon(hModule);