input-with-interpotaion-as-lvalue.html (2329B)
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>Negative tests for writting to a shader input with interpolation qualifier</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 <!-- 22 According to ESSL 3.00.6 section 4.3.4: 23 "Variables declared as in or centroid in may not be written to during shader execution.", 24 these tests ensure that a compile error is generated when using a shader input with interpolation qualifier as l-value. 25 --> 26 <script type="application/javascript"> 27 "use strict"; 28 description(); 29 30 var vertexShaderTemplate = [ 31 '#version 300 es', 32 '$(InterpolationQualifier) out float v_float_varying;', 33 'void main()', 34 '{', 35 ' v_float_varying = 1.0;', 36 ' gl_Position = vec4(0.0, 0.0, 0.0, 1.0);', 37 '}' 38 ].join('\n'); 39 40 var fragmentShaderTemplate = [ 41 '#version 300 es', 42 'precision mediump float;', 43 '$(InterpolationQualifier) in float v_float_varying;', 44 'out vec4 my_color;', 45 'void main()', 46 '{', 47 ' v_float_varying = 1.0;', 48 ' my_color = vec4(1.0, 0.0, 0.0, v_float_varying);', 49 '}' 50 ].join('\n'); 51 52 var errorMessageTemplate = "Writting to shader inputs with '$(InterpolationQualifier)' qualifier must fail"; 53 54 var testDataList = [ 55 { 56 InterpolationQualifier: 'flat' 57 }, 58 { 59 InterpolationQualifier: 'smooth' 60 }, 61 { 62 InterpolationQualifier: 'centroid' 63 } 64 ]; 65 66 var wtu = WebGLTestUtils; 67 68 var tests = []; 69 for (var i = 0; i < testDataList.length; ++i) { 70 tests.push({ 71 vShaderSource: wtu.replaceParams(vertexShaderTemplate, testDataList[i]), 72 vShaderSuccess: true, 73 fShaderSource: wtu.replaceParams(fragmentShaderTemplate, testDataList[i]), 74 fShaderSuccess: false, 75 linkSuccess: false, 76 passMsg: wtu.replaceParams(errorMessageTemplate, testDataList[i]) 77 }); 78 } 79 80 GLSLConformanceTester.runTests(tests, 2); 81 </script> 82 </body> 83 </html>