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 @@
// Renderer.cpp: Implements EGL dependencies for creating and destroying Renderer instances.
#include <D3Dcompiler.h>
#include "libGLESv2/main.h"
#include "libGLESv2/Program.h"
#include "libGLESv2/renderer/Renderer.h"
......@@ -64,14 +66,14 @@ bool Renderer::initializeCompiler()
return false;
}
mD3DCompileFunc = reinterpret_cast<pD3DCompile>(GetProcAddress(mD3dCompilerModule, "D3DCompile"));
mD3DCompileFunc = reinterpret_cast<pCompileFunc>(GetProcAddress(mD3dCompilerModule, "D3DCompile"));
ASSERT(mD3DCompileFunc);
return mD3DCompileFunc != NULL;
}
// 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)
{
......@@ -117,13 +119,15 @@ ID3DBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, cons
};
int attempts = (alternateFlags ? sizeof(extraFlags) / sizeof(UINT) : 1);
pD3DCompile compileFunc = reinterpret_cast<pD3DCompile>(mD3DCompileFunc);
for (int i = 0; i < attempts; ++i)
{
ID3DBlob *errorMessage = 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)
{
const char *message = (const char*)errorMessage->GetBufferPointer();
......@@ -138,13 +142,13 @@ ID3DBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, cons
if (SUCCEEDED(result))
{
return binary;
return (ShaderBlob*)binary;
}
else
{
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 ");
......
......@@ -16,8 +16,6 @@
#define EGLAPI
#include <EGL/egl.h>
#include <D3Dcompiler.h>
#include "libGLESv2/Uniform.h"
#include "libGLESv2/angletypes.h"
......@@ -66,6 +64,9 @@ class RenderTarget;
class Image;
class TextureStorage;
typedef void * ShaderBlob;
typedef void (*pCompileFunc)();
struct ConfigDesc
{
GLenum renderTargetFormat;
......@@ -224,7 +225,7 @@ class Renderer
protected:
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;
......@@ -232,7 +233,7 @@ class Renderer
DISALLOW_COPY_AND_ASSIGN(Renderer);
HMODULE mD3dCompilerModule;
pD3DCompile mD3DCompileFunc;
pCompileFunc mD3DCompileFunc;
};
}
......
......@@ -2688,7 +2688,7 @@ ShaderExecutable *Renderer11::compileToExecutable(gl::InfoLog &infoLog, const ch
return NULL;
}
ID3DBlob *binary = compileToBinary(infoLog, shaderHLSL, profile, false);
ID3DBlob *binary = (ID3DBlob*) compileToBinary(infoLog, shaderHLSL, profile, false);
if (!binary)
return NULL;
......
......@@ -17,7 +17,6 @@
#include <dxgi.h>
#include <d3d11.h>
#include <D3Dcompiler.h>
#include "common/angleutils.h"
#include "libGLESv2/angletypes.h"
......
......@@ -6,6 +6,8 @@
// Renderer9.cpp: Implements a back-end specific class for the D3D9 renderer.
#include <D3Dcompiler.h>
#include "common/debug.h"
#include "libGLESv2/main.h"
#include "libGLESv2/utilities.h"
......@@ -3008,7 +3010,7 @@ ShaderExecutable *Renderer9::compileToExecutable(gl::InfoLog &infoLog, const cha
return NULL;
}
ID3DBlob *binary = compileToBinary(infoLog, shaderHLSL, profile, true);
ID3DBlob *binary = (ID3DBlob*) compileToBinary(infoLog, shaderHLSL, profile, true);
if (!binary)
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