Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance2 / rendering / framebuffer-completeness-draw-framebuffer.html
blob1c0709e0b8a0c5359632366fc01b3ab0adcb57a4
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>Test draw framebuffer completeness when an incomplete framebuffer is bound to read framebuffer</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 <div id="description"></div>
18 <div id="console"></div>
19 <script>
20 // This exposes a bug in Chrome 67: If the read framebuffer is incomplete, then draw can fail even if the draw framebuffer is complete.
21 // http://anglebug.com/2737
23 "use strict";
24 description();
26 var wtu = WebGLTestUtils;
27 var gl = wtu.create3DContext(undefined, undefined, 2);
28 if (!gl) {
29 testFailed("context does not exist");
30 } else {
31 testPassed("context exists");
33 var incompleteFb = gl.createFramebuffer();
34 gl.bindFramebuffer(gl.FRAMEBUFFER, incompleteFb);
35 var incompleteTex = gl.createTexture();
36 gl.bindTexture(gl.TEXTURE_2D, incompleteTex);
37 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, incompleteTex, 0);
38 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT');
40 wtu.setupUnitQuad(gl, 0, 1);
42 var testProgram = wtu.setupSimpleColorProgram(gl, 0);
44 // If this is changed to gl.FRAMEBUFFER, the rendering succeeds on Chrome 67.
45 var drawFbTarget = gl.DRAW_FRAMEBUFFER;
47 var completeFb = gl.createFramebuffer();
48 gl.bindFramebuffer(drawFbTarget, completeFb);
49 var completeTex = gl.createTexture();
50 gl.bindTexture(gl.TEXTURE_2D, completeTex);
51 gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGBA8, 128, 128);
52 gl.framebufferTexture2D(drawFbTarget, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, completeTex, 0);
53 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no error after setup");
55 shouldBe('gl.checkFramebufferStatus(gl.READ_FRAMEBUFFER)', 'gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT');
56 shouldBe('gl.checkFramebufferStatus(gl.DRAW_FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
58 gl.viewport(0, 0, 128, 128);
59 gl.uniform4f(gl.getUniformLocation(testProgram, 'u_color'), 0, 1, 0, 1);
60 wtu.drawUnitQuad(gl);
62 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no error after draw");
63 gl.bindFramebuffer(gl.READ_FRAMEBUFFER, completeFb);
64 wtu.checkCanvasRect(gl, 0, 0, 128, 128, [0, 255, 0, 255], 'should be green', 2);
67 debug("");
68 var successfullyParsed = true;
70 </script>
71 <script src="../../js/js-test-post.js"></script>
73 </body>
74 </html>