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.
10 <meta charset=
"utf-8">
11 <title>Test bug of TexSubImage3D with canvas
</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>
17 <canvas id=
"example" width=
"2" height=
"2" style=
"width: 2px; height: 2px;"></canvas>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
22 description(document
.title
);
23 debug("This is a regression test for <a href='https://bugs.chromium.org/p/chromium/issues/detail?id=859400'>Chromium Issue 859400</a>");
26 var wtu
= WebGLTestUtils
;
27 var gl
= wtu
.create3DContext("example", undefined, 2);
29 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be no errors from setup.");
32 var ctx
= document
.createElement('canvas').getContext("2d");
33 var maxTexSize
= gl
.getParameter(gl
.MAX_TEXTURE_SIZE
);
34 var width
= Math
.ceil(Math
.sqrt(maxTexSize
));
36 var depth
= width
+ 1;
37 ctx
.canvas
.width
= width
;
38 // Set canvas height to a value larger than MAX_TEXTURE_SIZE.
39 // This triggers a validation bug in Chrome.
40 ctx
.canvas
.height
= height
* depth
;
42 var tex
= gl
.createTexture();
43 gl
.bindTexture(gl
.TEXTURE_2D_ARRAY
, tex
);
44 gl
.texStorage3D(gl
.TEXTURE_2D_ARRAY
, 1, gl
.RGBA8
, width
, height
, depth
);
45 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be no errors from TexStorage3D.");
46 gl
.texSubImage3D(gl
.TEXTURE_2D_ARRAY
, 0, 0, 0, 0, width
, height
, depth
,
47 gl
.RGBA
, gl
.UNSIGNED_BYTE
, ctx
.canvas
);
48 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be no errors from TexSubImage3D.");
52 var successfullyParsed
= true;
54 <script src=
"../../../js/js-test-post.js"></script>