Commit d2452555 by Chris Forbes

Wire up cull mode handling to Vulkan pipeline

Bug: b/124177079 Change-Id: I8e55607c8ff7f9c2d2356268bedf170cf27eeb99 Reviewed-on: https://swiftshader-review.googlesource.com/c/25268Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 222871ae
......@@ -177,7 +177,7 @@ namespace sw
int stencilWriteMaskCCW;
// Pixel processor states
CullMode cullMode;
VkCullModeFlags cullMode;
bool frontFacingCCW;
float alphaReference;
......
......@@ -82,6 +82,7 @@ namespace sw
state.interpolateZ = context->depthBufferActive() || vPosZW;
state.interpolateW = context->perspectiveActive() || vPosZW;
state.perspective = context->perspectiveActive();
state.frontFacingCCW = context->frontFacingCCW;
state.cullMode = context->cullMode;
state.twoSidedStencil = context->stencilActive() && context->twoSidedStencil;
state.slopeDepthBias = context->slopeDepthBias != 0.0f;
......
......@@ -42,7 +42,8 @@ namespace sw
bool interpolateZ : 1;
bool interpolateW : 1;
bool perspective : 1;
CullMode cullMode : BITS(CULL_LAST);
bool frontFacingCCW : 1;
VkCullModeFlags cullMode : BITS(VK_CULL_MODE_FLAG_BITS_MAX_ENUM);
bool twoSidedStencil : 1;
bool slopeDepthBias : 1;
bool vFace : 1;
......
......@@ -96,20 +96,22 @@ namespace sw
A = IfThenElse(w0w1w2 < 0, -A, A);
if(state.cullMode == CULL_CLOCKWISE)
Bool frontFacing = state.frontFacingCCW ? A > 0.0f : A < 0.0f;
if(state.cullMode & VK_CULL_MODE_FRONT_BIT)
{
If(A >= 0.0f) Return(false);
If(frontFacing) Return(false);
}
else if(state.cullMode == CULL_COUNTERCLOCKWISE)
if(state.cullMode & VK_CULL_MODE_BACK_BIT)
{
If(A <= 0.0f) Return(false);
If(!frontFacing) Return(false);
}
d = IfThenElse(A < 0.0f, d, Int(0));
if(state.twoSidedStencil)
{
If(A > 0.0f)
If(frontFacing)
{
*Pointer<Byte8>(primitive + OFFSET(Primitive,clockwiseMask)) = Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
*Pointer<Byte8>(primitive + OFFSET(Primitive,invClockwiseMask)) = Byte8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
......
......@@ -289,6 +289,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
}
context.rasterizerDiscard = rasterizationState->rasterizerDiscardEnable;
context.cullMode = rasterizationState->cullMode;
context.frontFacingCCW = rasterizationState->frontFace == VK_FRONT_FACE_COUNTER_CLOCKWISE;
context.depthBias = (rasterizationState->depthBiasEnable ? rasterizationState->depthBiasConstantFactor : 0.0f);
context.slopeDepthBias = (rasterizationState->depthBiasEnable ? rasterizationState->depthBiasSlopeFactor : 0.0f);
......
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