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 Multi-Context Sampler 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 <canvas id=
"canvas_drawing" width=
"12" height=
"12"></canvas>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
22 description("Tests that samplers' state doesn't leak across contexts");
24 debug('Regression test for <a href="http://crbug.com/713127">http://crbug.com/713127</a>');
27 var wtu
= WebGLTestUtils
;
28 var gl
= wtu
.create3DContext("canvas_drawing", undefined, 2);
30 var color
= [0, 255, 0, 255];
33 testFailed("WebGL context does not exist");
37 testPassed("WebGL context exists");
39 wtu
.setupTexturedQuad(gl
);
40 texture
= gl
.createTexture();
41 // Create a texture bigger than 1x1 so that it would need mipmaps in
42 // order to be complete.
43 wtu
.fillTexture(gl
, texture
, 2, 2, color
, 0,
44 gl
.RGBA
, gl
.UNSIGNED_BYTE
, gl
.RGBA8
);
45 // Set texture parameters so that this texture is complete.
46 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MIN_FILTER
, gl
.NEAREST
);
47 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MAG_FILTER
, gl
.NEAREST
);
49 // Set up a secondary context with a sampler bound to texture unit
50 // 0. This should not interfere with the primary context.
51 var altGL
= wtu
.create3DContext(undefined, undefined, 2);
53 testFailed("Error creating secondary WebGL context");
57 var sampler
= altGL
.createSampler();
58 // Note that the sampler's default TEXTURE_MIN_FILTER is
59 // NEAREST_MIPMAP_LINEAR.
60 altGL
.bindSampler(0, sampler
);
61 altGL
.clearColor(1, 0, 0, 1);
62 altGL
.clear(altGL
.COLOR_BUFFER_BIT
);
63 wtu
.checkCanvasRect(altGL
, 0, 0, 1, 1, [ 255, 0, 0, 255 ],
66 // Now switch back to the main context and draw the texture.
67 gl
.clearColor(1, 1, 1, 1);
68 gl
.clear(gl
.COLOR_BUFFER_BIT
| gl
.DEPTH_BUFFER_BIT
);
70 // The presence of the sampler on the other context should not
71 // have interfered with the completeness of the texture.
72 wtu
.checkCanvasRect(gl
, 0, 0, 1, 1, color
,
75 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "there should be no errors");
79 var successfullyParsed
= true;
81 <script src=
"../../js/js-test-post.js"></script>