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.
10 <meta charset=
"utf-8">
11 <title>WebGL Program Conformance Tests
</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 <div id=
"description"></div>
18 <div id=
"console"></div>
19 <canvas id=
"canvas" width=
"2" height=
"2"> </canvas>
20 <script id=
"vertexShader" language=
"x-shader/x-vertex">
27 <script id=
"fragmentShader" language=
"x-shader/x-fragment">
28 precision mediump float;
31 float _Intensity = exp2(gl_FragCoord.w);
32 if (_Intensity <
0.5) {
35 gl_FragColor = vec4(
1.0,
0.0,
0.0,
1.0);
40 description('Regression test for crash in Mac OS AMD OpenGL driver related to use of discard in fragment shader.<br><br>More specifically, triggering the crash seems to require examination of gl_FragCoord.w, use of exp2, and a call to discard in the fragment shader. Thanks to Sheheryar Zakaria and Michael Braithwaite at Turbulenz for the original test case.<br><a href="https://bugs.webkit.org/show_bug.cgi?id=73932">WebKit bug 73932</a><br>');
44 var wtu
= WebGLTestUtils
;
45 var gl
= wtu
.create3DContext("canvas");
47 testFailed("context does not exist");
49 testPassed("context exists");
54 var program
= wtu
.loadProgramFromScript(gl
, 'vertexShader', 'fragmentShader');
56 testPassed("Program linked successfully");
58 testFailed("Program failed to link");
61 // Crash occurs here on affected machines
62 gl
.useProgram(program
);
64 // In some browsers, such as Chrome, the above crash only causes a
65 // lost context event to be dispatched, and not synchronously. To verify
66 // that everything worked, clear and read back the frame buffer.
67 gl
.clearColor(1.0, 0.0, 0.0, 1.0);
68 gl
.clear(gl
.COLOR_BUFFER_BIT
);
69 wtu
.checkCanvasRect(gl
, 0, 0, 1, 1, [255, 0, 0, 255],
70 "Color should be red");
72 var successfullyParsed
= true;
74 <script src=
"../../js/js-test-post.js"></script>