Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance2 / rendering / framebuffer-completeness-unaffected.html
blob74b6106419dfd828f39a8e426895d75a44c1ab6f
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 drawBuffers, readBuffer, and fbo completeness</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 <canvas id="canvas" width="20" height="20"> </canvas>
20 <script>
21 // In MacOSX, if drawBuffers() and readBuffer() both select an attachment with no image attached,
22 // fbo becomes incomplete. However, drawBuffers() and readBuffer() should not affect fbo completeness.
24 "use strict";
25 description("This tests drawBuffers, readBuffer, and fbo completeness");
27 var setupRenderbuffer = function(attachment) {
28 var renderbuffer = gl.createRenderbuffer();
29 gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
30 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, renderbuffer);
31 gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA8, canvas.width, canvas.height);
32 return renderbuffer;
35 var wtu = WebGLTestUtils;
36 var canvas = document.getElementById("canvas");
37 var gl = wtu.create3DContext(canvas, undefined, 2);
38 if (!gl) {
39 testFailed("context does not exist");
40 } else {
41 testPassed("context exists");
43 var fb = gl.createFramebuffer();
44 gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
46 debug("fbo with two color images attached should be complete");
47 var colorbuffer = setupRenderbuffer(gl.COLOR_ATTACHMENT0);
48 var colorbuffer1 = setupRenderbuffer(gl.COLOR_ATTACHMENT1);
49 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
51 debug("drawBuffers selects ATTACHMENT1, fbo should be complete");
52 gl.drawBuffers([gl.NONE, gl.COLOR_ATTACHMENT1]);
53 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
55 debug("remove image attached to ATTACHMENT1, fbo should be complete");
56 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT1, gl.RENDERBUFFER, null);
57 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
59 debug("set read buffer to ATTACHMENT1, fbo should be complete");
60 gl.readBuffer(gl.COLOR_ATTACHMENT1);
61 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
63 debug("drawBuffers selects ATTACHMENT0, fbo should be complete");
64 gl.drawBuffers([gl.COLOR_ATTACHMENT0]);
65 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
67 debug("drawBuffers selects ATTACHMENT1, fbo should be complete");
68 gl.drawBuffers([gl.NONE, gl.COLOR_ATTACHMENT1]);
69 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
71 debug("set read buffer to ATTACHMENT0, fbo should be complete");
72 gl.readBuffer(gl.COLOR_ATTACHMENT0);
73 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
75 gl.deleteFramebuffer(fb);
76 gl.deleteRenderbuffer(colorbuffer);
77 gl.deleteRenderbuffer(colorbuffer1);
79 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no error after setup and clear render buffer");
82 debug("");
83 var successfullyParsed = true;
85 </script>
86 <script src="../../js/js-test-post.js"></script>
88 </body>
89 </html>