Implement gl_DepthRange using a single uniform vector.

TRAC #14504 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@495 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent ce9952c5
......@@ -362,7 +362,8 @@ void OutputHLSL::header()
" float diff;\n"
"};\n"
"\n"
"uniform gl_DepthRangeParameters gl_DepthRange;\n"
"uniform float3 dx_DepthRange;"
"static gl_DepthRangeParameters gl_DepthRange = {dx_DepthRange.x, dx_DepthRange.y, dx_DepthRange.z};\n"
"\n";
}
......
......@@ -1698,27 +1698,21 @@ bool Context::applyRenderTarget(bool ignoreViewport)
GLint halfPixelSize = programObject->getDxHalfPixelSizeLocation();
GLfloat xy[2] = {1.0f / viewport.Width, 1.0f / viewport.Height};
programObject->setUniform2fv(halfPixelSize, 1, (GLfloat*)&xy);
programObject->setUniform2fv(halfPixelSize, 1, xy);
GLint window = programObject->getDxViewportLocation();
GLint viewport = programObject->getDxViewportLocation();
GLfloat whxy[4] = {mState.viewportWidth / 2.0f, mState.viewportHeight / 2.0f,
(float)mState.viewportX + mState.viewportWidth / 2.0f,
(float)mState.viewportY + mState.viewportHeight / 2.0f};
programObject->setUniform4fv(window, 1, (GLfloat*)&whxy);
programObject->setUniform4fv(viewport, 1, whxy);
GLint depth = programObject->getDxDepthLocation();
GLfloat dz[2] = {(zFar - zNear) / 2.0f, (zNear + zFar) / 2.0f};
programObject->setUniform2fv(depth, 1, (GLfloat*)&dz);
programObject->setUniform2fv(depth, 1, dz);
GLint near = programObject->getDepthRangeNearLocation();
programObject->setUniform1fv(near, 1, &zNear);
GLint far = programObject->getDepthRangeFarLocation();
programObject->setUniform1fv(far, 1, &zFar);
GLint diff = programObject->getDepthRangeDiffLocation();
GLfloat zDiff = zFar - zNear;
programObject->setUniform1fv(diff, 1, &zDiff);
GLint depthRange = programObject->getDxDepthRangeLocation();
GLfloat nearFarDiff[3] = {zNear, zFar, zFar - zNear};
programObject->setUniform3fv(depthRange, 1, nearFarDiff);
}
return true;
......
......@@ -1536,9 +1536,7 @@ void Program::link()
// these uniforms are searched as already-decorated because gl_ and dx_
// are reserved prefixes, and do not receive additional decoration
mDepthRangeNearLocation = getUniformLocation("gl_DepthRange.near", true);
mDepthRangeFarLocation = getUniformLocation("gl_DepthRange.far", true);
mDepthRangeDiffLocation = getUniformLocation("gl_DepthRange.diff", true);
mDxDepthRangeLocation = getUniformLocation("dx_DepthRange", true);
mDxDepthLocation = getUniformLocation("dx_Depth", true);
mDxViewportLocation = getUniformLocation("dx_Viewport", true);
mDxHalfPixelSizeLocation = getUniformLocation("dx_HalfPixelSize", true);
......@@ -2457,9 +2455,7 @@ void Program::unlink(bool destroy)
mUniforms.pop_back();
}
mDepthRangeDiffLocation = -1;
mDepthRangeNearLocation = -1;
mDepthRangeFarLocation = -1;
mDxDepthRangeLocation = -1;
mDxDepthLocation = -1;
mDxViewportLocation = -1;
mDxHalfPixelSizeLocation = -1;
......@@ -2794,19 +2790,9 @@ void Program::getConstantHandles(Uniform *targetUniform, D3DXHANDLE *constantPS,
*constantVS = targetUniform->vsHandle;
}
GLint Program::getDepthRangeDiffLocation() const
GLint Program::getDxDepthRangeLocation() const
{
return mDepthRangeDiffLocation;
}
GLint Program::getDepthRangeNearLocation() const
{
return mDepthRangeNearLocation;
}
GLint Program::getDepthRangeFarLocation() const
{
return mDepthRangeFarLocation;
return mDxDepthRangeLocation;
}
GLint Program::getDxDepthLocation() const
......
......@@ -94,9 +94,7 @@ class Program
bool getUniformfv(GLint location, GLfloat *params);
bool getUniformiv(GLint location, GLint *params);
GLint getDepthRangeDiffLocation() const;
GLint getDepthRangeNearLocation() const;
GLint getDepthRangeFarLocation() const;
GLint getDxDepthRangeLocation() const;
GLint getDxDepthLocation() const;
GLint getDxViewportLocation() const;
GLint getDxHalfPixelSizeLocation() const;
......@@ -204,9 +202,7 @@ class Program
typedef std::vector<UniformLocation> UniformIndex;
UniformIndex mUniformIndex;
GLint mDepthRangeDiffLocation;
GLint mDepthRangeNearLocation;
GLint mDepthRangeFarLocation;
GLint mDxDepthRangeLocation;
GLint mDxDepthLocation;
GLint mDxViewportLocation;
GLint mDxHalfPixelSizeLocation;
......
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