4 ** Copyright (c) 2014 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>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>
38 <!-- These shaders were extracted from Skia's GPU accelerated backend "Ganesh". -->
39 <script id="shader-vs" type="x-shader/x-vertex">
41 uniform mat3 uStageMatrix_Stage1;
42 uniform vec4 urtAdjustment;
43 attribute vec2 aPosition;
44 attribute vec4 aColor;
46 varying vec2 vMatrixCoord_Stage1;
48 vec3 pos3 = uViewM * vec3(aPosition, 1);
50 { // Stage 0: XferEffect
52 vMatrixCoord_Stage1 = (uStageMatrix_Stage1 * vec3(aPosition, 1)).xy;
55 gl_Position = vec4(dot(pos3.xz, urtAdjustment.xy), dot(pos3.yz, urtAdjustment.zw), 0, pos3.z);
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;
67 varying vec2 vMatrixCoord_Stage1;
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);
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;
83 output_Stage1 = texture2D(uSampler0_Stage1, vMatrixCoord_Stage1);
85 gl_FragColor = ((output_Stage0 * output_Stage1) + ((vec4(1) - output_Stage1) * _dstColor));
88 <div id="description"></div>
89 <div id="console"></div>
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();
100 testFailed("context does not exist");
102 var program = wtu.setupProgram(gl, ["shader-vs", "shader-fs"], null, null, true);
104 testPassed("Program compiled and linked successfully");
106 testFailed("Program failed to compile and link");
110 var successfullyParsed = true;
112 <script src="../../../resources/js-test-post.js"></script>