Skip to content

Commit 7ef0839

Browse files
ShabbyXCommit Bot
authored andcommitted
Vulkan: add test to verify attrib default value dirty handling
Companion test to 0c2dc8c. Bug: angleproject:2786 Change-Id: Idfbd557dcf6b6bf7e62821ec554bdb3138b616ab Reviewed-on: https://chromium-review.googlesource.com/c/1367750 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
1 parent 5c4af66 commit 7ef0839

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

src/tests/gl_tests/StateChangeTest.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,56 @@ TEST_P(StateChangeTest, DisablingBufferedVertexAttribute)
333333
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
334334
}
335335

336+
// Tests that setting value for a subset of default attributes doesn't affect others.
337+
TEST_P(StateChangeTest, SetCurrentAttribute)
338+
{
339+
constexpr char kVS[] = R"(attribute vec4 position;
340+
attribute mat4 testAttrib; // Note that this generates 4 attributes
341+
varying vec4 testVarying;
342+
void main (void)
343+
{
344+
gl_Position = position;
345+
346+
testVarying = position.y < 0.0 ?
347+
position.x < 0.0 ? testAttrib[0] : testAttrib[1] :
348+
position.x < 0.0 ? testAttrib[2] : testAttrib[3];
349+
})";
350+
351+
ANGLE_GL_PROGRAM(program, kVS, kSimpleAttributeFS);
352+
glUseProgram(program);
353+
GLint attribLoc = glGetAttribLocation(program, "testAttrib");
354+
GLint positionLoc = glGetAttribLocation(program, "position");
355+
ASSERT_NE(-1, attribLoc);
356+
ASSERT_NE(-1, positionLoc);
357+
358+
// Set the current value of two of the test attributes, while leaving the other two as default.
359+
glVertexAttrib4f(attribLoc + 1, 0.0f, 1.0f, 0.0f, 1.0f);
360+
glVertexAttrib4f(attribLoc + 2, 0.0f, 0.0f, 1.0f, 1.0f);
361+
362+
// Set up the position attribute.
363+
setupQuadVertexBuffer(0.5f, 1.0f);
364+
glEnableVertexAttribArray(positionLoc);
365+
glVertexAttribPointer(positionLoc, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
366+
367+
// Draw and verify the four section in the output:
368+
//
369+
// +---------------+
370+
// | Black | Green |
371+
// +-------+-------+
372+
// | Blue | Black |
373+
// +---------------+
374+
//
375+
glDrawArrays(GL_TRIANGLES, 0, 6);
376+
377+
const int w = getWindowWidth();
378+
const int h = getWindowHeight();
379+
constexpr unsigned int kPixelTolerance = 5u;
380+
EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor::black, kPixelTolerance);
381+
EXPECT_PIXEL_COLOR_NEAR(w - 1, 0, GLColor::green, kPixelTolerance);
382+
EXPECT_PIXEL_COLOR_NEAR(0, h - 1, GLColor::blue, kPixelTolerance);
383+
EXPECT_PIXEL_COLOR_NEAR(w - 1, h - 1, GLColor::black, kPixelTolerance);
384+
}
385+
336386
// Ensure that CopyTexSubImage3D syncs framebuffer changes.
337387
TEST_P(StateChangeTestES3, CopyTexSubImage3DSync)
338388
{

0 commit comments

Comments
 (0)