qualcomm-crash.html (4012B)
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>Qualcomm program link crash 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 <script id='vshader1' type='x-shader/x-vertex'> 16 precision highp float; 17 void main() { 18 gl_Position = vec4( 1.0, 1.0, 1.0, 1.0 ); 19 } 20 </script> 21 <script id='fshader1' type='x-shader/x-fragment'> 22 precision highp float; 23 uniform int renderType; 24 uniform sampler2D texMap; 25 void main() { 26 vec2 uv = vec2(0.0, 0.0); 27 if( renderType == 0 ) { 28 gl_FragColor = texture2D( texMap, uv ); 29 } else { 30 vec4 texture = texture2D( texMap, uv ); 31 gl_FragColor = texture; 32 } 33 } 34 </script> 35 36 <script id='vshader2' type='x-shader/x-vertex'> 37 attribute vec3 vertex_position; 38 uniform mat4 matrix_model; 39 uniform mat4 matrix_viewProjection; 40 41 attribute vec4 vertex_boneWeights; 42 attribute vec4 vertex_boneIndices; 43 44 uniform sampler2D texture_poseMap; 45 uniform vec2 texture_poseMapSize; 46 47 mat4 getBoneMatrix(const in float i) 48 { 49 float j = i * 4.0; 50 float x = mod(j, float(texture_poseMapSize.x)); 51 float y = floor(j / float(texture_poseMapSize.x)); 52 53 float dx = 1.0 / float(texture_poseMapSize.x); 54 float dy = 1.0 / float(texture_poseMapSize.y); 55 56 y = dy * (y + 0.5); 57 58 vec4 v1 = texture2D(texture_poseMap, vec2(dx * (x + 0.5), y)); 59 vec4 v2 = texture2D(texture_poseMap, vec2(dx * (x + 1.5), y)); 60 vec4 v3 = texture2D(texture_poseMap, vec2(dx * (x + 2.5), y)); 61 vec4 v4 = texture2D(texture_poseMap, vec2(dx * (x + 3.5), y)); 62 63 mat4 bone = mat4(v1, v2, v3, v4); 64 65 return bone; 66 } 67 68 void main(void) 69 { 70 mat4 modelMatrix = vertex_boneWeights.x * getBoneMatrix(vertex_boneIndices.x) + 71 vertex_boneWeights.y * getBoneMatrix(vertex_boneIndices.y) + 72 vertex_boneWeights.z * getBoneMatrix(vertex_boneIndices.z) + 73 vertex_boneWeights.w * getBoneMatrix(vertex_boneIndices.w); 74 75 vec4 positionW = modelMatrix * vec4(vertex_position, 1.0); 76 gl_Position = matrix_viewProjection * positionW; 77 78 } 79 </script> 80 <script id='fshader2' type='x-shader/x-fragment'> 81 precision highp float; 82 void main() { 83 gl_FragColor = vec4( 1.0, 1.0, 1.0, 1.0 ); 84 } 85 </script> 86 </head> 87 <body> 88 <div id="description"></div> 89 <div id="console"></div> 90 <script> 91 "use strict"; 92 description("This test checks a known bug in some Qualcomm drivers which causes crashes when linking certain shaders. <a href='https://code.google.com/p/chromium/issues/detail?id=498947'>crbug.com/498947</a>"); 93 94 debug(""); 95 96 var wtu = WebGLTestUtils; 97 var gl = wtu.create3DContext(); 98 99 gl.canvas.addEventListener("webglcontextlost", function(e) { 100 testFailed("WebGL context lost"); 101 }); 102 103 if (!gl) { 104 testFailed("WebGL context does not exist"); 105 } else { 106 testPassed("WebGL context exists"); 107 debug(""); 108 109 if (gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT).precision == 0) { 110 testPassed("highp precision not supported"); 111 } else { 112 var program1 = wtu.setupProgram(gl, ['vshader1', 'fshader1']); 113 if (!gl.getProgramParameter(program1, gl.LINK_STATUS)) { 114 testFailed("Program failed to link"); 115 } 116 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors"); 117 118 debug(""); 119 120 var program2 = wtu.setupProgram(gl, ['vshader2', 'fshader2']); 121 if (!gl.getProgramParameter(program2, gl.LINK_STATUS)) { 122 testFailed("Program failed to link"); 123 } 124 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors"); 125 } 126 } 127 128 // Cycle through a rAF once to give any webglcontextlost events a chance to propagate 129 window.requestAnimationFrame(function() { finishTest(); }); 130 131 debug(""); 132 var successfullyParsed = true; 133 </script> 134 135 </body> 136 </html>