Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance2 / glsl3 / uint-int-shift-bug.html
blob499d266e7bf28d489c842628e9961f88f8b0cb72
1 <!--
2 Copyright (c) 2020 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>Verify (uint(int) >> 31) works correctly (Adreno driver bug)</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="2" height="2"> </canvas>
18 <div id="description"></div>
19 <div id="console"></div>
20 <script id="vshader-uint-1" type="x-shader/x-vertex">#version 300 es
21 in vec3 aPosition;
22 flat out highp uint uvalue;
23 uniform highp int ivalue;
25 void main() {
26 gl_Position = vec4(aPosition, 1);
27 uvalue = uint(ivalue) >> 31u;
29 </script>
30 <script id="fshader-uint-1" type="x-shader/x-fragment">#version 300 es
31 flat in highp uint uvalue;
32 out highp vec4 myFragColor;
34 void main() {
35 if (uvalue == 1u)
36 myFragColor = vec4(1.0, 0.0, 0.0, 1.0);
37 else
38 myFragColor = vec4(0.0, 0.0, 0.0, 1.0);
40 </script>
42 <script id="vshader-simple" type="x-shader/x-vertex">#version 300 es
43 in vec3 aPosition;
45 void main() {
46 gl_Position = vec4(aPosition, 1);
48 </script>
49 <script id="fshader-uint-2" type="x-shader/x-fragment">#version 300 es
50 uniform highp int ivalue;
51 out highp vec4 myFragColor;
53 void main() {
54 uint uvalue = uint(ivalue) >> 31u;
56 if (uvalue == 1u)
57 myFragColor = vec4(1.0, 0.0, 0.0, 1.0);
58 else
59 myFragColor = vec4(0.0, 0.0, 0.0, 1.0);
61 </script>
63 <script type="application/javascript">
64 "use strict";
65 description("Verify (uint(int) >> 31) works correctly");
66 debug("");
67 var wtu = WebGLTestUtils;
68 function test() {
69 var gl = wtu.create3DContext("canvas", undefined, 2);
70 if (!gl) {
71 testFailed("context does not exist");
72 return;
74 wtu.setupUnitQuad(gl);
76 var testCases = [
77 { vshader: "vshader-uint-1", fshader: "fshader-uint-1", desc: "vertex shader uint" },
78 { vshader: "vshader-simple", fshader: "fshader-uint-2", desc: "fragment shader uint" },
81 for (var idx = 0; idx < testCases.length; ++idx) {
82 var test = testCases[idx];
84 debug("");
85 var program = wtu.setupProgram(gl, [test.vshader, test.fshader], ["aPosition"]);
86 if (!program) {
87 testFailed("Fail to set up program");
88 } else {
89 var uniformLoc = gl.getUniformLocation(program, 'ivalue');
90 gl.uniform1i(uniformLoc, -1);
91 wtu.drawUnitQuad(gl);
92 wtu.checkCanvas(gl, [255, 0, 0, 255]);
93 gl.deleteProgram(program);
94 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from testing");
99 test();
101 debug("");
102 var successfullyParsed = true;
103 </script>
104 <script src="../../js/js-test-post.js"></script>
105 </body>
106 </html>