summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance/rendering/rendering-stencil-large-viewport.html
blob: 1202106c1372a029f58f5660ca1bd8757418a763 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!--
Copyright (c) 2019 The Khronos Group Inc.
Use of this source code is governed by an MIT-style license that can be
found in the LICENSE.txt file.
-->

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Rendering Stencil large viewport Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../js/js-test-pre.js"></script>
<script src="../../js/webgl-test-utils.js"></script>

<script id="vs" type="x-shader/x-vertex">
attribute vec4 a_Position;
void main()
{
  gl_Position = a_Position;
}
</script>
<script id="fs" type="x-shader/x-fragment">
precision mediump float;
uniform vec4 u_draw_color;
void main()
{
  gl_FragColor = u_draw_color;
}
</script>

</head>
<body>
<canvas id="example" width="4" height="4"></canvas>
<div id="description"></div>
<div id="console"></div>

<script>
"use strict";

var wtu = WebGLTestUtils;
description("This test reproduces a driver bug on Intel windows platforms http://crbug.com/782317.");

var gl = wtu.create3DContext("example", {stencil: true});

var program, colorLoc;

// Rendering with large viewport and stencil buffer enabled will lead to
// memory leak and driver crash on d3d11 driver on Intel platforms.
function render_stencil() {
  var canvas = document.getElementById("example");
  gl.uniform4f(colorLoc, 1.0, 0.0, 0.0, 1.0);

  canvas.width = 32767;
  canvas.height = 32767;
  gl.viewport(0, 0, 32767, 32767);

  gl.enable(gl.STENCIL_TEST);

  var kStencilRef = 4;
  gl.stencilOp(gl.REPLACE, gl.REPLACE, gl.REPLACE);
  gl.stencilFunc(gl.ALWAYS, kStencilRef, 0xFF);

  gl.drawArrays(gl.TRIANGLES, 0, 6);
  wtu.glErrorShouldBe(gl, gl.NO_ERROR);
  wtu.checkCanvasRect(gl, 0, 0, 1, 1, [255, 0, 0, 255],
                      "stencil test should be red");
}

if (!gl) {
    testFailed("WebGL context does not exist");
} else {
    testPassed("WebGL context exists");

    program = wtu.setupProgram(gl, ["vs", "fs"], ["a_Position"]);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after program initialization");
    shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true');

    colorLoc = gl.getUniformLocation(program, "u_draw_color")
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "query uniform location");
    shouldBeNonNull('colorLoc');
    wtu.setupUnitQuad(gl, 0);

    render_stencil();
}

var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>

</body>
</html>