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
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index 7139fa1..f1d5c67 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -199,12 +199,12 @@
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)
{
- out << "uniform float3 dx_DepthFront;\n";
+ out << "uniform float3 dx_DepthFront : register(" + dx_RegisterString(GL_FLOAT_VEC3, "dx_DepthFront") + ");\n";
}
out << "\n";
@@ -357,7 +357,7 @@
"// Varyings\n";
out << varyings;
out << "\n"
- "uniform float2 dx_HalfPixelSize;\n"
+ "uniform float2 dx_HalfPixelSize : register(" + dx_RegisterString(GL_FLOAT_VEC2, "dx_HalfPixelSize") + ");\n"
"\n";
out << uniforms;
out << "\n";
@@ -456,7 +456,7 @@
" float diff;\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"
"\n";
}
@@ -2613,6 +2613,17 @@
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)
{
const TType &type = sampler->getType();
diff --git a/src/compiler/OutputHLSL.h b/src/compiler/OutputHLSL.h
index 68c9899..b87fec3 100644
--- a/src/compiler/OutputHLSL.h
+++ b/src/compiler/OutputHLSL.h
@@ -158,6 +158,7 @@
int mSamplerRegister;
TString registerString(TIntermSymbol *operand);
+ TString dx_RegisterString(GLenum type, const char *name);
int samplerRegister(TIntermSymbol *sampler);
int uniformRegister(TIntermSymbol *uniform);
void declareUniform(const TType &type, const TString &name, int index);