Commit 83aec70b by Geoff Lang Committed by Jamie Madill

Sync the D3D11 rasterizer state if pointDrawMode or multisample changes.

When drawing points, culling is disabled to make sure the generated point sprites are not culled. Since there are no dirty bits for pointDrawMode or multiSample, they were not being checked to ensure the rasterizer state was correct. BUG=586531 Change-Id: I8fe60dd8d5bbc79b1bce2c0aa62c40cee560fe24 Reviewed-on: https://chromium-review.googlesource.com/327862Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/330196Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 5fc4e56d
......@@ -453,7 +453,9 @@ gl::Error StateManager11::setDepthStencilState(const gl::State &glState)
gl::Error StateManager11::setRasterizerState(const gl::RasterizerState &rasterState)
{
if (!mRasterizerStateIsDirty)
// TODO: Remove pointDrawMode and multiSample from gl::RasterizerState.
if (!mRasterizerStateIsDirty && rasterState.pointDrawMode == mCurRasterState.pointDrawMode &&
rasterState.multiSample == mCurRasterState.multiSample)
{
return gl::Error(GL_NO_ERROR);
}
......
......@@ -432,6 +432,84 @@ TEST_P(PointSpritesTest, PointSizeDeclaredButUnused)
glDeleteProgram(program);
}
// Test to cover a bug where the D3D11 rasterizer state would not be update when switching between
// draw types. This causes the cull face to potentially be incorrect when drawing emulated point
// spites.
TEST_P(PointSpritesTest, PointSpriteAlternatingDrawTypes)
{
// clang-format off
const std::string pointFS = SHADER_SOURCE
(
precision mediump float;
void main()
{
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
}
);
const std::string pointVS = SHADER_SOURCE
(
void main()
{
gl_PointSize = 16.0;
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
}
);
const std::string quadFS = SHADER_SOURCE
(
precision mediump float;
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
);
const std::string quadVS = SHADER_SOURCE
(
precision mediump float;
attribute vec4 pos;
void main()
{
gl_Position = pos;
}
);
// clang-format on
GLuint pointProgram = CompileProgram(pointVS, pointFS);
ASSERT_NE(pointProgram, 0u);
ASSERT_GL_NO_ERROR();
GLuint quadProgram = CompileProgram(quadVS, quadFS);
ASSERT_NE(pointProgram, 0u);
ASSERT_GL_NO_ERROR();
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
const GLfloat quadVertices[] = {
-1.0f, 1.0f, 0.5f, 1.0f, -1.0f, 0.5f, -1.0f, -1.0f, 0.5f,
-1.0f, 1.0f, 0.5f, 1.0f, 1.0f, 0.5f, 1.0f, -1.0f, 0.5f,
};
glUseProgram(quadProgram);
GLint positionLocation = glGetAttribLocation(quadProgram, "pos");
glVertexAttribPointer(positionLocation, 3, GL_FLOAT, GL_FALSE, 0, quadVertices);
glEnableVertexAttribArray(positionLocation);
glDrawArrays(GL_TRIANGLES, 0, 6);
glUseProgram(pointProgram);
glDrawArrays(GL_POINTS, 0, 1);
ASSERT_GL_NO_ERROR();
// expect the center pixel to be green
EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 0, 255, 0, 255);
glDeleteProgram(pointProgram);
glDeleteProgram(quadProgram);
}
// Use this to select which configurations (e.g. which renderer, which GLES
// major version) these tests should be run against.
//
......
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