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