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 Rendering Stencil large viewport Tests
</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>
16 <script id=
"vs" type=
"x-shader/x-vertex">
17 attribute vec4 a_Position;
20 gl_Position = a_Position;
23 <script id=
"fs" type=
"x-shader/x-fragment">
24 precision mediump float;
25 uniform vec4 u_draw_color;
28 gl_FragColor = u_draw_color;
34 <canvas id=
"example" width=
"4" height=
"4"></canvas>
35 <div id=
"description"></div>
36 <div id=
"console"></div>
41 var wtu
= WebGLTestUtils
;
42 description("This test reproduces a driver bug on Intel windows platforms http://crbug.com/782317.");
44 var gl
= wtu
.create3DContext("example", {stencil
: true});
46 var program
, colorLoc
;
48 // Rendering with large viewport and stencil buffer enabled will lead to
49 // memory leak and driver crash on d3d11 driver on Intel platforms.
50 function render_stencil() {
51 var canvas
= document
.getElementById("example");
52 gl
.uniform4f(colorLoc
, 1.0, 0.0, 0.0, 1.0);
55 canvas
.height
= 32767;
56 gl
.viewport(0, 0, 32767, 32767);
58 gl
.enable(gl
.STENCIL_TEST
);
61 gl
.stencilOp(gl
.REPLACE
, gl
.REPLACE
, gl
.REPLACE
);
62 gl
.stencilFunc(gl
.ALWAYS
, kStencilRef
, 0xFF);
64 gl
.drawArrays(gl
.TRIANGLES
, 0, 6);
65 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
);
66 wtu
.checkCanvasRect(gl
, 0, 0, 1, 1, [255, 0, 0, 255],
67 "stencil test should be red");
71 testFailed("WebGL context does not exist");
73 testPassed("WebGL context exists");
75 program
= wtu
.setupProgram(gl
, ["vs", "fs"], ["a_Position"]);
76 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "after program initialization");
77 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true');
79 colorLoc
= gl
.getUniformLocation(program
, "u_draw_color")
80 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "query uniform location");
81 shouldBeNonNull('colorLoc');
82 wtu
.setupUnitQuad(gl
, 0);
87 var successfullyParsed
= true;
89 <script src=
"../../js/js-test-post.js"></script>