Backed out changeset b462e7b742d8 (bug 1908261) for causing multiple reftest failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / attribs / gl-disabled-vertex-attrib-update.html
blob3ef12fb9aa508a113a226921185bb0f921fb730a
1 <!--
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.
5 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
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>
15 </head>
16 <body>
17 <canvas id="example" width="50" height="50">
18 </canvas>
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;
26 void main() {
27 gl_Position = a_position;
28 v_result = a_actualValue == u_expectedValue ? 1.0 : 0.0;
30 </script>
32 <script id="fshader" type="x-shader/x-fragment">
33 precision mediump float;
34 varying float v_result;
35 void main() {
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);
38 </script>
40 <script>
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
44 "use strict";
45 var wtu = WebGLTestUtils;
46 description();
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");
59 var gridRes = 1;
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;
74 </script>
75 <script src="../../js/js-test-post.js"></script>
77 </body>
78 </html>