Isolate D3DCompiler.h include to just the cpp files that need it, instead of…

Isolate D3DCompiler.h include to just the cpp files that need it, instead of every file that uses the renderer. TRAC #22499 Signed-off-by: Geoff Lang Signed-off-by: Nicolas Capens Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1905 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent d2811d68
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
// Renderer.cpp: Implements EGL dependencies for creating and destroying Renderer instances. // Renderer.cpp: Implements EGL dependencies for creating and destroying Renderer instances.
#include <D3Dcompiler.h>
#include "libGLESv2/main.h" #include "libGLESv2/main.h"
#include "libGLESv2/Program.h" #include "libGLESv2/Program.h"
#include "libGLESv2/renderer/Renderer.h" #include "libGLESv2/renderer/Renderer.h"
...@@ -64,14 +66,14 @@ bool Renderer::initializeCompiler() ...@@ -64,14 +66,14 @@ bool Renderer::initializeCompiler()
return false; return false;
} }
mD3DCompileFunc = reinterpret_cast<pD3DCompile>(GetProcAddress(mD3dCompilerModule, "D3DCompile")); mD3DCompileFunc = reinterpret_cast<pCompileFunc>(GetProcAddress(mD3dCompilerModule, "D3DCompile"));
ASSERT(mD3DCompileFunc); ASSERT(mD3DCompileFunc);
return mD3DCompileFunc != NULL; return mD3DCompileFunc != NULL;
} }
// Compiles HLSL code into executable binaries // Compiles HLSL code into executable binaries
ID3DBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, const char *profile, bool alternateFlags) ShaderBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, const char *profile, bool alternateFlags)
{ {
if (!hlsl) if (!hlsl)
{ {
...@@ -117,13 +119,15 @@ ID3DBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, cons ...@@ -117,13 +119,15 @@ ID3DBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, cons
}; };
int attempts = (alternateFlags ? sizeof(extraFlags) / sizeof(UINT) : 1); int attempts = (alternateFlags ? sizeof(extraFlags) / sizeof(UINT) : 1);
pD3DCompile compileFunc = reinterpret_cast<pD3DCompile>(mD3DCompileFunc);
for (int i = 0; i < attempts; ++i) for (int i = 0; i < attempts; ++i)
{ {
ID3DBlob *errorMessage = NULL; ID3DBlob *errorMessage = NULL;
ID3DBlob *binary = NULL; ID3DBlob *binary = NULL;
result = mD3DCompileFunc(hlsl, strlen(hlsl), gl::g_fakepath, NULL, NULL,
"main", profile, flags | extraFlags[i], 0, &binary, &errorMessage); result = compileFunc(hlsl, strlen(hlsl), gl::g_fakepath, NULL, NULL,
"main", profile, flags | extraFlags[i], 0, &binary, &errorMessage);
if (errorMessage) if (errorMessage)
{ {
const char *message = (const char*)errorMessage->GetBufferPointer(); const char *message = (const char*)errorMessage->GetBufferPointer();
...@@ -138,13 +142,13 @@ ID3DBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, cons ...@@ -138,13 +142,13 @@ ID3DBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, cons
if (SUCCEEDED(result)) if (SUCCEEDED(result))
{ {
return binary; return (ShaderBlob*)binary;
} }
else else
{ {
if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY) if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
{ {
return gl::error(GL_OUT_OF_MEMORY, (ID3DBlob*) NULL); return gl::error(GL_OUT_OF_MEMORY, (ShaderBlob*) NULL);
} }
infoLog.append("Warning: D3D shader compilation failed with "); infoLog.append("Warning: D3D shader compilation failed with ");
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
#define EGLAPI #define EGLAPI
#include <EGL/egl.h> #include <EGL/egl.h>
#include <D3Dcompiler.h>
#include "libGLESv2/Uniform.h" #include "libGLESv2/Uniform.h"
#include "libGLESv2/angletypes.h" #include "libGLESv2/angletypes.h"
...@@ -66,6 +64,9 @@ class RenderTarget; ...@@ -66,6 +64,9 @@ class RenderTarget;
class Image; class Image;
class TextureStorage; class TextureStorage;
typedef void * ShaderBlob;
typedef void (*pCompileFunc)();
struct ConfigDesc struct ConfigDesc
{ {
GLenum renderTargetFormat; GLenum renderTargetFormat;
...@@ -224,7 +225,7 @@ class Renderer ...@@ -224,7 +225,7 @@ class Renderer
protected: protected:
bool initializeCompiler(); bool initializeCompiler();
ID3DBlob *compileToBinary(gl::InfoLog &infoLog, const char *hlsl, const char *profile, bool alternateFlags); ShaderBlob *compileToBinary(gl::InfoLog &infoLog, const char *hlsl, const char *profile, bool alternateFlags);
egl::Display *mDisplay; egl::Display *mDisplay;
...@@ -232,7 +233,7 @@ class Renderer ...@@ -232,7 +233,7 @@ class Renderer
DISALLOW_COPY_AND_ASSIGN(Renderer); DISALLOW_COPY_AND_ASSIGN(Renderer);
HMODULE mD3dCompilerModule; HMODULE mD3dCompilerModule;
pD3DCompile mD3DCompileFunc; pCompileFunc mD3DCompileFunc;
}; };
} }
......
...@@ -2688,7 +2688,7 @@ ShaderExecutable *Renderer11::compileToExecutable(gl::InfoLog &infoLog, const ch ...@@ -2688,7 +2688,7 @@ ShaderExecutable *Renderer11::compileToExecutable(gl::InfoLog &infoLog, const ch
return NULL; return NULL;
} }
ID3DBlob *binary = compileToBinary(infoLog, shaderHLSL, profile, false); ID3DBlob *binary = (ID3DBlob*) compileToBinary(infoLog, shaderHLSL, profile, false);
if (!binary) if (!binary)
return NULL; return NULL;
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <dxgi.h> #include <dxgi.h>
#include <d3d11.h> #include <d3d11.h>
#include <D3Dcompiler.h>
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libGLESv2/angletypes.h" #include "libGLESv2/angletypes.h"
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
// Renderer9.cpp: Implements a back-end specific class for the D3D9 renderer. // Renderer9.cpp: Implements a back-end specific class for the D3D9 renderer.
#include <D3Dcompiler.h>
#include "common/debug.h" #include "common/debug.h"
#include "libGLESv2/main.h" #include "libGLESv2/main.h"
#include "libGLESv2/utilities.h" #include "libGLESv2/utilities.h"
...@@ -3008,7 +3010,7 @@ ShaderExecutable *Renderer9::compileToExecutable(gl::InfoLog &infoLog, const cha ...@@ -3008,7 +3010,7 @@ ShaderExecutable *Renderer9::compileToExecutable(gl::InfoLog &infoLog, const cha
return NULL; return NULL;
} }
ID3DBlob *binary = compileToBinary(infoLog, shaderHLSL, profile, true); ID3DBlob *binary = (ID3DBlob*) compileToBinary(infoLog, shaderHLSL, profile, true);
if (!binary) if (!binary)
return NULL; return NULL;
......
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