Commit 7ef08391 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: add test to verify attrib default value dirty handling

Companion test to 0c2dc8c3. Bug: angleproject:2786 Change-Id: Idfbd557dcf6b6bf7e62821ec554bdb3138b616ab Reviewed-on: https://chromium-review.googlesource.com/c/1367750 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 5c4af666
...@@ -333,6 +333,56 @@ TEST_P(StateChangeTest, DisablingBufferedVertexAttribute) ...@@ -333,6 +333,56 @@ TEST_P(StateChangeTest, DisablingBufferedVertexAttribute)
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
} }
// Tests that setting value for a subset of default attributes doesn't affect others.
TEST_P(StateChangeTest, SetCurrentAttribute)
{
constexpr char kVS[] = R"(attribute vec4 position;
attribute mat4 testAttrib; // Note that this generates 4 attributes
varying vec4 testVarying;
void main (void)
{
gl_Position = position;
testVarying = position.y < 0.0 ?
position.x < 0.0 ? testAttrib[0] : testAttrib[1] :
position.x < 0.0 ? testAttrib[2] : testAttrib[3];
})";
ANGLE_GL_PROGRAM(program, kVS, kSimpleAttributeFS);
glUseProgram(program);
GLint attribLoc = glGetAttribLocation(program, "testAttrib");
GLint positionLoc = glGetAttribLocation(program, "position");
ASSERT_NE(-1, attribLoc);
ASSERT_NE(-1, positionLoc);
// Set the current value of two of the test attributes, while leaving the other two as default.
glVertexAttrib4f(attribLoc + 1, 0.0f, 1.0f, 0.0f, 1.0f);
glVertexAttrib4f(attribLoc + 2, 0.0f, 0.0f, 1.0f, 1.0f);
// Set up the position attribute.
setupQuadVertexBuffer(0.5f, 1.0f);
glEnableVertexAttribArray(positionLoc);
glVertexAttribPointer(positionLoc, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
// Draw and verify the four section in the output:
//
// +---------------+
// | Black | Green |
// +-------+-------+
// | Blue | Black |
// +---------------+
//
glDrawArrays(GL_TRIANGLES, 0, 6);
const int w = getWindowWidth();
const int h = getWindowHeight();
constexpr unsigned int kPixelTolerance = 5u;
EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor::black, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(w - 1, 0, GLColor::green, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(0, h - 1, GLColor::blue, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(w - 1, h - 1, GLColor::black, kPixelTolerance);
}
// Ensure that CopyTexSubImage3D syncs framebuffer changes. // Ensure that CopyTexSubImage3D syncs framebuffer changes.
TEST_P(StateChangeTestES3, CopyTexSubImage3DSync) TEST_P(StateChangeTestES3, CopyTexSubImage3DSync)
{ {
......
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