On replay prefer loading the d3dcompiler we ship

* On windows 7, d3dcompiler_47.dll is too old to support SM5.1 shaders.
This commit is contained in:
baldurk
2020-03-18 17:14:20 +00:00
parent 3bb57bfed7
commit cb6240e271
+25 -13
View File
@@ -24,11 +24,19 @@
#include "dxbc_compile.h"
#include "common/common.h"
#include "core/core.h"
#include "os/os_specific.h"
#include "strings/string_utils.h"
// gives us an address to identify this dll with
static int dllLocator = 0;
static HMODULE GetLocalD3DCompiler()
{
rdcstr dllFile;
FileIO::GetLibraryFilename(dllFile);
rdcstr dll = get_dirname(dllFile) + "/d3dcompiler_47.dll";
return LoadLibraryW(StringFormat::UTF82Wide(dll.c_str()).data());
}
HMODULE GetD3DCompiler()
{
@@ -36,7 +44,15 @@ HMODULE GetD3DCompiler()
if(ret != NULL)
return ret;
// dlls to try in priority order
// during replay, try to load our local one to get the newest possible.
if(RenderDoc::Inst().IsReplayApp())
{
ret = GetLocalD3DCompiler();
if(ret)
return ret;
}
// now dlls to try in priority order
const char *dlls[] = {
"d3dcompiler_47.dll", "d3dcompiler_46.dll", "d3dcompiler_45.dll",
"d3dcompiler_44.dll", "d3dcompiler_43.dll",
@@ -46,6 +62,8 @@ HMODULE GetD3DCompiler()
{
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
@@ -56,15 +74,9 @@ HMODULE GetD3DCompiler()
}
}
// all else failed, couldn't find d3dcompiler loaded,
// and couldn't even loadlibrary any version!
// we'll have to loadlibrary the version that ships with
// RenderDoc.
// finally if we couldn't load a library anywhere from the system while capturing, load our local
// compiler.
ret = GetLocalD3DCompiler();
rdcstr dllFile;
FileIO::GetLibraryFilename(dllFile);
rdcstr dll = get_dirname(dllFile) + "/d3dcompiler_47.dll";
return LoadLibraryW(StringFormat::UTF82Wide(dll.c_str()).data());
return ret;
}