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>
17 <div id=
"description"></div>
18 <div id=
"console"></div>
19 <canvas id=
"example" width=
"64" height=
"64">
23 description("Test out of order cube map uploads.");
24 debug("Regression test for crbug.com/473739 / Apple Radar 20444072.");
26 <!-- Thanks to Gregg Tavares
for the original report and test
case. -->
28 var wtu
= WebGLTestUtils
;
30 var canvas
= document
.getElementById("example");
31 canvas
.addEventListener('webglcontextlost', contextLost
, false);
33 var contextWasLost
= false;
35 function contextLost(e
) {
37 contextWasLost
= true;
38 debug("***context lost -- should not happen***");
43 var gl
= wtu
.create3DContext(canvas
);
44 var tex
= gl
.createTexture();
45 // start with 1x1 pixel cubemap
46 gl
.bindTexture(gl
.TEXTURE_CUBE_MAP
, tex
);
47 var color
= new Uint8Array([128, 192, 255, 255]);
48 for (var ii
= 0; ii
< 6; ++ii
) {
49 gl
.texImage2D(gl
.TEXTURE_CUBE_MAP_POSITIVE_X
+ ii
, 0, gl
.RGBA
, 1, 1, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
, color
);
51 gl
.bindTexture(gl
.TEXTURE_CUBE_MAP
, tex
);
52 gl
.generateMipmap(gl
.TEXTURE_CUBE_MAP
); // there's no need to call this but the code doesn't check the size.
54 var textureData
= new Uint8Array(dataWidth
* dataHeight
* 4);
56 // The first texture has downloaded
58 gl
.bindTexture(gl
.TEXTURE_CUBE_MAP
, tex
);
59 gl
.texImage2D(gl
.TEXTURE_CUBE_MAP_POSITIVE_X
+ first
, 0, gl
.RGBA
, dataWidth
, dataHeight
, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
, textureData
);
61 // Now because the first face downloaded doesn't match the other 5 faces upload the same image to the other 5
63 for (var ii
= 0; ii
< 6; ++ii
) {
65 gl
.bindTexture(gl
.TEXTURE_CUBE_MAP
, tex
);
66 gl
.texImage2D(gl
.TEXTURE_CUBE_MAP_POSITIVE_X
+ ii
, 0, gl
.RGBA
, dataWidth
, dataHeight
, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
, textureData
);
69 gl
.generateMipmap(gl
.TEXTURE_CUBE_MAP
);
71 // Now as each new face comes in add it
72 for (var ii
= 0; ii
< 6; ++ii
) {
74 gl
.bindTexture(gl
.TEXTURE_CUBE_MAP
, tex
);
75 gl
.texImage2D(gl
.TEXTURE_CUBE_MAP_POSITIVE_X
+ ii
, 0, gl
.RGBA
, dataWidth
, dataHeight
, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
, textureData
);
76 gl
.generateMipmap(gl
.TEXTURE_CUBE_MAP
);
82 setTimeout(function() {
83 shouldBe("contextWasLost", "false");
87 var successfullyParsed
= true;