Backed out changeset b462e7b742d8 (bug 1908261) for causing multiple reftest failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / programs / gl-get-active-attribute.html
blob76dc422eaebb055b6b222e451c5971e45f51efaa
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 getActiveAttrib conformance 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="16" height="16"></canvas>
18 <div id="description"></div>
19 <div id="console"></div>
20 <script id="vshader" type="x-shader/x-vertex">
21 attribute $type attr0;
22 void main()
24 gl_Position = vec4(0, 0, 0, attr0$access);
26 </script>
27 <script id="fshader" type="x-shader/x-fragment">
28 void main()
30 gl_FragColor = vec4(0,1,0,1);
32 </script>
33 <script>
34 "use strict";
35 description("Tests getActiveAttrib for various types");
37 var wtu = WebGLTestUtils;
38 var gl = wtu.create3DContext("example");
40 var tests = [
41 { glType: gl.FLOAT, size: 1, type: 'float', access: ''},
42 { glType: gl.FLOAT_VEC2, size: 1, type: 'vec2', access: '[1]'},
43 { glType: gl.FLOAT_VEC3, size: 1, type: 'vec3', access: '[2]'},
44 { glType: gl.FLOAT_VEC4, size: 1, type: 'vec4', access: '[3]'},
45 { glType: gl.FLOAT_MAT2, size: 1, type: 'mat2', access: '[1][1]'},
46 { glType: gl.FLOAT_MAT3, size: 1, type: 'mat3', access: '[2][2]'},
47 { glType: gl.FLOAT_MAT4, size: 1, type: 'mat4', access: '[3][3]'},
50 var source = document.getElementById('vshader').text;
51 var fs = wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER);
52 for (var tt = 0; tt < tests.length; ++tt) {
53 var t = tests[tt];
54 var vs = wtu.loadShader(
55 gl,
56 source.replace('$type', t.type).replace('$access', t.access),
57 gl.VERTEX_SHADER);
58 var program = wtu.setupProgram(gl, [vs, fs]);
59 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no errors from setup");
60 var numAttribs = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
61 var found = false;
62 for (var ii = 0; ii < numAttribs; ++ii) {
63 var info = gl.getActiveAttrib(program, ii);
64 if (info.name == 'attr0') {
65 found = true;
66 assertMsg(info.type == t.glType,
67 "type must be " + wtu.glEnumToString(gl, t.glType) + " was " +
68 wtu.glEnumToString(gl, info.type));
69 assertMsg(info.size == t.size,
70 "size must be " + t.size + ' was ' + info.size);
73 if (!found) {
74 testFailed("attrib 'attr0' not found");
78 var successfullyParsed = true;
79 </script>
80 <script src="../../js/js-test-post.js"></script>
82 </body>
83 </html>