Commit dd4c8631 by Nicolas Capens Committed by Nicolas Capens

Fix gl_FrontFacing to take GL_FRONT_FACE into account.

Bug swiftshader:113 Change-Id: Ia1cbcdbb396eaabaa79e4c8651d7c025f73d028a Reviewed-on: https://swiftshader-review.googlesource.com/20068Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 9e22c542
......@@ -3207,13 +3207,13 @@ namespace D3D9
switch(value)
{
case D3DCULL_NONE:
renderer->setCullMode(sw::CULL_NONE);
renderer->setCullMode(sw::CULL_NONE, true);
break;
case D3DCULL_CCW:
renderer->setCullMode(sw::CULL_COUNTERCLOCKWISE);
renderer->setCullMode(sw::CULL_COUNTERCLOCKWISE, true);
break;
case D3DCULL_CW:
renderer->setCullMode(sw::CULL_CLOCKWISE);
renderer->setCullMode(sw::CULL_CLOCKWISE, true);
break;
default:
ASSERT(false);
......
......@@ -1707,14 +1707,15 @@ bool Context::applyRenderTarget()
void Context::applyState(GLenum drawMode)
{
Framebuffer *framebuffer = getDrawFramebuffer();
bool frontFaceCCW = (mState.frontFace == GL_CCW);
if(mState.cullFaceEnabled)
{
device->setCullMode(es2sw::ConvertCullMode(mState.cullMode, mState.frontFace));
device->setCullMode(es2sw::ConvertCullMode(mState.cullMode, mState.frontFace), frontFaceCCW);
}
else
{
device->setCullMode(sw::CULL_NONE);
device->setCullMode(sw::CULL_NONE, frontFaceCCW);
}
if(mDepthStateDirty)
......
......@@ -45,7 +45,7 @@ namespace gl
setAlphaTestEnable(false);
setSourceBlendFactor(BLEND_ONE);
setDestBlendFactor(BLEND_ZERO);
setCullMode(CULL_COUNTERCLOCKWISE);
setCullMode(CULL_COUNTERCLOCKWISE, true);
setDepthCompare(DEPTH_LESSEQUAL);
setAlphaReference(0.0f);
setAlphaCompare(ALPHA_ALWAYS);
......
......@@ -1781,14 +1781,15 @@ bool Context::applyRenderTarget()
void Context::applyState(GLenum drawMode)
{
Framebuffer *framebuffer = getFramebuffer();
bool frontFaceCCW = (mState.frontFace == GL_CCW);
if(mState.cullFaceEnabled)
{
device->setCullMode(es2sw::ConvertCullMode(mState.cullMode, mState.frontFace));
device->setCullMode(es2sw::ConvertCullMode(mState.cullMode, mState.frontFace), frontFaceCCW);
}
else
{
device->setCullMode(sw::CULL_NONE);
device->setCullMode(sw::CULL_NONE, frontFaceCCW);
}
if(mDepthStateDirty)
......
......@@ -46,7 +46,7 @@ namespace es1
setAlphaTestEnable(false);
setSourceBlendFactor(BLEND_ONE);
setDestBlendFactor(BLEND_ZERO);
setCullMode(CULL_COUNTERCLOCKWISE);
setCullMode(CULL_COUNTERCLOCKWISE, true);
setDepthCompare(DEPTH_LESSEQUAL);
setAlphaReference(0.0f);
setAlphaCompare(ALPHA_ALWAYS);
......
......@@ -2783,14 +2783,15 @@ bool Context::applyRenderTarget()
void Context::applyState(GLenum drawMode)
{
Framebuffer *framebuffer = getDrawFramebuffer();
bool frontFaceCCW = (mState.frontFace == GL_CCW);
if(mState.cullFaceEnabled)
{
device->setCullMode(es2sw::ConvertCullMode(mState.cullMode, mState.frontFace));
device->setCullMode(es2sw::ConvertCullMode(mState.cullMode, mState.frontFace), frontFaceCCW);
}
else
{
device->setCullMode(sw::CULL_NONE);
device->setCullMode(sw::CULL_NONE, frontFaceCCW);
}
if(mDepthStateDirty)
......
......@@ -50,7 +50,7 @@ namespace es2
setAlphaTestEnable(false);
setSourceBlendFactor(BLEND_ONE);
setDestBlendFactor(BLEND_ZERO);
setCullMode(CULL_COUNTERCLOCKWISE);
setCullMode(CULL_COUNTERCLOCKWISE, true);
setDepthCompare(DEPTH_LESSEQUAL);
setAlphaReference(127.5f);
setAlphaCompare(ALPHA_ALWAYS);
......
......@@ -274,6 +274,7 @@ namespace sw
blendOperationStateAlpha = BLENDOP_ADD;
cullMode = CULL_CLOCKWISE;
frontFacingCCW = true;
alphaReference = 0.0f;
depthBias = 0.0f;
......
......@@ -432,6 +432,7 @@ namespace sw
ShadingMode shadingMode;
CullMode cullMode;
bool frontFacingCCW;
float alphaReference;
float depthBias;
......
......@@ -586,9 +586,10 @@ namespace sw
context->alphaTestEnable = alphaTestEnable;
}
void PixelProcessor::setCullMode(CullMode cullMode)
void PixelProcessor::setCullMode(CullMode cullMode, bool frontFacingCCW)
{
context->cullMode = cullMode;
context->frontFacingCCW = frontFacingCCW;
}
void PixelProcessor::setColorWriteMask(int index, int rgbaMask)
......@@ -1041,6 +1042,8 @@ namespace sw
state.centroid = context->pixelShader->containsCentroid();
}
state.frontFaceCCW = context->frontFacingCCW;
if(!context->pixelShader)
{
for(unsigned int i = 0; i < 8; i++)
......
......@@ -83,6 +83,7 @@ namespace sw
unsigned int multiSampleMask : 4;
TransparencyAntialiasing transparencyAntialiasing : BITS(TRANSPARENCY_LAST);
bool centroid : 1;
bool frontFaceCCW : 1;
LogicalOperation logicalOperation : BITS(LOGICALOP_LAST);
......@@ -250,7 +251,7 @@ namespace sw
void setAlphaCompare(AlphaCompareMode alphaCompareMode);
void setDepthWriteEnable(bool depthWriteEnable);
void setAlphaTestEnable(bool alphaTestEnable);
void setCullMode(CullMode cullMode);
void setCullMode(CullMode cullMode, bool frontFacingCCW);
void setColorWriteMask(int index, int rgbaMask);
void setColorLogicOpEnabled(bool colorLogicOpEnabled);
......
......@@ -51,8 +51,12 @@ namespace sw
if(shader->isVFaceDeclared())
{
Float4 area = *Pointer<Float>(primitive + OFFSET(Primitive, area));
Float4 face = booleanFaceRegister ? Float4(As<Float4>(CmpNLT(area, Float4(0.0f)))) : area;
Float4 face = *Pointer<Float>(primitive + OFFSET(Primitive, area));
if(booleanFaceRegister)
{
face = As<Float4>(state.frontFaceCCW ? CmpNLT(face, Float4(0.0f)) : CmpLT(face, Float4(0.0f)));
}
vFace.x = face;
vFace.y = face;
......
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