Add loadExecutable function to Renderer

Trac #22155 Signed-off-by: Geoff Lang Signed-off-by: Nicolas Capens factored out of compileToExecutable as we also need this when loading binaries from disk. git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1504 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent a9c71424
......@@ -163,6 +163,7 @@ class Renderer
virtual RenderTarget *createRenderTarget(int width, int height, GLenum format, GLsizei samples, bool depth) = 0;
// Shader operations
virtual ShaderExecutable *loadExecutable(const DWORD *function, size_t length, GLenum type, void *data) = 0;
virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, GLenum type) = 0;
protected:
......
......@@ -829,6 +829,13 @@ RenderTarget *Renderer11::createRenderTarget(int width, int height, GLenum forma
return NULL;
}
ShaderExecutable *Renderer11::loadExecutable(const DWORD *function, size_t length, GLenum type, void *data)
{
// TODO
UNIMPLEMENTED();
return NULL;
}
ShaderExecutable *Renderer11::compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, GLenum type)
{
// TODO
......
......@@ -130,6 +130,7 @@ class Renderer11 : public Renderer
virtual RenderTarget *createRenderTarget(int width, int height, GLenum format, GLsizei samples, bool depth);
// Shader operations
virtual ShaderExecutable *loadExecutable(const DWORD *function, size_t length, GLenum type, void *data);
virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, GLenum type);
// D3D11-renderer specific methods
......
......@@ -2632,47 +2632,28 @@ RenderTarget *Renderer9::createRenderTarget(int width, int height, GLenum format
return renderTarget;
}
ShaderExecutable *Renderer9::compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, GLenum type)
ShaderExecutable *Renderer9::loadExecutable(const DWORD *function, size_t length, GLenum type, void *data)
{
const char *profile = NULL;
switch (type)
{
case GL_VERTEX_SHADER:
profile = getMajorShaderModel() >= 3 ? "vs_3_0" : "vs_2_0";
break;
case GL_FRAGMENT_SHADER:
profile = getMajorShaderModel() >= 3 ? "ps_3_0" : "ps_2_0";
break;
default:
UNREACHABLE();
return NULL;
}
gl::D3DConstantTable *constantTable = NULL;
ID3D10Blob *binary = compileToBinary(infoLog, shaderHLSL, profile, &constantTable);
if (!binary)
return NULL;
ShaderExecutable9 *executable = NULL;
gl::D3DConstantTable *table = reinterpret_cast<gl::D3DConstantTable *>(data);
switch (type)
{
case GL_VERTEX_SHADER:
{
IDirect3DVertexShader9 *vshader = createVertexShader((DWORD *)binary->GetBufferPointer(), binary->GetBufferSize());
IDirect3DVertexShader9 *vshader = createVertexShader(function, length);
if (vshader)
{
executable = new ShaderExecutable9(vshader, constantTable);
executable = new ShaderExecutable9(vshader, table);
}
}
break;
case GL_FRAGMENT_SHADER:
{
IDirect3DPixelShader9 *pshader = createPixelShader((DWORD *)binary->GetBufferPointer(), binary->GetBufferSize());
IDirect3DPixelShader9 *pshader = createPixelShader(function, length);
if (pshader)
{
executable = new ShaderExecutable9(pshader, constantTable);
executable = new ShaderExecutable9(pshader, table);
}
}
break;
......@@ -2684,6 +2665,33 @@ ShaderExecutable *Renderer9::compileToExecutable(gl::InfoLog &infoLog, const cha
return executable;
}
ShaderExecutable *Renderer9::compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, GLenum type)
{
const char *profile = NULL;
switch (type)
{
case GL_VERTEX_SHADER:
profile = getMajorShaderModel() >= 3 ? "vs_3_0" : "vs_2_0";
break;
case GL_FRAGMENT_SHADER:
profile = getMajorShaderModel() >= 3 ? "ps_3_0" : "ps_2_0";
break;
default:
UNREACHABLE();
return NULL;
}
gl::D3DConstantTable *constantTable = NULL;
ID3D10Blob *binary = compileToBinary(infoLog, shaderHLSL, profile, &constantTable);
if (!binary)
return NULL;
ShaderExecutable *executable = loadExecutable((DWORD *)binary->GetBufferPointer(), binary->GetBufferSize(), type, constantTable);
return executable;
}
// Compiles the HLSL code of the attached shaders into executable binaries
ID3D10Blob *Renderer9::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, const char *profile, gl::D3DConstantTable **constantTable)
{
......
......@@ -171,6 +171,7 @@ class Renderer9 : public Renderer
virtual RenderTarget *createRenderTarget(int width, int height, GLenum format, GLsizei samples, bool depth);
// Shader operations
virtual ShaderExecutable *loadExecutable(const DWORD *function, size_t length, GLenum type, void *data);
virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, GLenum type);
// D3D9-renderer specific methods
......
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