mirror of https://github.com/PCSX2/pcsx2.git
gsdx-dx: Load D3DCompiler dll at runtime
D3DCompiler_47.dll will be loaded for Windows 8.1 and above (and maybe Windows 7 devs), D3DCompiler_43.dll will be loaded for Windows 7 and below.
This commit is contained in:
parent
80b6140a3e
commit
8f4823d604
|
@ -132,6 +132,10 @@ EXPORT_C_(int) GSinit()
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (!GSDeviceDX::LoadD3DCompiler())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@ -156,6 +160,8 @@ EXPORT_C GSshutdown()
|
|||
s_hr = E_FAIL;
|
||||
}
|
||||
|
||||
GSDeviceDX::FreeD3DCompiler();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,11 @@
|
|||
#include "stdafx.h"
|
||||
#include "GSdx.h"
|
||||
#include "GSDeviceDX.h"
|
||||
#include <VersionHelpers.h>
|
||||
|
||||
HMODULE GSDeviceDX::s_d3d_compiler_dll = nullptr;
|
||||
decltype(&D3DCompile) GSDeviceDX::s_pD3DCompile = nullptr;
|
||||
bool GSDeviceDX::s_old_d3d_compiler_dll;
|
||||
|
||||
GSDeviceDX::GSDeviceDX()
|
||||
{
|
||||
|
@ -35,6 +40,48 @@ GSDeviceDX::~GSDeviceDX()
|
|||
{
|
||||
}
|
||||
|
||||
bool GSDeviceDX::LoadD3DCompiler()
|
||||
{
|
||||
// Windows 8.1 and later come with the latest d3dcompiler_47.dll, but
|
||||
// Windows 7 devs might also have the dll available for use (which will
|
||||
// have to be placed in the application directory)
|
||||
s_d3d_compiler_dll = LoadLibraryEx(D3DCOMPILER_DLL, nullptr, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
|
||||
// Windows Vista and 7 can use the older version. If the previous LoadLibrary
|
||||
// call fails on Windows 8.1 and later, then the user's system is likely
|
||||
// broken.
|
||||
if (s_d3d_compiler_dll)
|
||||
{
|
||||
s_old_d3d_compiler_dll = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!IsWindows8Point1OrGreater())
|
||||
s_d3d_compiler_dll = LoadLibraryEx("D3DCompiler_43.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
|
||||
if (s_d3d_compiler_dll == nullptr)
|
||||
return false;
|
||||
|
||||
s_old_d3d_compiler_dll = true;
|
||||
}
|
||||
|
||||
s_pD3DCompile = reinterpret_cast<decltype(&D3DCompile)>(GetProcAddress(s_d3d_compiler_dll, "D3DCompile"));
|
||||
if (s_pD3DCompile)
|
||||
return true;
|
||||
|
||||
FreeLibrary(s_d3d_compiler_dll);
|
||||
s_d3d_compiler_dll = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
void GSDeviceDX::FreeD3DCompiler()
|
||||
{
|
||||
s_pD3DCompile = nullptr;
|
||||
if (s_d3d_compiler_dll)
|
||||
FreeLibrary(s_d3d_compiler_dll);
|
||||
s_d3d_compiler_dll = nullptr;
|
||||
}
|
||||
|
||||
GSTexture* GSDeviceDX::FetchSurface(int type, int w, int h, bool msaa, int format)
|
||||
{
|
||||
if(m_msaa < 2)
|
||||
|
|
|
@ -278,6 +278,12 @@ protected:
|
|||
uint32 m_msaa;
|
||||
DXGI_SAMPLE_DESC m_msaa_desc;
|
||||
|
||||
static HMODULE s_d3d_compiler_dll;
|
||||
static decltype(&D3DCompile) s_pD3DCompile;
|
||||
// Older version doesn't support D3D_COMPILE_STANDARD_FILE_INCLUDE, which
|
||||
// could be useful for external shaders.
|
||||
static bool s_old_d3d_compiler_dll;
|
||||
|
||||
GSTexture* FetchSurface(int type, int w, int h, bool msaa, int format);
|
||||
|
||||
public:
|
||||
|
@ -297,6 +303,9 @@ public:
|
|||
virtual bool HasStencil() = 0;
|
||||
virtual bool HasDepth32() = 0;
|
||||
|
||||
static bool LoadD3DCompiler();
|
||||
static void FreeD3DCompiler();
|
||||
|
||||
template<class T> void PrepareShaderMacro(vector<T>& dst, const T* src)
|
||||
{
|
||||
dst.clear();
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <commctrl.h>
|
||||
#include <commdlg.h>
|
||||
#include <shellapi.h>
|
||||
#include <d3dcompiler.h>
|
||||
#include <d3d11.h>
|
||||
#include <d3dx11.h>
|
||||
#include <d3d9.h>
|
||||
|
|
Loading…
Reference in New Issue