From fa2085860dd8e8e93223de8e2f054d196d1cf761 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 17 Jan 2025 15:43:51 +0000 Subject: [PATCH] Always prioritise loading a new d3dcompiler over re-using an old one * Previously when replaying we'd always use our d3dcompiler_47.dll that we ship, but during capture we would always prioritise re-using an existing d3dcompiler that the process already had. * Since it should be safe to have multiple (differently named) d3dcompiler's in the same process and we want to avoid using an old out of date d3dcompiler if possible, we prioritise loading a new d3dcompiler_47.dll over re-using an existing in-process d3dcompiler_43.dll --- .../driver/shaders/dxbc/dxbc_compile.cpp | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/renderdoc/driver/shaders/dxbc/dxbc_compile.cpp b/renderdoc/driver/shaders/dxbc/dxbc_compile.cpp index a7c9d4719..b63cb2c75 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_compile.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_compile.cpp @@ -58,20 +58,19 @@ HMODULE GetD3DCompiler() "d3dcompiler_44.dll", "d3dcompiler_43.dll", }; - for(int i = 0; i < 2; i++) + for(int d = 0; d < ARRAY_COUNT(dlls); d++) { - for(int d = 0; d < ARRAY_COUNT(dlls); d++) - { - // first time around, try to load one that already exists. Second time around try to load it - // in the default search path. - if(i == 0) - ret = GetModuleHandleA(dlls[d]); - else - ret = LoadLibraryA(dlls[d]); + // first attempt try to load one that already exists. Second time around try to load it + // in the default search path. + ret = GetModuleHandleA(dlls[d]); - if(ret != NULL) - return ret; - } + if(ret != NULL) + return ret; + + ret = LoadLibraryA(dlls[d]); + + if(ret != NULL) + return ret; } // finally if we couldn't load a library anywhere from the system while capturing, load our local