Apply DX constants directly.

TRAC #22245 Signed-off-by: Daniel Koch Signed-off-by: Geoff Lang Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1584 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 88853c50
#define MAJOR_VERSION 1 #define MAJOR_VERSION 1
#define MINOR_VERSION 1 #define MINOR_VERSION 1
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 1550 #define BUILD_REVISION 1561
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -85,10 +85,11 @@ ProgramBinary::ProgramBinary(rx::Renderer *renderer) : mRenderer(renderer), RefC ...@@ -85,10 +85,11 @@ ProgramBinary::ProgramBinary(rx::Renderer *renderer) : mRenderer(renderer), RefC
mUsedVertexSamplerRange = 0; mUsedVertexSamplerRange = 0;
mUsedPixelSamplerRange = 0; mUsedPixelSamplerRange = 0;
mDxDepthRangeLocation = -1; mDxDepthRangeRegisterVS = -1;
mDxDepthFrontLocation = -1; mDxDepthRangeRegisterPS = -1;
mDxCoordLocation = -1; mDxDepthFrontRegister = -1;
mDxHalfPixelSizeLocation = -1; mDxCoordRegister = -1;
mDxHalfPixelSizeRegister = -1;
} }
ProgramBinary::~ProgramBinary() ProgramBinary::~ProgramBinary()
...@@ -1626,10 +1627,11 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length) ...@@ -1626,10 +1627,11 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
stream.read(&mUniformIndex[i].index); stream.read(&mUniformIndex[i].index);
} }
stream.read(&mDxDepthRangeLocation); stream.read(&mDxDepthRangeRegisterVS);
stream.read(&mDxDepthFrontLocation); stream.read(&mDxDepthRangeRegisterPS);
stream.read(&mDxCoordLocation); stream.read(&mDxDepthFrontRegister);
stream.read(&mDxHalfPixelSizeLocation); stream.read(&mDxCoordRegister);
stream.read(&mDxHalfPixelSizeRegister);
unsigned int pixelShaderSize; unsigned int pixelShaderSize;
stream.read(&pixelShaderSize); stream.read(&pixelShaderSize);
...@@ -1733,10 +1735,11 @@ bool ProgramBinary::save(void* binary, GLsizei bufSize, GLsizei *length) ...@@ -1733,10 +1735,11 @@ bool ProgramBinary::save(void* binary, GLsizei bufSize, GLsizei *length)
stream.write(mUniformIndex[i].index); stream.write(mUniformIndex[i].index);
} }
stream.write(mDxDepthRangeLocation); stream.write(mDxDepthRangeRegisterVS);
stream.write(mDxDepthFrontLocation); stream.write(mDxDepthRangeRegisterPS);
stream.write(mDxCoordLocation); stream.write(mDxDepthFrontRegister);
stream.write(mDxHalfPixelSizeLocation); stream.write(mDxCoordRegister);
stream.write(mDxHalfPixelSizeRegister);
UINT pixelShaderSize = mPixelExecutable->getLength(); UINT pixelShaderSize = mPixelExecutable->getLength();
stream.write(pixelShaderSize); stream.write(pixelShaderSize);
...@@ -1856,13 +1859,6 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin ...@@ -1856,13 +1859,6 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
} }
} }
// these uniforms are searched as already-decorated because gl_ and dx_
// are reserved prefixes, and do not receive additional decoration
mDxDepthRangeLocation = getUniformLocation("dx_DepthRange");
mDxDepthFrontLocation = getUniformLocation("dx_DepthFront");
mDxCoordLocation = getUniformLocation("dx_Coord");
mDxHalfPixelSizeLocation = getUniformLocation("dx_HalfPixelSize");
Context *context = getContext(); Context *context = getContext();
context->markDxUniformsDirty(); context->markDxUniformsDirty();
...@@ -2047,9 +2043,34 @@ bool ProgramBinary::defineUniform(InfoLog &infoLog, GLenum shader, const rx::D3D ...@@ -2047,9 +2043,34 @@ bool ProgramBinary::defineUniform(InfoLog &infoLog, GLenum shader, const rx::D3D
bool ProgramBinary::defineUniform(GLenum shader, const rx::D3DConstant *constant, const std::string &_name) bool ProgramBinary::defineUniform(GLenum shader, const rx::D3DConstant *constant, const std::string &_name)
{ {
if (_name == "dx_DepthRange")
{
if (shader == GL_VERTEX_SHADER) mDxDepthRangeRegisterVS = constant->registerIndex;
if (shader == GL_FRAGMENT_SHADER) mDxDepthRangeRegisterPS = constant->registerIndex;
return true;
}
if (_name == "dx_DepthFront")
{
mDxDepthFrontRegister = constant->registerIndex;
return true;
}
if (_name == "dx_Coord")
{
mDxCoordRegister = constant->registerIndex;
return true;
}
if (_name == "dx_HalfPixelSize")
{
mDxHalfPixelSizeRegister = constant->registerIndex;
return true;
}
Uniform *uniform = createUniform(constant, _name); Uniform *uniform = createUniform(constant, _name);
if(!uniform) if (!uniform)
{ {
return false; return false;
} }
...@@ -2651,26 +2672,56 @@ bool ProgramBinary::validateSamplers(InfoLog *infoLog) ...@@ -2651,26 +2672,56 @@ bool ProgramBinary::validateSamplers(InfoLog *infoLog)
void ProgramBinary::applyDxDepthRange(float near, float far, float diff) void ProgramBinary::applyDxDepthRange(float near, float far, float diff)
{ {
GLfloat nearFarDiff[3] = {near, far, diff}; if (dynamic_cast<rx::Renderer9*>(mRenderer) == NULL) return; // UNIMPLEMENTED
setUniform3fv(mDxDepthRangeLocation, 1, nearFarDiff); IDirect3DDevice9 *device = rx::Renderer9::makeRenderer9(mRenderer)->getDevice(); // D3D9_REPLACE
if (mDxDepthRangeRegisterVS >= 0)
{
float nearFarDiff[4] = {near, far, diff};
device->SetVertexShaderConstantF(mDxDepthRangeRegisterVS, nearFarDiff, 1);
}
if (mDxDepthRangeRegisterPS >= 0)
{
float nearFarDiff[4] = {near, far, diff};
device->SetPixelShaderConstantF(mDxDepthRangeRegisterPS, nearFarDiff, 1);
}
} }
void ProgramBinary::applyDxDepthFront(float range, float start, float frontCCW) void ProgramBinary::applyDxDepthFront(float range, float start, float frontCCW)
{ {
GLfloat dz[3] = {range, start, frontCCW}; if (mDxDepthFrontRegister >= 0)
setUniform3fv(mDxDepthFrontLocation, 1, dz); {
if (dynamic_cast<rx::Renderer9*>(mRenderer) == NULL) return; // UNIMPLEMENTED
IDirect3DDevice9 *device = rx::Renderer9::makeRenderer9(mRenderer)->getDevice(); // D3D9_REPLACE
GLfloat dz[4] = {range, start, frontCCW};
device->SetPixelShaderConstantF(mDxDepthFrontRegister, dz, 1);
}
} }
void ProgramBinary::applyDxCoord(float halfWidth, float halfHeight, float x0, float y0) void ProgramBinary::applyDxCoord(float halfWidth, float halfHeight, float x0, float y0)
{ {
if (mDxCoordRegister >= 0)
{
if (dynamic_cast<rx::Renderer9*>(mRenderer) == NULL) return; // UNIMPLEMENTED
IDirect3DDevice9 *device = rx::Renderer9::makeRenderer9(mRenderer)->getDevice(); // D3D9_REPLACE
GLfloat whxy[4] = {halfWidth,halfHeight, x0, y0}; GLfloat whxy[4] = {halfWidth,halfHeight, x0, y0};
setUniform4fv(mDxCoordLocation, 1, whxy); device->SetPixelShaderConstantF(mDxCoordRegister, whxy, 1);
}
} }
void ProgramBinary::applyDxHalfPixelSize(float width, float height) void ProgramBinary::applyDxHalfPixelSize(float width, float height)
{ {
GLfloat xy[2] = {width, height}; if (mDxHalfPixelSizeRegister >= 0)
setUniform2fv(mDxHalfPixelSizeLocation, 1, xy); {
if (dynamic_cast<rx::Renderer9*>(mRenderer) == NULL) return; // UNIMPLEMENTED
IDirect3DDevice9 *device = rx::Renderer9::makeRenderer9(mRenderer)->getDevice(); // D3D9_REPLACE
GLfloat xy[4] = {width, height};
device->SetVertexShaderConstantF(mDxHalfPixelSizeRegister, xy, 1);
}
} }
ProgramBinary::Sampler::Sampler() : active(false), logicalTextureUnit(0), textureType(TEXTURE_2D) ProgramBinary::Sampler::Sampler() : active(false), logicalTextureUnit(0), textureType(TEXTURE_2D)
......
...@@ -210,10 +210,11 @@ class ProgramBinary : public RefCountObject ...@@ -210,10 +210,11 @@ class ProgramBinary : public RefCountObject
typedef std::vector<UniformLocation> UniformIndex; typedef std::vector<UniformLocation> UniformIndex;
UniformIndex mUniformIndex; UniformIndex mUniformIndex;
GLint mDxDepthRangeLocation; int mDxDepthRangeRegisterVS;
GLint mDxDepthFrontLocation; int mDxDepthRangeRegisterPS;
GLint mDxCoordLocation; int mDxDepthFrontRegister;
GLint mDxHalfPixelSizeLocation; int mDxCoordRegister;
int mDxHalfPixelSizeRegister;
bool mValidated; bool mValidated;
......
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