@@ -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.
337387TEST_P (StateChangeTestES3, CopyTexSubImage3DSync)
338388{
0 commit comments