Load the compiler module for D3D11.

TRAC #22191 Signed-off-by: Shannon Woods Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1528 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent c5693159
......@@ -37,6 +37,7 @@ Renderer11::Renderer11(egl::Display *display, HDC hDc) : Renderer(display), mDc(
{
mD3d11Module = NULL;
mDxgiModule = NULL;
mD3dCompilerModule = NULL;
mDeviceLost = false;
......@@ -85,6 +86,12 @@ Renderer11::~Renderer11()
FreeLibrary(mDxgiModule);
mDxgiModule = NULL;
}
if (mD3dCompilerModule)
{
FreeLibrary(mD3dCompilerModule);
mD3dCompilerModule = NULL;
}
}
Renderer11 *Renderer11::makeRenderer11(Renderer *renderer)
......@@ -171,6 +178,31 @@ EGLint Renderer11::initialize()
return EGL_NOT_INITIALIZED;
}
#if defined(ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES)
// Find a D3DCompiler module that had already been loaded based on a predefined list of versions.
static TCHAR* d3dCompilerNames[] = ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES;
for (int i = 0; i < sizeof(d3dCompilerNames) / sizeof(*d3dCompilerNames); ++i)
{
if (GetModuleHandleEx(0, d3dCompilerNames[i], &mD3dCompilerModule))
{
break;
}
}
#else
// Load the version of the D3DCompiler DLL associated with the Direct3D version ANGLE was built with.
mD3dCompilerModule = LoadLibrary(D3DCOMPILER_DLL);
#endif // ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES
if (!mD3dCompilerModule)
{
terminate();
return false;
}
mD3DCompileFunc = reinterpret_cast<pD3DCompile>(GetProcAddress(mD3dCompilerModule, "D3DCompile"));
ASSERT(mD3DCompileFunc);
initializeDevice();
return EGL_SUCCESS;
......
......@@ -17,6 +17,7 @@
#include <dxgi.h>
#include <d3d11.h>
#include <D3Dcompiler.h>
#include "common/angleutils.h"
#include "libGLESv2/angletypes.h"
......@@ -143,6 +144,9 @@ class Renderer11 : public Renderer
HMODULE mDxgiModule;
HDC mDc;
HMODULE mD3dCompilerModule;
pD3DCompile mD3DCompileFunc;
bool mDeviceLost;
void initializeDevice();
......
......@@ -229,7 +229,7 @@ EGLint Renderer9::initialize()
return false;
}
mD3DCompileFunc = reinterpret_cast<D3DCompileFunc>(GetProcAddress(mD3dCompilerModule, "D3DCompile"));
mD3DCompileFunc = reinterpret_cast<pD3DCompile>(GetProcAddress(mD3dCompilerModule, "D3DCompile"));
ASSERT(mD3DCompileFunc);
if (mDc != NULL)
......
......@@ -191,20 +191,8 @@ class Renderer9 : public Renderer
HMODULE mD3d9Module;
HDC mDc;
typedef HRESULT (WINAPI *D3DCompileFunc)(LPCVOID pSrcData,
SIZE_T SrcDataSize,
LPCSTR pSourceName,
CONST D3D_SHADER_MACRO* pDefines,
ID3DInclude* pInclude,
LPCSTR pEntrypoint,
LPCSTR pTarget,
UINT Flags1,
UINT Flags2,
ID3DBlob** ppCode,
ID3DBlob** ppErrorMsgs);
HMODULE mD3dCompilerModule;
D3DCompileFunc mD3DCompileFunc;
pD3DCompile mD3DCompileFunc;
void initializeDevice();
D3DPRESENT_PARAMETERS getDefaultPresentParameters();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment