Skip to content

Commit

Permalink
fix(cp2077): only use layout slot 14
Browse files Browse the repository at this point in the history
  • Loading branch information
clshortfuse committed Mar 19, 2024
1 parent 66c07ec commit 76d3d0c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/common/shaderReplaceMod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace ShaderReplaceMod {

static float* _shaderInjection = nullptr;
static size_t _shaderInjectionSize = 0;
static int32_t expectedLayoutInjectionIndex = -1;

static CustomShaders* _customShaders = nullptr;

Expand Down Expand Up @@ -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("
Expand All @@ -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];
Expand Down
2 changes: 2 additions & 0 deletions src/cp2077/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 76d3d0c

Please sign in to comment.