2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
10 <meta charset=
"utf-8">
11 <title>WebGL Disabled Vertex Attrib Update Test
</title>
12 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
13 <script src=
"../../js/js-test-pre.js"></script>
14 <script src=
"../../js/webgl-test-utils.js"> </script>
17 <canvas id=
"example" width=
"50" height=
"50">
19 <div id=
"description"></div>
20 <div id=
"console"></div>
21 <script id=
"vshader" type=
"x-shader/x-vertex">
22 attribute vec4 a_position;
23 attribute float a_actualValue;
24 uniform float u_expectedValue;
25 varying float v_result;
27 gl_Position = a_position;
28 v_result = a_actualValue == u_expectedValue ?
1.0 :
0.0;
32 <script id=
"fshader" type=
"x-shader/x-fragment">
33 precision mediump float;
34 varying float v_result;
36 gl_FragColor = v_result
> 0.0 ? vec4(
0.0,
1.0,
0.0,
1.0) : vec4(
1.0,
0.0,
0.0,
1.0);
41 // Tests that repeatedly updating a disabled vertex attribute works as expected.
42 // This covers an ANGLE bug where dirty bits for current values were ignoring repeated updates.
43 // Based on ANGLE test (VertexAttributeTest, DisabledAttribUpdates) from https://github.com/google/angle/blob/f7f0b8c3ab21c52cc2915048959361cf628d95f0/src/tests/gl_tests/VertexAttributeTest.cpp
45 var wtu
= WebGLTestUtils
;
48 var gl
= wtu
.create3DContext("example");
50 var program
= wtu
.setupProgram(gl
, ['vshader', 'fshader']);
51 gl
.useProgram(program
);
53 var positionLocation
= gl
.getAttribLocation(program
, "a_position");
54 var attribLoc
= gl
.getAttribLocation(program
, "a_actualValue");
55 gl
.vertexAttribPointer(attribLoc
, 1, gl
.FLOAT
, gl
.FALSE
, 0, 0);
57 var uniLoc
= gl
.getUniformLocation(program
, "u_expectedValue");
60 wtu
.setupIndexedQuad(gl
, gridRes
, positionLocation
);
62 var testValues
= [1, 2, 3, 4];
63 for (var i
= 0; i
< testValues
.length
; ++i
) {
64 var testValue
= testValues
[i
];
65 gl
.uniform1f(uniLoc
, testValue
);
66 gl
.vertexAttrib1f(attribLoc
, testValue
);
67 wtu
.clearAndDrawIndexedQuad(gl
, gridRes
);
68 wtu
.checkCanvas(gl
, [0, 255, 0, 255], "should be green");
71 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "should be no errors");
73 var successfullyParsed
= true;
75 <script src=
"../../js/js-test-post.js"></script>