Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / webgl / src / sdk / tests / conformance / glsl / bugs / fragcoord-linking-bug.html
1 <!--
2
3 /*
4 ** Copyright (c) 2014 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>GLSL compiler bug referencing gl_FragCoord</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 <!-- These shaders were extracted from Skia's GPU accelerated backend "Ganesh". -->
39 <script id="shader-vs" type="x-shader/x-vertex">
40 uniform mat3 uViewM;
41 uniform mat3 uStageMatrix_Stage1;
42 uniform vec4 urtAdjustment;
43 attribute vec2 aPosition;
44 attribute vec4 aColor;
45 varying vec4 vColor;
46 varying vec2 vMatrixCoord_Stage1;
47 void main() {
48     vec3 pos3 = uViewM * vec3(aPosition, 1);
49     vColor = aColor;
50     { // Stage 0: XferEffect
51     }
52     vMatrixCoord_Stage1 = (uStageMatrix_Stage1 * vec3(aPosition, 1)).xy;
53     { // Stage 1: Texture
54     }
55     gl_Position = vec4(dot(pos3.xz, urtAdjustment.xy), dot(pos3.yz, urtAdjustment.zw), 0, pos3.z);
56 }
57 </script>
58
59 <script id="shader-fs" type="x-shader/x-fragment">
60 precision mediump float;
61 uniform sampler2D uDstCopySampler;
62 uniform vec2 uDstCopyUpperLeft;
63 uniform vec2 uDstCopyCoordScale;
64 uniform float uRTHeight;
65 uniform sampler2D uSampler0_Stage1;
66 varying vec4 vColor;
67 varying vec2 vMatrixCoord_Stage1;
68 void main() {
69     vec4 fragCoordYDown = vec4(gl_FragCoord.x, uRTHeight - gl_FragCoord.y, gl_FragCoord.zw);
70     // Read color from copy of the destination.
71     vec2 _dstTexCoord = (fragCoordYDown.xy - uDstCopyUpperLeft) * uDstCopyCoordScale;
72     _dstTexCoord.y = 1.0 - _dstTexCoord.y;
73     vec4 _dstColor = texture2D(uDstCopySampler, _dstTexCoord);
74
75     vec4 output_Stage0;
76     { // Stage 0: XferEffect
77         // SkXfermode::Mode: Multiply
78         output_Stage0.a = vColor.a + (1.0 - vColor.a) * _dstColor.a;
79         output_Stage0.rgb = (1.0 - vColor.a) * _dstColor.rgb + (1.0 - _dstColor.a) * vColor.rgb + vColor.rgb * _dstColor.rgb;
80     }
81     vec4 output_Stage1;
82     { // Stage 1: Texture
83     output_Stage1 = texture2D(uSampler0_Stage1, vMatrixCoord_Stage1);
84     }
85     gl_FragColor = ((output_Stage0 * output_Stage1) + ((vec4(1) - output_Stage1) * _dstColor));
86 }
87 </script>
88 <div id="description"></div>
89 <div id="console"></div>
90 <script>
91 "use strict";
92
93 description();
94 debug("");
95 debug('Verify shaders using gl_FragCoord z and w components compile and link correctly');
96 debug('Regression test for Qualcomm bug ID CR649654');
97 var wtu = WebGLTestUtils;
98 var gl = wtu.create3DContext();
99 if (!gl) {
100   testFailed("context does not exist");
101 } else {
102   var program = wtu.setupProgram(gl, ["shader-vs", "shader-fs"], null, null, true);
103   if (program) {
104     testPassed("Program compiled and linked successfully");
105   } else {
106     testFailed("Program failed to compile and link");
107   }
108 }
109
110 var successfullyParsed = true;
111 </script>
112 <script src="../../../resources/js-test-post.js"></script>
113 </body>
114 </html>