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>GLSL compiler bug referencing gl_FragCoord
</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 <!-- These shaders were extracted from Skia's GPU accelerated backend "Ganesh". -->
18 <script id=
"shader-vs" type=
"x-shader/x-vertex">
20 uniform mat3 uStageMatrix_Stage1;
21 uniform vec4 urtAdjustment;
22 attribute vec2 aPosition;
23 attribute vec4 aColor;
25 varying vec2 vMatrixCoord_Stage1;
27 vec3 pos3 = uViewM * vec3(aPosition,
1);
29 { // Stage
0: XferEffect
31 vMatrixCoord_Stage1 = (uStageMatrix_Stage1 * vec3(aPosition,
1)).xy;
34 gl_Position = vec4(dot(pos3.xz, urtAdjustment.xy), dot(pos3.yz, urtAdjustment.zw),
0, pos3.z);
38 <script id=
"shader-fs" type=
"x-shader/x-fragment">
39 precision mediump float;
40 uniform sampler2D uDstCopySampler;
41 uniform vec2 uDstCopyUpperLeft;
42 uniform vec2 uDstCopyCoordScale;
43 uniform float uRTHeight;
44 uniform sampler2D uSampler0_Stage1;
46 varying vec2 vMatrixCoord_Stage1;
48 vec4 fragCoordYDown = vec4(gl_FragCoord.x, uRTHeight - gl_FragCoord.y, gl_FragCoord.zw);
49 // Read color from copy of the destination.
50 vec2 _dstTexCoord = (fragCoordYDown.xy - uDstCopyUpperLeft) * uDstCopyCoordScale;
51 _dstTexCoord.y =
1.0 - _dstTexCoord.y;
52 vec4 _dstColor = texture2D(uDstCopySampler, _dstTexCoord);
55 { // Stage
0: XferEffect
56 // SkXfermode::Mode: Multiply
57 output_Stage0.a = vColor.a + (
1.0 - vColor.a) * _dstColor.a;
58 output_Stage0.rgb = (
1.0 - vColor.a) * _dstColor.rgb + (
1.0 - _dstColor.a) * vColor.rgb + vColor.rgb * _dstColor.rgb;
62 output_Stage1 = texture2D(uSampler0_Stage1, vMatrixCoord_Stage1);
64 gl_FragColor = ((output_Stage0 * output_Stage1) + ((vec4(
1) - output_Stage1) * _dstColor));
67 <div id=
"description"></div>
68 <div id=
"console"></div>
74 debug('Verify shaders using gl_FragCoord z and w components compile and link correctly');
75 debug('Regression test for Qualcomm bug ID CR649654');
76 var wtu
= WebGLTestUtils
;
77 var gl
= wtu
.create3DContext();
79 testFailed("context does not exist");
81 var program
= wtu
.setupProgram(gl
, ["shader-vs", "shader-fs"], null, null, true);
83 testPassed("Program compiled and linked successfully");
85 testFailed("Program failed to compile and link");
89 var successfullyParsed
= true;
91 <script src=
"../../../js/js-test-post.js"></script>