Compute gl_FrontFacing using a single float constant.

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@1580 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent a41d07f0
......@@ -213,8 +213,7 @@ void OutputHLSL::header()
if (mUsesFrontFacing)
{
out << "uniform bool dx_PointsOrLines;\n"
"uniform bool dx_FrontCCW;\n";
out << "uniform float dx_FrontCCW;\n";
}
out << "\n";
......
......@@ -1734,12 +1734,8 @@ void Context::applyState(GLenum drawMode)
Framebuffer *framebufferObject = getDrawFramebuffer();
GLint frontCCW = programBinary->getDxFrontCCWLocation();
GLint ccw = (mState.rasterizer.frontFace == GL_CCW);
programBinary->setUniform1iv(frontCCW, 1, &ccw);
GLint pointsOrLines = programBinary->getDxPointsOrLinesLocation();
GLint alwaysFront = !isTriangleMode(drawMode);
programBinary->setUniform1iv(pointsOrLines, 1, &alwaysFront);
GLfloat ccw = !isTriangleMode(drawMode) ? 0.0f : (mState.rasterizer.frontFace == GL_CCW ? 1.0f : -1.0f);
programBinary->setUniform1fv(frontCCW, 1, &ccw);
mRenderer->setRasterizerState(mState.rasterizer);
......
......@@ -69,8 +69,8 @@ enum
MAX_TEXTURE_IMAGE_UNITS = 16,
MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF = 4, // For devices supporting vertex texture fetch
MAX_COMBINED_TEXTURE_IMAGE_UNITS_VTF = MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF,
MAX_FRAGMENT_UNIFORM_VECTORS_SM2 = 32 - 3, // Reserve space for dx_Coord, dx_Depth, and dx_DepthRange. dx_PointOrLines and dx_FrontCCW use separate bool registers.
MAX_FRAGMENT_UNIFORM_VECTORS_SM3 = 224 - 3,
MAX_FRAGMENT_UNIFORM_VECTORS_SM2 = 32 - 4, // Reserve space for dx_Coord, dx_Depth, dx_DepthRange and dx_FrontCCW.
MAX_FRAGMENT_UNIFORM_VECTORS_SM3 = 224 - 4,
MAX_DRAW_BUFFERS = 1
};
......
......@@ -87,7 +87,6 @@ ProgramBinary::ProgramBinary(rx::Renderer *renderer) : mRenderer(renderer), RefC
mDxCoordLocation = -1;
mDxHalfPixelSizeLocation = -1;
mDxFrontCCWLocation = -1;
mDxPointsOrLinesLocation = -1;
}
ProgramBinary::~ProgramBinary()
......@@ -1475,7 +1474,7 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, std::string& pixelHLSL, std::
if (fragmentShader->mUsesFrontFacing)
{
pixelHLSL += " gl_FrontFacing = dx_PointsOrLines || (dx_FrontCCW ? (input.vFace >= 0.0) : (input.vFace <= 0.0));\n";
pixelHLSL += " gl_FrontFacing = (input.vFace * dx_FrontCCW >= 0.0);\n";
}
for (VaryingList::iterator varying = fragmentShader->mVaryings.begin(); varying != fragmentShader->mVaryings.end(); varying++)
......@@ -1630,7 +1629,6 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
stream.read(&mDxCoordLocation);
stream.read(&mDxHalfPixelSizeLocation);
stream.read(&mDxFrontCCWLocation);
stream.read(&mDxPointsOrLinesLocation);
unsigned int pixelShaderSize;
stream.read(&pixelShaderSize);
......@@ -1739,7 +1737,6 @@ bool ProgramBinary::save(void* binary, GLsizei bufSize, GLsizei *length)
stream.write(mDxCoordLocation);
stream.write(mDxHalfPixelSizeLocation);
stream.write(mDxFrontCCWLocation);
stream.write(mDxPointsOrLinesLocation);
UINT pixelShaderSize = mPixelExecutable->getLength();
stream.write(pixelShaderSize);
......@@ -1866,7 +1863,6 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
mDxCoordLocation = getUniformLocation("dx_Coord");
mDxHalfPixelSizeLocation = getUniformLocation("dx_HalfPixelSize");
mDxFrontCCWLocation = getUniformLocation("dx_FrontCCW");
mDxPointsOrLinesLocation = getUniformLocation("dx_PointsOrLines");
Context *context = getContext();
context->markDxUniformsDirty();
......@@ -2679,11 +2675,6 @@ GLint ProgramBinary::getDxFrontCCWLocation() const
return mDxFrontCCWLocation;
}
GLint ProgramBinary::getDxPointsOrLinesLocation() const
{
return mDxPointsOrLinesLocation;
}
ProgramBinary::Sampler::Sampler() : active(false), logicalTextureUnit(0), textureType(TEXTURE_2D)
{
}
......
......@@ -134,7 +134,6 @@ class ProgramBinary : public RefCountObject
GLint getDxCoordLocation() const;
GLint getDxHalfPixelSizeLocation() const;
GLint getDxFrontCCWLocation() const;
GLint getDxPointsOrLinesLocation() const;
void dirtyAllUniforms();
void applyUniforms();
......@@ -217,7 +216,6 @@ class ProgramBinary : public RefCountObject
GLint mDxCoordLocation;
GLint mDxHalfPixelSizeLocation;
GLint mDxFrontCCWLocation;
GLint mDxPointsOrLinesLocation;
bool mValidated;
......
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