Don't expose DX constants as GL uniforms.

TRAC #22245 Signed-off-by: Daniel Koch Signed-off-by: Geoff Lang Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1583 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 12985188
......@@ -19,6 +19,9 @@
#include <string>
#undef near
#undef far
namespace gl
{
std::string str(int i)
......@@ -2646,24 +2649,28 @@ bool ProgramBinary::validateSamplers(InfoLog *infoLog)
return true;
}
GLint ProgramBinary::getDxDepthRangeLocation() const
void ProgramBinary::applyDxDepthRange(float near, float far, float diff)
{
return mDxDepthRangeLocation;
GLfloat nearFarDiff[3] = {near, far, diff};
setUniform3fv(mDxDepthRangeLocation, 1, nearFarDiff);
}
GLint ProgramBinary::getDxDepthFrontLocation() const
void ProgramBinary::applyDxDepthFront(float range, float start, float frontCCW)
{
return mDxDepthFrontLocation;
GLfloat dz[3] = {range, start, frontCCW};
setUniform3fv(mDxDepthFrontLocation, 1, dz);
}
GLint ProgramBinary::getDxCoordLocation() const
void ProgramBinary::applyDxCoord(float halfWidth, float halfHeight, float x0, float y0)
{
return mDxCoordLocation;
GLfloat whxy[4] = {halfWidth,halfHeight, x0, y0};
setUniform4fv(mDxCoordLocation, 1, whxy);
}
GLint ProgramBinary::getDxHalfPixelSizeLocation() const
void ProgramBinary::applyDxHalfPixelSize(float width, float height)
{
return mDxHalfPixelSizeLocation;
GLfloat xy[2] = {width, height};
setUniform2fv(mDxHalfPixelSizeLocation, 1, xy);
}
ProgramBinary::Sampler::Sampler() : active(false), logicalTextureUnit(0), textureType(TEXTURE_2D)
......
......@@ -129,10 +129,10 @@ class ProgramBinary : public RefCountObject
bool getUniformfv(GLint location, GLsizei *bufSize, GLfloat *params);
bool getUniformiv(GLint location, GLsizei *bufSize, GLint *params);
GLint getDxDepthRangeLocation() const;
GLint getDxDepthFrontLocation() const;
GLint getDxCoordLocation() const;
GLint getDxHalfPixelSizeLocation() const;
void applyDxDepthRange(float near, float far, float diff);
void applyDxDepthFront(float range, float start, float frontCCW);
void applyDxCoord(float halfWidth, float halfHeight, float x0, float y0);
void applyDxHalfPixelSize(float width, float height);
void dirtyAllUniforms();
void applyUniforms();
......
......@@ -427,26 +427,18 @@ bool Renderer11::setViewport(const gl::Rectangle &viewport, float zNear, float z
if (currentProgram && (viewportChanged || forceSetUniforms))
{
GLint halfPixelSize = currentProgram->getDxHalfPixelSizeLocation();
GLfloat xy[2] = { 0.0f, 0.0f };
currentProgram->setUniform2fv(halfPixelSize, 1, xy);
currentProgram->applyDxHalfPixelSize(0.0f, 0.0f);
// These values are used for computing gl_FragCoord in Program::linkVaryings().
GLint coord = currentProgram->getDxCoordLocation();
GLfloat whxy[4] = { actualViewport.width * 0.5f,
actualViewport.height * 0.5f,
actualViewport.x + (actualViewport.width * 0.5f),
actualViewport.y + (actualViewport.height * 0.5f) };
currentProgram->setUniform4fv(coord, 1, whxy);
GLint depthFront = currentProgram->getDxDepthFrontLocation();
currentProgram->applyDxCoord(actualViewport.width * 0.5f,
actualViewport.height * 0.5f,
actualViewport.x + (actualViewport.width * 0.5f),
actualViewport.y + (actualViewport.height * 0.5f));
GLfloat ccw = !gl::IsTriangleMode(drawMode) ? 0.0f : (frontFace == GL_CCW ? 1.0f : -1.0f);
GLfloat dz[3] = { (actualZFar - actualZNear) * 0.5f, (actualZNear + actualZFar) * 0.5f, ccw };
currentProgram->setUniform3fv(depthFront, 1, dz);
currentProgram->applyDxDepthFront((actualZFar - actualZNear) * 0.5f, (actualZNear + actualZFar) * 0.5f, ccw);
GLint depthRange = currentProgram->getDxDepthRangeLocation();
GLfloat nearFarDiff[3] = { actualZNear, actualZFar, actualZFar - actualZNear };
currentProgram->setUniform3fv(depthRange, 1, nearFarDiff);
currentProgram->applyDxDepthRange(actualZNear, actualZFar, actualZFar - actualZNear);
}
mForceSetViewport = false;
......
......@@ -934,26 +934,18 @@ bool Renderer9::setViewport(const gl::Rectangle &viewport, float zNear, float zF
if (currentProgram && (viewportChanged || forceSetUniforms))
{
GLint halfPixelSize = currentProgram->getDxHalfPixelSizeLocation();
GLfloat xy[2] = { 1.0f / dxViewport.Width, -1.0f / dxViewport.Height };
currentProgram->setUniform2fv(halfPixelSize, 1, xy);
currentProgram->applyDxHalfPixelSize(1.0f / dxViewport.Width, -1.0f / dxViewport.Height);
// These values are used for computing gl_FragCoord in Program::linkVaryings().
GLint coord = currentProgram->getDxCoordLocation();
GLfloat whxy[4] = { actualViewport.width * 0.5f,
actualViewport.height * 0.5f,
actualViewport.x + (actualViewport.width * 0.5f),
actualViewport.y + (actualViewport.height * 0.5f) };
currentProgram->setUniform4fv(coord, 1, whxy);
GLint depthFront = currentProgram->getDxDepthFrontLocation();
currentProgram->applyDxCoord(actualViewport.width * 0.5f,
actualViewport.height * 0.5f,
actualViewport.x + (actualViewport.width * 0.5f),
actualViewport.y + (actualViewport.height * 0.5f));
GLfloat ccw = !gl::IsTriangleMode(drawMode) ? 0.0f : (frontFace == GL_CCW ? 1.0f : -1.0f);
GLfloat dz[3] = { (actualZFar - actualZNear) * 0.5f, (actualZNear + actualZFar) * 0.5f, ccw };
currentProgram->setUniform3fv(depthFront, 1, dz);
currentProgram->applyDxDepthFront((actualZFar - actualZNear) * 0.5f, (actualZNear + actualZFar) * 0.5f, ccw);
GLint depthRange = currentProgram->getDxDepthRangeLocation();
GLfloat nearFarDiff[3] = { actualZNear, actualZFar, actualZFar - actualZNear };
currentProgram->setUniform3fv(depthRange, 1, nearFarDiff);
currentProgram->applyDxDepthRange(actualZNear, actualZFar, actualZFar - actualZNear);
}
mForceSetViewport = false;
......
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