Scale the vertex coordinates when the viewport has been clamped.

TRAC #22649 Signed-off-by: Geoff Lang Signed-off-by: Shannon Woods Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1952 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 38e87885
......@@ -100,7 +100,7 @@ OutputHLSL::OutputHLSL(TParseContext &context, ShShaderOutput outputType)
}
else
{
mUniformRegister = 2; // Reserve registers for dx_DepthRange and dx_HalfPixelSize
mUniformRegister = 2; // Reserve registers for dx_DepthRange and dx_ViewAdjust
}
}
else
......@@ -629,7 +629,7 @@ void OutputHLSL::header()
out << "uniform float3 dx_DepthRange : register(c0);\n";
}
out << "uniform float2 dx_HalfPixelSize : register(c1);\n"
out << "uniform float4 dx_ViewAdjust : register(c1);\n"
"\n";
}
......
......@@ -1317,8 +1317,8 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, int registers, const Varying
" 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.x = gl_Position.x * dx_ViewAdjust.z + dx_ViewAdjust.x * gl_Position.w;\n"
" output.gl_Position.y = -(gl_Position.y * dx_ViewAdjust.w + dx_ViewAdjust.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";
}
......
......@@ -72,7 +72,7 @@ struct ConfigDesc
struct dx_VertexConstants
{
float depthRange[4];
float halfPixelSize[4];
float viewAdjust[4];
};
struct dx_PixelConstants
......
......@@ -1093,8 +1093,10 @@ bool Renderer9::setViewport(const gl::Rectangle &viewport, float zNear, float zF
dx_VertexConstants vc = {0};
dx_PixelConstants pc = {0};
vc.halfPixelSize[0] = 1.0f / dxViewport.Width;
vc.halfPixelSize[1] = -1.0f / dxViewport.Height;
vc.viewAdjust[0] = (float)((actualViewport.width - (int)dxViewport.Width) + 2 * (actualViewport.x - (int)dxViewport.X) - 1) / dxViewport.Width;
vc.viewAdjust[1] = (float)((actualViewport.height - (int)dxViewport.Height) + 2 * (actualViewport.y - (int)dxViewport.Y) - 1) / dxViewport.Height;
vc.viewAdjust[2] = (float)actualViewport.width / dxViewport.Width;
vc.viewAdjust[3] = (float)actualViewport.height / dxViewport.Height;
pc.viewCoords[0] = actualViewport.width * 0.5f;
pc.viewCoords[1] = actualViewport.height * 0.5f;
......@@ -2273,12 +2275,12 @@ unsigned int Renderer9::getMaxCombinedTextureImageUnits() const
unsigned int Renderer9::getReservedVertexUniformVectors() const
{
return 2; // dx_HalfPixelSize and dx_DepthRange.
return 2; // dx_ViewAdjust and dx_DepthRange.
}
unsigned int Renderer9::getReservedFragmentUniformVectors() const
{
return 3; // dx_ViewCoords, dx_DepthFront and dx_DepthRange.
return 3; // dx_ViewCoords, dx_DepthFront and dx_DepthRange.
}
unsigned int Renderer9::getMaxVertexUniformVectors() const
......
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