summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance2/textures/misc/tex-subimage3d-canvas-bug.html
blob: 2c2d021d5a11044ea028c0a931c16e2c963b3e51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!--
Copyright (c) 2019 The Khronos Group Inc.
Use of this source code is governed by an MIT-style license that can be
found in the LICENSE.txt file.
-->

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test bug of TexSubImage3D with canvas</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
<script src="../../../js/js-test-pre.js"></script>
<script src="../../../js/webgl-test-utils.js"></script>
</head>
<body>
<canvas id="example" width="2" height="2" style="width: 2px; height: 2px;"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description(document.title);
debug("This is a regression test for <a href='https://bugs.chromium.org/p/chromium/issues/detail?id=859400'>Chromium Issue 859400</a>");
debug("");

var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("example", undefined, 2);

wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");

function runTest() {
  var ctx = document.createElement('canvas').getContext("2d");
  var maxTexSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
  var width = Math.ceil(Math.sqrt(maxTexSize));
  var height = width;
  var depth = width + 1;
  ctx.canvas.width = width;
  // Set canvas height to a value larger than MAX_TEXTURE_SIZE.
  // This triggers a validation bug in Chrome.
  ctx.canvas.height = height * depth;

  var tex = gl.createTexture();
  gl.bindTexture(gl.TEXTURE_2D_ARRAY, tex);
  gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.RGBA8, width, height, depth);
  wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from TexStorage3D.");
  gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, width, height, depth,
                   gl.RGBA, gl.UNSIGNED_BYTE, ctx.canvas);
  wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from TexSubImage3D.");
}

runTest();
var successfullyParsed = true;
</script>
<script src="../../../js/js-test-post.js"></script>
</body>
</html>