Remove dependency on d3dcompiler import library.

It is now loaded with LoadLibrary. Added compile time option of having ANGLE enumerate various versions of d3dcompiler_nn.dll that the application can preload before eglInitialize(). Review URL: https://codereview.appspot.com/6816074 Author: Al Patrick (applied to branch) git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1467 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent c23f4611
......@@ -9,6 +9,7 @@
'target_defaults': {
'defines': [
'ANGLE_DISABLE_TRACE',
'ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ L"d3dcompiler_46.dll", L"d3dcompiler_43.dll" }',
],
},
'targets': [
......@@ -294,8 +295,6 @@
'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'],
'AdditionalDependencies': [
'd3d9.lib',
'd3dx9.lib',
'd3dcompiler.lib',
'dxguid.lib',
],
}
......@@ -308,6 +307,7 @@
'include_dirs': [
'.',
'../include',
'$(DXSDK_DIR)/include',
],
'sources': [
'common/angleutils.h',
......
......@@ -1088,7 +1088,7 @@ ID3D10Blob *ProgramBinary::compileToBinary(InfoLog &infoLog, const char *hlsl, c
{
ID3D10Blob *errorMessage = NULL;
ID3D10Blob *binary = NULL;
result = D3DCompile(hlsl, strlen(hlsl), g_fakepath, NULL, NULL, "main", profile, flags | extraFlags[i], 0, &binary, &errorMessage);
result = mRenderer->compileShaderSource(hlsl, g_fakepath, profile, flags | extraFlags[i], &binary, &errorMessage);
if (errorMessage)
{
......
......@@ -97,7 +97,7 @@
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>d3d9.lib;d3dcompiler.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>d3d9.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>libGLESv2.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
......@@ -130,7 +130,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4718;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>d3d9.lib;d3dcompiler.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>d3d9.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<ModuleDefinitionFile>libGLESv2.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
......@@ -170,7 +170,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<AdditionalDependencies>d3d9.lib;d3dcompiler.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>d3d9.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>libGLESv2.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
......@@ -206,7 +206,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<AdditionalDependencies>d3d9.lib;d3dcompiler.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>d3d9.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<ModuleDefinitionFile>libGLESv2.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
......
......@@ -65,6 +65,8 @@ Renderer9::Renderer9(egl::Display *display, HDC hDc, bool softwareDevice) : Rend
{
mD3d9Module = NULL;
mD3dCompilerModule = NULL;
mD3d9 = NULL;
mD3d9Ex = NULL;
mDevice = NULL;
......@@ -132,6 +134,12 @@ Renderer9::~Renderer9()
mD3d9Module = NULL;
}
if (mD3dCompilerModule)
{
FreeLibrary(mD3dCompilerModule);
mD3dCompilerModule = NULL;
}
while (!mMultiSampleSupport.empty())
{
delete [] mMultiSampleSupport.begin()->second;
......@@ -178,6 +186,32 @@ EGLint Renderer9::initialize()
ERR("Could not create D3D9 device - aborting!\n");
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<D3DCompileFunc>(GetProcAddress(mD3dCompilerModule, "D3DCompile"));
ASSERT(mD3DCompileFunc);
if (mDc != NULL)
{
// UNIMPLEMENTED(); // FIXME: Determine which adapter index the device context corresponds to
......@@ -540,6 +574,12 @@ void Renderer9::freeEventQuery(IDirect3DQuery9* query)
}
}
HRESULT Renderer9::compileShaderSource(const char* hlsl, const char* sourceName, const char* profile, DWORD flags, ID3DBlob** binary, ID3DBlob** errorMessage)
{
return mD3DCompileFunc(hlsl, strlen(hlsl), sourceName, NULL, NULL, "main", profile, flags, 0, binary, errorMessage);
}
IDirect3DVertexShader9 *Renderer9::createVertexShader(const DWORD *function, size_t length)
{
return mVertexShaderCache.create(function, length);
......
......@@ -20,6 +20,7 @@
#include <EGL/egl.h>
#include <d3d9.h>
#include <D3Dcompiler.h>
#include "common/angleutils.h"
#include "libGLESv2/renderer/ShaderCache.h"
......@@ -53,6 +54,7 @@ class Renderer9 : public Renderer
// resource creation
IDirect3DVertexShader9 *createVertexShader(const DWORD *function, size_t length);
IDirect3DPixelShader9 *createPixelShader(const DWORD *function, size_t length);
HRESULT compileShaderSource(const char* hlsl, const char* sourceName, const char* profile, DWORD flags, ID3DBlob** binary, ID3DBlob** errorMessage);
HRESULT createVertexBuffer(UINT Length, DWORD Usage, IDirect3DVertexBuffer9 **ppVertexBuffer);
HRESULT createIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, IDirect3DIndexBuffer9 **ppIndexBuffer);
#if 0
......@@ -159,6 +161,21 @@ 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;
void initializeDevice();
D3DPRESENT_PARAMETERS getDefaultPresentParameters();
void releaseDeviceResources();
......
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