Bug 1945965 – remove new tab April Fools logo. r=home-newtab-reviewers,reemhamz
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / glsl / bugs / fragcoord-linking-bug.html
blobf22632c0a476fbf8f7ef9346e31a004b8b33ed24
1 <!--
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.
5 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
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>
15 </head>
16 <body>
17 <!-- These shaders were extracted from Skia's GPU accelerated backend "Ganesh". -->
18 <script id="shader-vs" type="x-shader/x-vertex">
19 uniform mat3 uViewM;
20 uniform mat3 uStageMatrix_Stage1;
21 uniform vec4 urtAdjustment;
22 attribute vec2 aPosition;
23 attribute vec4 aColor;
24 varying vec4 vColor;
25 varying vec2 vMatrixCoord_Stage1;
26 void main() {
27 vec3 pos3 = uViewM * vec3(aPosition, 1);
28 vColor = aColor;
29 { // Stage 0: XferEffect
31 vMatrixCoord_Stage1 = (uStageMatrix_Stage1 * vec3(aPosition, 1)).xy;
32 { // Stage 1: Texture
34 gl_Position = vec4(dot(pos3.xz, urtAdjustment.xy), dot(pos3.yz, urtAdjustment.zw), 0, pos3.z);
36 </script>
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;
45 varying vec4 vColor;
46 varying vec2 vMatrixCoord_Stage1;
47 void main() {
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);
54 vec4 output_Stage0;
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;
60 vec4 output_Stage1;
61 { // Stage 1: Texture
62 output_Stage1 = texture2D(uSampler0_Stage1, vMatrixCoord_Stage1);
64 gl_FragColor = ((output_Stage0 * output_Stage1) + ((vec4(1) - output_Stage1) * _dstColor));
66 </script>
67 <div id="description"></div>
68 <div id="console"></div>
69 <script>
70 "use strict";
72 description();
73 debug("");
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();
78 if (!gl) {
79 testFailed("context does not exist");
80 } else {
81 var program = wtu.setupProgram(gl, ["shader-vs", "shader-fs"], null, null, true);
82 if (program) {
83 testPassed("Program compiled and linked successfully");
84 } else {
85 testFailed("Program failed to compile and link");
89 var successfullyParsed = true;
90 </script>
91 <script src="../../../js/js-test-post.js"></script>
92 </body>
93 </html>