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.
10 <meta charset=
"utf-8">
11 <title>Verify precision side effects (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>
17 <canvas id=
"canvas" width=
"2" height=
"2"> </canvas>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
21 <script id=
"vshader-simple" type=
"x-shader/x-vertex">#version
300 es
25 gl_Position = vec4(aPosition,
1.0);
28 <script id=
"fshader-int" type=
"x-shader/x-fragment">#version
300 es
29 out highp vec4 myFragColor;
32 t =
0 | (int(t == t) *
0x8000);
35 myFragColor = vec4(
1.0,
0.0,
0.0,
1.0);
37 myFragColor = vec4(
0.0,
0.0,
0.0,
1.0);
40 <script id=
"fshader-ivec2" type=
"x-shader/x-fragment">#version
300 es
41 out highp vec4 myFragColor;
44 t =
0 | (ivec2(t == t) *
0x8000);
46 if (t == ivec2(
0x8000))
47 myFragColor = vec4(
1.0,
0.0,
0.0,
1.0);
49 myFragColor = vec4(
0.0,
0.0,
0.0,
1.0);
52 <script id=
"fshader-ivec3" type=
"x-shader/x-fragment">#version
300 es
53 out highp vec4 myFragColor;
56 t =
0 | (ivec3(t == t) *
0x8000);
58 if (t == ivec3(
0x8000))
59 myFragColor = vec4(
1.0,
0.0,
0.0,
1.0);
61 myFragColor = vec4(
0.0,
0.0,
0.0,
1.0);
64 <script id=
"fshader-ivec4" type=
"x-shader/x-fragment">#version
300 es
65 out highp vec4 myFragColor;
68 t =
0 | (ivec4(t == t) *
0x8000);
70 if (t == ivec4(
0x8000))
71 myFragColor = vec4(
1.0,
0.0,
0.0,
1.0);
73 myFragColor = vec4(
0.0,
0.0,
0.0,
1.0);
76 <script type=
"application/javascript">
78 description(
"Verify precision side effects");
80 debug(
"When this test is run on Adreno (no repros on other vendors so far):");
81 debug(
" - the result of the expression 0 | (int(e0 == e0) * 0x8000) somehow returns -32768 instead of 32768 despite the variable using highp precision;");
82 debug(
" - splitting the expression along | fixes the issue (could also be observed with other operators).");
83 debug('For additional reference see this
<a href=
"https://github.com/KhronosGroup/WebGL/pull/3192">pull request
</a> and
<a href=
"http://crbug.com/1155942">Chromium bug
</a>');
85 var wtu = WebGLTestUtils;
87 var gl = wtu.create3DContext(
"canvas", undefined,
2);
89 testFailed(
"context does not exist");
92 wtu.setupUnitQuad(gl);
95 { vshader:
"vshader-simple", fshader:
"fshader-int", desc:
"fragment shader int" },
96 { vshader:
"vshader-simple", fshader:
"fshader-ivec2", desc:
"fragment shader ivec2" },
97 { vshader:
"vshader-simple", fshader:
"fshader-ivec3", desc:
"fragment shader ivec3" },
98 { vshader:
"vshader-simple", fshader:
"fshader-ivec4", desc:
"fragment shader ivec4" },
101 for (var idx =
0; idx < testCases.length; ++idx) {
102 var test = testCases[idx];
105 var program = wtu.setupProgram(gl, [test.vshader, test.fshader], [
"aPosition"]);
107 testFailed(
"Fail to set up program");
109 debug(
"Testing " + test.desc);
110 wtu.drawUnitQuad(gl);
111 wtu.checkCanvas(gl, [
255,
0,
0,
255]);
112 gl.deleteProgram(program);
113 wtu.glErrorShouldBe(gl, gl.NO_ERROR,
"Should be no errors from testing");
121 var successfullyParsed = true;
123 <script src=
"../../js/js-test-post.js"></script>