Commit 2900c3be by Luc Ferron Committed by Commit Bot

Vulkan: Add culling rasterization states tests and invert front face

Bug: angleproject:2352 Change-Id: I0ac83f3173d22a2ee8bc98d2fd7bfa1875d46b8c Reviewed-on: https://chromium-review.googlesource.com/912358Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Luc Ferron <lucferron@chromium.org>
parent d50537a7
...@@ -1332,15 +1332,16 @@ VkCullModeFlags GetCullMode(const gl::RasterizerState &rasterState) ...@@ -1332,15 +1332,16 @@ VkCullModeFlags GetCullMode(const gl::RasterizerState &rasterState)
VkFrontFace GetFrontFace(GLenum frontFace) VkFrontFace GetFrontFace(GLenum frontFace)
{ {
// Invert CW and CCW to have the same behavior as OpenGL.
switch (frontFace) switch (frontFace)
{ {
case GL_CW: case GL_CW:
return VK_FRONT_FACE_CLOCKWISE;
case GL_CCW:
return VK_FRONT_FACE_COUNTER_CLOCKWISE; return VK_FRONT_FACE_COUNTER_CLOCKWISE;
case GL_CCW:
return VK_FRONT_FACE_CLOCKWISE;
default: default:
UNREACHABLE(); UNREACHABLE();
return VK_FRONT_FACE_COUNTER_CLOCKWISE; return VK_FRONT_FACE_CLOCKWISE;
} }
} }
......
...@@ -64,6 +64,43 @@ void SimpleOperationTest::verifyBuffer(const std::vector<uint8_t> &data, GLenum ...@@ -64,6 +64,43 @@ void SimpleOperationTest::verifyBuffer(const std::vector<uint8_t> &data, GLenum
EXPECT_EQ(data, readbackData); EXPECT_EQ(data, readbackData);
} }
// Validates if culling rasterization states work. Simply draws a quad with
// cull face enabled and make sure we still render correctly.
TEST_P(SimpleOperationTest, CullFaceEnabledState)
{
ANGLE_GL_PROGRAM(program, kBasicVertexShader, kGreenFragmentShader);
glUseProgram(program);
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_CULL_FACE);
drawQuad(program.get(), "position", 0.0f, 1.0f, true);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
}
// Validates if culling rasterization states work. Simply draws a quad with
// cull face enabled with cullface front and make sure the face have not been rendered.
TEST_P(SimpleOperationTest, CullFaceFrontEnabledState)
{
ANGLE_GL_PROGRAM(program, kBasicVertexShader, kGreenFragmentShader);
glUseProgram(program);
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_CULL_FACE);
// Should make the quad disappear since we draw it front facing.
glCullFace(GL_FRONT);
drawQuad(program.get(), "position", 0.0f, 1.0f, true);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::transparentBlack);
}
// Validates if blending render states work. Simply draws twice and verify the color have been // Validates if blending render states work. Simply draws twice and verify the color have been
// added in the final output. // added in the final output.
TEST_P(SimpleOperationTest, BlendingRenderState) TEST_P(SimpleOperationTest, BlendingRenderState)
......
...@@ -1067,6 +1067,33 @@ TEST_P(SimpleStateChangeTest, RedefineFramebufferInUse) ...@@ -1067,6 +1067,33 @@ TEST_P(SimpleStateChangeTest, RedefineFramebufferInUse)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
} }
// Validates disabling cull face really disables it.
TEST_P(SimpleStateChangeTest, EnableAndDisableCullFace)
{
ANGLE_GL_PROGRAM(program, kSolidColorVertexShader, kSolidColorFragmentShader);
glUseProgram(program);
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
drawQuad(program.get(), "position", 0.0f, 1.0f, true);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::transparentBlack);
// Disable cull face and redraw, then make sure we have the quad drawn.
glDisable(GL_CULL_FACE);
drawQuad(program.get(), "position", 0.0f, 1.0f, true);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
}
TEST_P(SimpleStateChangeTest, ScissorTest) TEST_P(SimpleStateChangeTest, ScissorTest)
{ {
// This test validates this order of state changes: // This test validates this order of state changes:
......
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