Assign register indexes to dx_ constants and intercept them.

TRAC #22326 Signed-off-by: Daniel Koch Signed-off-by: Shannon Woods Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1631 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent da8d3801
...@@ -199,12 +199,12 @@ void OutputHLSL::header() ...@@ -199,12 +199,12 @@ void OutputHLSL::header()
if (mUsesFragCoord) if (mUsesFragCoord)
{ {
out << "uniform float4 dx_Coord;\n"; out << "uniform float4 dx_Coord : register(" + dx_RegisterString(GL_FLOAT_VEC4, "dx_Coord") + ");\n";
} }
if (mUsesFragCoord || mUsesFrontFacing) if (mUsesFragCoord || mUsesFrontFacing)
{ {
out << "uniform float3 dx_DepthFront;\n"; out << "uniform float3 dx_DepthFront : register(" + dx_RegisterString(GL_FLOAT_VEC3, "dx_DepthFront") + ");\n";
} }
out << "\n"; out << "\n";
...@@ -357,7 +357,7 @@ void OutputHLSL::header() ...@@ -357,7 +357,7 @@ void OutputHLSL::header()
"// Varyings\n"; "// Varyings\n";
out << varyings; out << varyings;
out << "\n" out << "\n"
"uniform float2 dx_HalfPixelSize;\n" "uniform float2 dx_HalfPixelSize : register(" + dx_RegisterString(GL_FLOAT_VEC2, "dx_HalfPixelSize") + ");\n"
"\n"; "\n";
out << uniforms; out << uniforms;
out << "\n"; out << "\n";
...@@ -456,7 +456,7 @@ void OutputHLSL::header() ...@@ -456,7 +456,7 @@ void OutputHLSL::header()
" float diff;\n" " float diff;\n"
"};\n" "};\n"
"\n" "\n"
"uniform float3 dx_DepthRange;" "uniform float3 dx_DepthRange : register(" + dx_RegisterString(GL_FLOAT_VEC3, "dx_DepthRange") + ");"
"static gl_DepthRangeParameters gl_DepthRange = {dx_DepthRange.x, dx_DepthRange.y, dx_DepthRange.z};\n" "static gl_DepthRangeParameters gl_DepthRange = {dx_DepthRange.x, dx_DepthRange.y, dx_DepthRange.z};\n"
"\n"; "\n";
} }
...@@ -2613,6 +2613,17 @@ TString OutputHLSL::registerString(TIntermSymbol *operand) ...@@ -2613,6 +2613,17 @@ TString OutputHLSL::registerString(TIntermSymbol *operand)
return "c" + str(uniformRegister(operand)); return "c" + str(uniformRegister(operand));
} }
TString OutputHLSL::dx_RegisterString(GLenum type, const char *name)
{
ASSERT(type >= GL_FLOAT_VEC2 && type <= GL_FLOAT_VEC4); // Only single (uniform) registers handled
int index = mUniformRegister;
mUniformRegister += 1;
mActiveUniforms.push_back(Uniform(type, name, 0, index));
return "c" + str(index);
}
int OutputHLSL::samplerRegister(TIntermSymbol *sampler) int OutputHLSL::samplerRegister(TIntermSymbol *sampler)
{ {
const TType &type = sampler->getType(); const TType &type = sampler->getType();
......
...@@ -158,6 +158,7 @@ class OutputHLSL : public TIntermTraverser ...@@ -158,6 +158,7 @@ class OutputHLSL : public TIntermTraverser
int mSamplerRegister; int mSamplerRegister;
TString registerString(TIntermSymbol *operand); TString registerString(TIntermSymbol *operand);
TString dx_RegisterString(GLenum type, const char *name);
int samplerRegister(TIntermSymbol *sampler); int samplerRegister(TIntermSymbol *sampler);
int uniformRegister(TIntermSymbol *uniform); int uniformRegister(TIntermSymbol *uniform);
void declareUniform(const TType &type, const TString &name, int index); void declareUniform(const TType &type, const TString &name, int index);
......
...@@ -2112,6 +2112,31 @@ bool ProgramBinary::defineUniform(GLenum shader, const rx::D3DConstant *constant ...@@ -2112,6 +2112,31 @@ bool ProgramBinary::defineUniform(GLenum shader, const rx::D3DConstant *constant
bool ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &constant, InfoLog &infoLog) bool ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &constant, InfoLog &infoLog)
{ {
if (constant.name == "dx_DepthRange")
{
if (shader == GL_VERTEX_SHADER) mDxDepthRangeRegisterVS = constant.registerIndex;
if (shader == GL_FRAGMENT_SHADER) mDxDepthRangeRegisterPS = constant.registerIndex;
return true;
}
if (constant.name == "dx_DepthFront")
{
mDxDepthFrontRegister = constant.registerIndex;
return true;
}
if (constant.name == "dx_Coord")
{
mDxCoordRegister = constant.registerIndex;
return true;
}
if (constant.name == "dx_HalfPixelSize")
{
mDxHalfPixelSizeRegister = constant.registerIndex;
return true;
}
if (constant.type == GL_SAMPLER_2D || if (constant.type == GL_SAMPLER_2D ||
constant.type == GL_SAMPLER_CUBE) constant.type == GL_SAMPLER_CUBE)
{ {
......
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