Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance2 / rendering / framebuffer-texture-level1.html
blobd5ac8cb1e796e5762158bd463c0d105175cc475f
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>WebGL framebuffer using texture level 1</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="2" height="2"> </canvas>
20 <script>
21 "use strict";
22 var wtu = WebGLTestUtils;
23 var gl;
25 function testFramebufferTextureWithNonZeroBaseLevel(level) {
26 if (level < 1) {
27 throw "This test is incorrect if level < 1";
29 var width = 32;
30 var height = 16;
31 var texture = gl.createTexture();
32 gl.bindTexture(gl.TEXTURE_2D, texture);
33 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
34 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
35 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
36 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
37 gl.texImage2D(gl.TEXTURE_2D, level, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
38 var fbo = gl.createFramebuffer();
39 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
40 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, level);
41 shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
42 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_BASE_LEVEL, level);
43 shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
44 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setup framebuffer with texture should succeed.");
46 gl.deleteTexture(texture);
47 gl.deleteFramebuffer(fbo);
50 description("Test fbo completeness when using non level 0 texture images");
52 var canvas = document.getElementById("canvas");
53 shouldBeNonNull("gl = wtu.create3DContext(canvas, undefined, 2)");
55 testFramebufferTextureWithNonZeroBaseLevel(1);
57 debug("");
58 var successfullyParsed = true;
60 </script>
61 <script src="../../js/js-test-post.js"></script>
63 </body>
64 </html>