Bug 1945965 – remove new tab April Fools logo. r=home-newtab-reviewers,reemhamz
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / glsl / matrices / matrix-compound-multiply.html
bloba485160c569db5de30c84ff72f9a0c7ff1ccd0b9
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>Matrix compound multiplication 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="canvas" width="256" height="256"> </canvas>
18 <div id="description"></div>
19 <div id="console"></div>
20 <script id="vshader" type="x-shader/x-vertex">
21 attribute vec3 aPosition;
23 void main() {
24 gl_Position = vec4(aPosition, 1);
26 </script>
27 <script id="fshader" type="x-shader/x-fragment">
28 precision mediump float;
30 void main() {
31 $(type) a = $(type)(0.0);
32 $(type) b = $(type)(0.0);
33 a[1][1] = 3.0; // 2nd column, 2nd row
34 b[0][1] = 2.0; // 1st column, 2nd row
35 $(type) c = a * b;
36 a *= b;
37 $(type) diffMat = a - c;
38 float diff = length(diffMat[0]) + length(diffMat[1]);
39 gl_FragColor = vec4(0.0, diff < 0.01 ? 1.0 : 0.0, 0.0, 1.0);
41 </script>
42 <script type="application/javascript">
43 "use strict";
44 description("Matrix compound multiplication test comparing against normal multiplication.");
45 debug("");
46 var wtu = WebGLTestUtils;
47 function test() {
48 var gl = wtu.create3DContext("canvas");
49 if (!gl) {
50 testFailed("context does not exist");
51 return;
53 wtu.setupUnitQuad(gl);
54 var fshaderTemplate = wtu.getScript('fshader');
56 var types = ['mat2', 'mat3', 'mat4'];
57 for (var i = 0; i < types.length; ++i) {
58 debug('');
59 debug('Testing type ' + types[i]);
60 var fshaderSource = wtu.replaceParams(fshaderTemplate, {type: types[i]});
61 var program = wtu.setupProgram(gl, ['vshader', fshaderSource], ["aPosition"], undefined, true);
62 wtu.drawUnitQuad(gl);
63 wtu.checkCanvas(gl, [0, 255, 0, 255], 'should be green');
67 test();
68 finishTest();
69 </script>
70 </body>
71 </html>