CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Common/GPU/D3D9/D3DCompilerLoader.cpp
Views: 1401
1
#include "ppsspp_config.h"
2
3
#include "Common/CommonWindows.h"
4
#include <D3Dcompiler.h>
5
6
#include "Common/Log.h"
7
#include "Common/GPU/D3D9/D3DCompilerLoader.h"
8
9
static HMODULE g_D3DCompileModule;
10
extern pD3DCompile ptr_D3DCompile;
11
12
static int d3dcompiler_version = 47;
13
14
bool LoadD3DCompilerDynamic() {
15
g_D3DCompileModule = LoadLibrary(D3DCOMPILER_DLL);
16
#if PPSSPP_ARCH(X86)
17
// Workaround for distributing both 32-bit and 64-bit versions of the DLL.
18
if (!g_D3DCompileModule) {
19
g_D3DCompileModule = LoadLibrary(L"D3dcompiler_47.x86.dll");
20
}
21
#endif
22
if (!g_D3DCompileModule) {
23
g_D3DCompileModule = LoadLibrary(L"D3dcompiler_42.dll");
24
d3dcompiler_version = 42;
25
}
26
27
if (!g_D3DCompileModule) {
28
return false;
29
} else {
30
ptr_D3DCompile = (pD3DCompile)GetProcAddress(g_D3DCompileModule, "D3DCompile");
31
return true;
32
}
33
34
}
35
36
int GetD3DCompilerVersion() {
37
return d3dcompiler_version;
38
}
39
40
bool UnloadD3DCompiler() {
41
if (!g_D3DCompileModule)
42
return false;
43
44
FreeLibrary(g_D3DCompileModule);
45
g_D3DCompileModule = nullptr;
46
47
return true;
48
}
49
50
HRESULT dyn_D3DCompile(LPCSTR pSrcData, UINT SrcDataSize, LPCSTR pFileName, CONST D3D_SHADER_MACRO* pDefines,
51
LPD3DINCLUDE pInclude, LPCSTR pEntrypoint, LPCSTR pTarget,
52
UINT Flags1, UINT Flags2, LPD3DBLOB* ppShader, LPD3DBLOB* ppErrorMsgs)
53
{
54
_assert_(g_D3DCompileModule != nullptr);
55
return ptr_D3DCompile(pSrcData, SrcDataSize, pFileName, pDefines, pInclude, pEntrypoint, pTarget, Flags1, Flags2, ppShader, ppErrorMsgs);
56
}
57
58