rendering-stencil-large-viewport.html (2416B)
1 <!-- 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. 5 --> 6 7 <!DOCTYPE html> 8 <html> 9 <head> 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> 15 16 <script id="vs" type="x-shader/x-vertex"> 17 attribute vec4 a_Position; 18 void main() 19 { 20 gl_Position = a_Position; 21 } 22 </script> 23 <script id="fs" type="x-shader/x-fragment"> 24 precision mediump float; 25 uniform vec4 u_draw_color; 26 void main() 27 { 28 gl_FragColor = u_draw_color; 29 } 30 </script> 31 32 </head> 33 <body> 34 <canvas id="example" width="4" height="4"></canvas> 35 <div id="description"></div> 36 <div id="console"></div> 37 38 <script> 39 "use strict"; 40 41 var wtu = WebGLTestUtils; 42 description("This test reproduces a driver bug on Intel windows platforms http://crbug.com/782317."); 43 44 var gl = wtu.create3DContext("example", {stencil: true}); 45 46 var program, colorLoc; 47 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); 53 54 canvas.width = 32767; 55 canvas.height = 32767; 56 gl.viewport(0, 0, 32767, 32767); 57 58 gl.enable(gl.STENCIL_TEST); 59 60 var kStencilRef = 4; 61 gl.stencilOp(gl.REPLACE, gl.REPLACE, gl.REPLACE); 62 gl.stencilFunc(gl.ALWAYS, kStencilRef, 0xFF); 63 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"); 68 } 69 70 if (!gl) { 71 testFailed("WebGL context does not exist"); 72 } else { 73 testPassed("WebGL context exists"); 74 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'); 78 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); 83 84 render_stencil(); 85 } 86 87 var successfullyParsed = true; 88 </script> 89 <script src="../../js/js-test-post.js"></script> 90 91 </body> 92 </html>