4 ** Copyright (c) 2012 The Khronos Group Inc.
6 ** Permission is hereby granted, free of charge, to any person obtaining a
7 ** copy of this software and/or associated documentation files (the
8 ** "Materials"), to deal in the Materials without restriction, including
9 ** without limitation the rights to use, copy, modify, merge, publish,
10 ** distribute, sublicense, and/or sell copies of the Materials, and to
11 ** permit persons to whom the Materials are furnished to do so, subject to
12 ** the following conditions:
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
31 <meta charset="utf-8">
32 <title>WebGL Program Conformance Tests</title>
33 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
34 <script src="../../resources/js-test-pre.js"></script>
35 <script src="../resources/webgl-test-utils.js"></script>
38 <div id="description"></div>
39 <div id="console"></div>
40 <canvas id="canvas" width="2" height="2"> </canvas>
41 <script id="vertexShader" language="x-shader/x-vertex">
48 <script id="fragmentShader" language="x-shader/x-fragment">
49 precision mediump float;
52 float _Intensity = exp2(gl_FragCoord.w);
53 if (_Intensity < 0.5) {
56 gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
61 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>');
65 var wtu = WebGLTestUtils;
66 var gl = wtu.create3DContext("canvas");
68 testFailed("context does not exist");
70 testPassed("context exists");
75 var program = wtu.loadProgramFromScript(gl, 'vertexShader', 'fragmentShader');
77 testPassed("Program linked successfully");
79 testFailed("Program failed to link");
82 // Crash occurs here on affected machines
83 gl.useProgram(program);
85 // In some browsers, such as Chrome, the above crash only causes a
86 // lost context event to be dispatched, and not synchronously. To verify
87 // that everything worked, clear and read back the frame buffer.
88 gl.clearColor(1.0, 0.0, 0.0, 1.0);
89 gl.clear(gl.COLOR_BUFFER_BIT);
90 wtu.checkCanvasRect(gl, 0, 0, 1, 1, [255, 0, 0, 255],
91 "Color should be red");
93 var successfullyParsed = true;
95 <script src="../../resources/js-test-post.js"></script>