Eliminate unused DX11 driver uniforms.

TRAC #22428 Signed-off-by: Geoff Lang Signed-off-by: Jamie Madill Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1895 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 6bb4886c
......@@ -96,7 +96,7 @@ OutputHLSL::OutputHLSL(TParseContext &context, ShShaderOutput outputType)
{
if (mContext.shaderType == SH_FRAGMENT_SHADER)
{
mUniformRegister = 3; // Reserve registers for dx_DepthRange, dx_Coord and dx_DepthFront
mUniformRegister = 3; // Reserve registers for dx_DepthRange, dx_ViewCoords and dx_DepthFront
}
else
{
......@@ -250,7 +250,7 @@ void OutputHLSL::header()
if (mUsesFragCoord)
{
out << " float4 dx_Coord : packoffset(c1);\n";
out << " float4 dx_ViewCoords : packoffset(c1);\n";
}
if (mUsesFragCoord || mUsesFrontFacing)
......@@ -269,7 +269,7 @@ void OutputHLSL::header()
if (mUsesFragCoord)
{
out << "uniform float4 dx_Coord : register(c1);\n";
out << "uniform float4 dx_ViewCoords : register(c1);\n";
}
if (mUsesFragCoord || mUsesFrontFacing)
......@@ -613,16 +613,14 @@ void OutputHLSL::header()
if (mOutputType == SH_HLSL11_OUTPUT)
{
out << "cbuffer DriverConstants : register(b1)\n"
"{\n";
if (mUsesDepthRange)
{
out << " float3 dx_DepthRange : packoffset(c0);\n";
out << "cbuffer DriverConstants : register(b1)\n"
"{\n"
" float3 dx_DepthRange : packoffset(c0);\n"
"};\n"
"\n";
}
out << " float2 dx_HalfPixelSize : packoffset(c1);\n";
out << "};\n";
}
else
{
......@@ -631,11 +629,10 @@ void OutputHLSL::header()
out << "uniform float3 dx_DepthRange : register(c0);\n";
}
out << "uniform float2 dx_HalfPixelSize : register(c1);\n";
out << "uniform float2 dx_HalfPixelSize : register(c1);\n"
"\n";
}
out << "\n";
if (mUsesDepthRange)
{
out << "static gl_DepthRangeParameters gl_DepthRange = {dx_DepthRange.x, dx_DepthRange.y, dx_DepthRange.z};\n"
......
......@@ -1324,14 +1324,28 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, int registers, const Varying
vertexHLSL += "(input." + decorateAttribute(attribute->name) + ");\n";
}
vertexHLSL += "\n"
" gl_main();\n"
"\n"
" VS_OUTPUT output;\n"
" output.gl_Position.x = gl_Position.x - dx_HalfPixelSize.x * gl_Position.w;\n"
" output.gl_Position.y = -(gl_Position.y + dx_HalfPixelSize.y * gl_Position.w);\n"
" output.gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n"
" output.gl_Position.w = gl_Position.w;\n";
if (shaderModel >= 4)
{
vertexHLSL += "\n"
" gl_main();\n"
"\n"
" VS_OUTPUT output;\n"
" output.gl_Position.x = gl_Position.x;\n"
" output.gl_Position.y = -gl_Position.y;\n"
" output.gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n"
" output.gl_Position.w = gl_Position.w;\n";
}
else
{
vertexHLSL += "\n"
" gl_main();\n"
"\n"
" VS_OUTPUT output;\n"
" output.gl_Position.x = gl_Position.x - dx_HalfPixelSize.x * gl_Position.w;\n"
" output.gl_Position.y = -(gl_Position.y + dx_HalfPixelSize.y * gl_Position.w);\n"
" output.gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n"
" output.gl_Position.w = gl_Position.w;\n";
}
if (vertexShader->mUsesPointSize && shaderModel >= 3)
{
......@@ -1490,9 +1504,9 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, int registers, const Varying
}
else
{
// dx_Coord contains the viewport width/2, height/2, center.x and center.y. See Context::applyRenderTarget()
pixelHLSL += " gl_FragCoord.x = (input.gl_FragCoord.x * rhw) * dx_Coord.x + dx_Coord.z;\n"
" gl_FragCoord.y = (input.gl_FragCoord.y * rhw) * dx_Coord.y + dx_Coord.w;\n";
// dx_ViewCoords contains the viewport width/2, height/2, center.x and center.y. See Renderer::setViewport()
pixelHLSL += " gl_FragCoord.x = (input.gl_FragCoord.x * rhw) * dx_ViewCoords.x + dx_ViewCoords.z;\n"
" gl_FragCoord.y = (input.gl_FragCoord.y * rhw) * dx_ViewCoords.y + dx_ViewCoords.w;\n";
}
pixelHLSL += " gl_FragCoord.z = (input.gl_FragCoord.z * rhw) * dx_DepthFront.x + dx_DepthFront.y;\n"
......@@ -2134,10 +2148,9 @@ std::string ProgramBinary::generatePointSpriteHLSL(int registers, const Varying
pointCoordSemantic = varyingSemantic + str(reservedRegisterIndex++);
}
geomHLSL += "uniform float4 dx_viewportCoords : register(c1);\n"
"\n";
geomHLSL += "struct GS_INPUT\n"
geomHLSL += "uniform float4 dx_ViewCoords : register(c1);\n"
"\n"
"struct GS_INPUT\n"
"{\n";
for (int r = 0; r < registers; r++)
......@@ -2216,7 +2229,7 @@ std::string ProgramBinary::generatePointSpriteHLSL(int registers, const Varying
geomHLSL += " \n"
" float gl_PointSize = clamp(input[0].gl_PointSize, minPointSize, maxPointSize);\n"
" float4 gl_Position = input[0].gl_Position;\n"
" float2 viewportScale = float2(1.0f / dx_viewportCoords.x, 1.0f / dx_viewportCoords.y) * gl_Position.w;\n";
" float2 viewportScale = float2(1.0f / dx_ViewCoords.x, 1.0f / dx_ViewCoords.y);\n";
for (int corner = 0; corner < 4; corner++)
{
......
......@@ -79,7 +79,7 @@ struct dx_VertexConstants
struct dx_PixelConstants
{
float depthRange[4];
float coord[4];
float viewCoords[4];
float depthFront[4];
};
......
......@@ -687,17 +687,13 @@ bool Renderer11::setViewport(const gl::Rectangle &viewport, float zNear, float z
mCurNear = actualZNear;
mCurFar = actualZFar;
mVertexConstants.halfPixelSize[0] = 0.0f;
mVertexConstants.halfPixelSize[1] = 0.0f;
mPixelConstants.coord[0] = actualViewport.width * 0.5f;
mPixelConstants.coord[1] = actualViewport.height * 0.5f;
mPixelConstants.coord[2] = actualViewport.x + (actualViewport.width * 0.5f);
mPixelConstants.coord[3] = actualViewport.y + (actualViewport.height * 0.5f);
mPixelConstants.viewCoords[0] = actualViewport.width * 0.5f;
mPixelConstants.viewCoords[1] = actualViewport.height * 0.5f;
mPixelConstants.viewCoords[2] = actualViewport.x + (actualViewport.width * 0.5f);
mPixelConstants.viewCoords[3] = actualViewport.y + (actualViewport.height * 0.5f);
mPixelConstants.depthFront[0] = (actualZFar - actualZNear) * 0.5f;
mPixelConstants.depthFront[1] = (actualZNear + actualZFar) * 0.5f;
mPixelConstants.depthFront[2] = !gl::IsTriangleMode(drawMode) ? 0.0f : (frontFace == GL_CCW ? 1.0f : -1.0f);;
mVertexConstants.depthRange[0] = actualZNear;
mVertexConstants.depthRange[1] = actualZFar;
......
......@@ -1088,10 +1088,10 @@ bool Renderer9::setViewport(const gl::Rectangle &viewport, float zNear, float zF
vc.halfPixelSize[0] = 1.0f / dxViewport.Width;
vc.halfPixelSize[1] = -1.0f / dxViewport.Height;
pc.coord[0] = actualViewport.width * 0.5f;
pc.coord[1] = actualViewport.height * 0.5f;
pc.coord[2] = actualViewport.x + (actualViewport.width * 0.5f);
pc.coord[3] = actualViewport.y + (actualViewport.height * 0.5f);
pc.viewCoords[0] = actualViewport.width * 0.5f;
pc.viewCoords[1] = actualViewport.height * 0.5f;
pc.viewCoords[2] = actualViewport.x + (actualViewport.width * 0.5f);
pc.viewCoords[3] = actualViewport.y + (actualViewport.height * 0.5f);
pc.depthFront[0] = (actualZFar - actualZNear) * 0.5f;
pc.depthFront[1] = (actualZNear + actualZFar) * 0.5f;
......
......@@ -39,7 +39,7 @@ enum
{
D3D9_MAX_FLOAT_CONSTANTS = 256,
MAX_VERTEX_UNIFORM_VECTORS = D3D9_MAX_FLOAT_CONSTANTS - 2, // Reserve space for dx_HalfPixelSize and dx_DepthRange.
MAX_FRAGMENT_UNIFORM_VECTORS_SM2 = 32 - 3, // Reserve space for dx_Coord, dx_DepthFront and dx_DepthRange.
MAX_FRAGMENT_UNIFORM_VECTORS_SM2 = 32 - 3, // Reserve space for dx_ViewCoords, dx_DepthFront and dx_DepthRange.
MAX_FRAGMENT_UNIFORM_VECTORS_SM3 = 224 - 3,
MAX_VARYING_VECTORS_SM2 = 8,
MAX_VARYING_VECTORS_SM3 = 10
......
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