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>WebGL2 texture base level bug conformance 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/tests/tex-image-and-sub-image-utils.js"></script>
18 <canvas id=
"example" width=
"2" height=
"2" style=
"width: 2px; height: 2px;"></canvas>
19 <div id=
"description"></div>
20 <div id=
"console"></div>
24 description(document
.title
);
25 var wtu
= WebGLTestUtils
;
26 var canvas
= document
.getElementById("example");
27 var gl
= wtu
.create3DContext("example", undefined, 2);
28 var tiu
= TexImageUtils
;
30 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be no errors from setup.");
34 debug("This is a regression test for <a href='https://crbug.com/705865'>Chromium Issue 705865</a>");
35 var tex
= gl
.createTexture();
36 var program
= tiu
.setupTexturedQuad(gl
, "RGBA");
38 // Test that filling partial levels is enough for mipmapping.
41 gl
.bindTexture(gl
.TEXTURE_2D
, tex
);
42 wtu
.fillTexture(gl
, tex
, width
, height
, [255, 0, 0, 255], 2, gl
.RGBA
, gl
.UNSIGNED_BYTE
);
43 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_BASE_LEVEL
, 2);
44 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MAG_FILTER
, gl
.NEAREST
);
45 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MIN_FILTER
, gl
.NEAREST
);
46 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Texture setup should succeed");
49 canvas
.height
= height
;
50 gl
.viewport(0, 0, width
, height
);
52 wtu
.clearAndDrawUnitQuad(gl
);
53 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "clearAndDrawQuad should succeed");
54 wtu
.checkCanvas(gl
, [255, 0, 0, 255], "should draw with [255, 0, 0, 255]");
58 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGBA
, width
, height
, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
, null);
59 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "texImage2D should succeed");
61 wtu
.clearAndDrawUnitQuad(gl
);
62 wtu
.checkCanvas(gl
, [255, 0, 0, 255], "should draw with [255, 0, 0, 255]");
63 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
,"checkCanvas should succeed");
65 gl
.deleteTexture(tex
);
70 var successfullyParsed
= true;
73 <script src=
"../../../js/js-test-post.js"></script>