Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / webgl / src / sdk / tests / conformance / programs / use-program-crash-with-discard-in-fragment-shader.html
1 <!--
2
3 /*
4 ** Copyright (c) 2012 The Khronos Group Inc.
5 **
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:
13 **
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
16 **
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.
24 */
25
26 -->
27
28 <!DOCTYPE html>
29 <html>
30 <head>
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>
36 </head>
37 <body>
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">
42 attribute vec4 ATTR0;
43 void main()
44 {
45   gl_Position = ATTR0;
46 }
47 </script>
48 <script id="fragmentShader" language="x-shader/x-fragment">
49 precision mediump float;
50 void main()
51 {
52   float _Intensity = exp2(gl_FragCoord.w);
53   if (_Intensity < 0.5) {
54     discard;
55   }
56   gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
57 }
58 </script>
59 <script>
60 "use strict";
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>');
62
63 debug("");
64
65 var wtu = WebGLTestUtils;
66 var gl = wtu.create3DContext("canvas");
67 if (!gl) {
68   testFailed("context does not exist");
69 } else {
70   testPassed("context exists");
71 }
72
73 debug("");
74
75 var program = wtu.loadProgramFromScript(gl, 'vertexShader', 'fragmentShader');
76 if (program) {
77   testPassed("Program linked successfully");
78 } else {
79   testFailed("Program failed to link");
80 }
81
82 // Crash occurs here on affected machines
83 gl.useProgram(program);
84
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");
92
93 var successfullyParsed = true;
94 </script>
95 <script src="../../resources/js-test-post.js"></script>
96
97 </body>
98 </html>