Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance2 / rendering / framebuffer-render-to-layer-angle-issue.html
blob1fbdb6bbeb494740d2aca886955aab3bb6b4a341
1 <!--
2 Copyright (c) 2020 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>WebGL2 can render to layers in 3D texture angle issue check</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 <script id="vshader" type="x-shader/x-vertex">#version 300 es
16 void main(void) {
17 gl_Position = vec4(0, 0, 0, 1);
18 gl_PointSize = 1.0;
20 </script>
21 <script id="fshader" type="x-shader/x-fragment">#version 300 es
22 precision mediump float;
23 out vec4 outColor;
24 void main() {
25 outColor = vec4(0, 1, 0, 1);
27 </script>
28 </head>
29 <body>
30 <canvas id="example" width="1", height="1"></canvas>
31 <div id="description"></div>
32 <a href='https://bugs.chromium.org/p/angleproject/issues/detail?id=4417'>ANGLE issue #4417</a>
33 <div id="console"></div>
34 <script>
35 "use strict";
36 debug("");
38 description("Test that WebGL2 can render to layers in 3D textures");
40 var wtu = WebGLTestUtils;
41 var gl = wtu.create3DContext("example", undefined, 2);
43 if (!gl) {
44 testFailed("WebGL context creation failed");
45 } else {
46 testPassed("WebGL context creation succeeded");
47 runTest();
50 function runTest() {
51 const fb = gl.createFramebuffer();
52 gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
54 const tex = gl.createTexture();
55 gl.bindTexture(gl.TEXTURE_3D, tex);
56 gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
57 gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
58 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA8, gl.canvas.width, gl.canvas.height, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
60 for (let i = 0; i < 2; i++) {
61 gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, tex, 0, i);
63 const rb = gl.createRenderbuffer();
64 gl.bindRenderbuffer(gl.RENDERBUFFER, rb);
65 gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, gl.canvas.width, gl.canvas.height);
66 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, rb);
68 wtu.framebufferStatusShouldBe(gl, gl.FRAMEBUFFER, gl.FRAMEBUFFER_COMPLETE);
70 const program = wtu.setupProgram(gl, ['vshader','fshader'], [], console.log.bind(console));
71 gl.useProgram(program);
73 gl.drawArrays(gl.POINTS, 0, 1);
75 wtu.glErrorShouldBe(gl, gl.NO_ERROR, `No errors`);
76 wtu.checkCanvas(gl, [0, 255, 0, 255], `framebuffer layer ${i} should be green`);
79 // make sure we were not rendering to the canvas.
80 gl.bindFramebuffer(gl.FRAMEBUFFER, null)
81 wtu.checkCanvas(gl, [0, 0, 0, 0], "canvas should be zero");
84 debug("");
85 var successfullyParsed = true;
86 </script>
87 <script src="../../js/js-test-post.js"></script>
89 </body>
90 </html>