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>WebGL cube map out of order upload test.
</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 src=
"../js/glsl-conformance-test.js"></script>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
20 <canvas id=
"example" width=
"64" height=
"64">
24 description("Test out of order cube map uploads.");
25 debug("Regression test for crbug.com/473739 / Apple Radar 20444072.");
27 <!-- Thanks to Gregg Tavares
for the original report and test
case. -->
29 var wtu
= WebGLTestUtils
;
31 var canvas
= document
.getElementById("example");
32 canvas
.addEventListener('webglcontextlost', contextLost
, false);
34 var contextWasLost
= false;
36 function contextLost(e
) {
38 contextWasLost
= true;
39 debug("***context lost -- should not happen***");
44 var gl
= wtu
.create3DContext(canvas
);
45 var tex
= gl
.createTexture();
46 // start with 1x1 pixel cubemap
47 gl
.bindTexture(gl
.TEXTURE_CUBE_MAP
, tex
);
48 var color
= new Uint8Array([128, 192, 255, 255]);
49 for (var ii
= 0; ii
< 6; ++ii
) {
50 gl
.texImage2D(gl
.TEXTURE_CUBE_MAP_POSITIVE_X
+ ii
, 0, gl
.RGBA
, 1, 1, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
, color
);
52 gl
.bindTexture(gl
.TEXTURE_CUBE_MAP
, tex
);
53 gl
.generateMipmap(gl
.TEXTURE_CUBE_MAP
); // there's no need to call this but the code doesn't check the size.
55 var textureData
= new Uint8Array(dataWidth
* dataHeight
* 4);
57 // The first texture has downlaoded
59 gl
.bindTexture(gl
.TEXTURE_CUBE_MAP
, tex
);
60 gl
.texImage2D(gl
.TEXTURE_CUBE_MAP_POSITIVE_X
+ first
, 0, gl
.RGBA
, dataWidth
, dataHeight
, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
, textureData
);
62 // Now because the first face downloaded doesn't match the other 5 faces upload the same image to the other 5
64 for (var ii
= 0; ii
< 6; ++ii
) {
66 gl
.bindTexture(gl
.TEXTURE_CUBE_MAP
, tex
);
67 gl
.texImage2D(gl
.TEXTURE_CUBE_MAP_POSITIVE_X
+ ii
, 0, gl
.RGBA
, dataWidth
, dataHeight
, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
, textureData
);
70 gl
.generateMipmap(gl
.TEXTURE_CUBE_MAP
);
72 // Now as each new face comes in add it
73 for (var ii
= 0; ii
< 6; ++ii
) {
75 gl
.bindTexture(gl
.TEXTURE_CUBE_MAP
, tex
);
76 gl
.texImage2D(gl
.TEXTURE_CUBE_MAP_POSITIVE_X
+ ii
, 0, gl
.RGBA
, dataWidth
, dataHeight
, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
, textureData
);
77 gl
.generateMipmap(gl
.TEXTURE_CUBE_MAP
);
83 setTimeout(function() {
84 shouldBe("contextWasLost", "false");
88 var successfullyParsed
= true;