shaders-with-mis-matching-varyings.html (2408B)
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 GLSL Conformance Tests</title> 12 <link rel="stylesheet" href="../../../resources/js-test-style.css"/> 13 <link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/> 14 <script src="../../../js/js-test-pre.js"></script> 15 <script src="../../../js/webgl-test-utils.js"></script> 16 <script src="../../../js/glsl-conformance-test.js"></script> 17 </head> 18 <body> 19 <div id="description"></div> 20 <div id="console"></div> 21 <script id="vertexShader" type="text/something-not-javascript"> 22 // Shaders with mis-matching varying types should fail 23 // GLSL 1.0.17 4.3.5 24 attribute $(type) a_attribute; 25 varying $(type) v_varying; 26 27 void main() 28 { 29 v_varying = a_attribute; 30 gl_Position = vec4(0,0,0,0); 31 } 32 </script> 33 <script id="fragmentShader" type="text/something-not-javascript"> 34 // Shaders with mis-matching varyings types should fail 35 // GLSL 1.0.17 4.3.5 36 precision mediump float; 37 38 varying $(type) v_varying; 39 40 void main() 41 { 42 gl_FragColor = $(code); 43 } 44 </script> 45 <script> 46 "use strict"; 47 var wtu = WebGLTestUtils; 48 var varyingTypes = [ 49 { type: "float", code: "vec4(v_varying, 0, 0, 0)", }, 50 { type: "vec2", code: "vec4(v_varying, 0, 0)", }, 51 { type: "vec3", code: "vec4(v_varying, 0)", }, 52 { type: "vec4", code: "vec4(v_varying)", }, 53 { type: "mat2", code: "vec4(v_varying[0][0], 0, 0, 0)", }, 54 { type: "mat3", code: "vec4(v_varying[0][0], 0, 0, 0)", }, 55 { type: "mat4", code: "vec4(v_varying[0][0], 0, 0, 0)", }, 56 ]; 57 var vSource = wtu.getScript("vertexShader"); 58 var fSource = wtu.getScript("fragmentShader"); 59 var tests = []; 60 for (var ii = 0; ii < varyingTypes.length; ++ii) { 61 var u1 = varyingTypes[ii]; 62 var vs = wtu.replaceParams(vSource, u1); 63 for (var jj = ii + 1; jj < varyingTypes.length; ++jj) { 64 var u2 = varyingTypes[jj]; 65 var fs = wtu.replaceParams(fSource, u2); 66 tests.push({ 67 vShaderSource: vs, 68 vShaderSuccess: true, 69 fShaderSource: fs, 70 fShaderSuccess: true, 71 linkSuccess: false, 72 passMsg: "vertex shader with varying " + u1.type + " and fragment shader with varying " + u2.type + " with the same name should fail to link", 73 }); 74 } 75 } 76 GLSLConformanceTester.runTests(tests); 77 var successfullyParsed = true; 78 </script> 79 </body> 80 </html>