vector-scalar-arithmetic-inside-loop.html (2705B)
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>GLSL vector/scalar arithmetic inside a for loop</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 src="../../../js/glsl-conformance-test.js"></script> 16 </head> 17 <body> 18 <div id="description"></div> 19 <div id="console"></div> 20 <script id="fShaderVectorMulAndAddInsideForLoop" type="x-shader/x-fragment"> 21 void main(){ 22 gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); 23 for (int i = 0; i < 2; i++) 24 { 25 gl_FragColor += (2.0 * gl_FragCoord.x); 26 } 27 if (gl_FragColor.g == gl_FragColor.r && 28 gl_FragColor.b == gl_FragColor.r && 29 gl_FragColor.a == gl_FragColor.r) 30 { 31 gl_FragColor = vec4(0, 1, 0, 1); 32 } 33 } 34 </script> 35 <script id="fShaderVectorCompoundMulAndAddInsideForLoop" type="x-shader/x-fragment"> 36 precision mediump float; 37 38 void main() { 39 gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); 40 for (int i = 0; i < 2; i++) 41 { 42 float x = gl_FragCoord.x; 43 gl_FragColor = gl_FragColor + (x *= 2.0); 44 } 45 if (gl_FragColor.g == gl_FragColor.r && 46 gl_FragColor.b == gl_FragColor.r && 47 gl_FragColor.a == gl_FragColor.r) 48 { 49 gl_FragColor = vec4(0, 1, 0, 1); 50 } 51 } 52 </script> 53 <script id="fShaderVectorCompoundDivAndAddInsideForLoop" type="x-shader/x-fragment"> 54 precision mediump float; 55 56 void main() { 57 gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); 58 for (int i = 0; i < 2; i++) 59 { 60 float x = gl_FragCoord.x; 61 gl_FragColor = gl_FragColor + (x /= 2.0); 62 } 63 if (gl_FragColor.g == gl_FragColor.r && 64 gl_FragColor.b == gl_FragColor.r && 65 gl_FragColor.a == gl_FragColor.r) 66 { 67 gl_FragColor = vec4(0, 1, 0, 1); 68 } 69 } 70 </script> 71 <script type="text/javascript"> 72 "use strict"; 73 description(); 74 75 // See http://crbug.com/772651 76 77 GLSLConformanceTester.runRenderTests([ 78 { 79 fShaderId: 'fShaderVectorMulAndAddInsideForLoop', 80 fShaderSuccess: true, 81 linkSuccess: true, 82 passMsg: "Adding a scalar to a vector inside for loop should work." 83 }, 84 { 85 fShaderId: 'fShaderVectorCompoundMulAndAddInsideForLoop', 86 fShaderSuccess: true, 87 linkSuccess: true, 88 passMsg: "Adding a scalar (target of a compound assignment/multiplication operation) to a vector inside for loop should work." 89 }, 90 { 91 fShaderId: 'fShaderVectorCompoundDivAndAddInsideForLoop', 92 fShaderSuccess: true, 93 linkSuccess: true, 94 passMsg: "Adding a scalar (target of a compound assignment/division operation) to a vector inside for loop should work." 95 } 96 ]); 97 </script> 98 </body> 99 </html>