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.
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
17 gl_Position = vec4(
0,
0,
0,
1);
21 <script id=
"fshader" type=
"x-shader/x-fragment">#version
300 es
22 precision mediump float;
25 outColor = vec4(
0,
1,
0,
1);
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>
38 description("Test that WebGL2 can render to layers in 3D textures");
40 var wtu
= WebGLTestUtils
;
41 var gl
= wtu
.create3DContext("example", undefined, 2);
44 testFailed("WebGL context creation failed");
46 testPassed("WebGL context creation succeeded");
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");
85 var successfullyParsed
= true;
87 <script src=
"../../js/js-test-post.js"></script>