vector-scalar-arithmetic-inside-loop-complex.html (2299B)
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 (complex cases)</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="fShaderVectorCompoundMulAndAddInSeparateStatementsInsideForLoop" type="x-shader/x-fragment"> 21 precision mediump float; 22 23 void main() { 24 gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); 25 for (int i = 0; i < 2; i++) 26 { 27 float x = gl_FragCoord.x; 28 float y = (x *= 2.0); 29 gl_FragColor = gl_FragColor + vec4(y, y, y, y); 30 } 31 if (gl_FragColor.g == gl_FragColor.r && 32 gl_FragColor.b == gl_FragColor.r && 33 gl_FragColor.a == gl_FragColor.r) 34 { 35 gl_FragColor = vec4(0, 1, 0, 1); 36 } 37 } 38 </script> 39 <script id="fShaderVectorCompoundMulAndAddInSeparateStatementsInsideForLoop2" type="x-shader/x-fragment"> 40 precision mediump float; 41 42 void main() { 43 gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); 44 for (int i = 0; i < 2; i++) 45 { 46 float x = gl_FragCoord.x; 47 float y = (x *= 2.0); 48 gl_FragColor = gl_FragColor + vec4(x, y, x, y); 49 } 50 if (gl_FragColor.g == gl_FragColor.r && 51 gl_FragColor.b == gl_FragColor.r && 52 gl_FragColor.a == gl_FragColor.r) 53 { 54 gl_FragColor = vec4(0, 1, 0, 1); 55 } 56 } 57 </script> 58 <script type="text/javascript"> 59 "use strict"; 60 description(); 61 62 // See http://crbug.com/772651 63 64 GLSLConformanceTester.runRenderTests([ 65 { 66 fShaderId: 'fShaderVectorCompoundMulAndAddInSeparateStatementsInsideForLoop', 67 fShaderSuccess: true, 68 linkSuccess: true, 69 passMsg: "Adding a vector that's just 4 copies of a scalar to another vector inside for loop should work." 70 }, 71 { 72 fShaderId: 'fShaderVectorCompoundMulAndAddInSeparateStatementsInsideForLoop2', 73 fShaderSuccess: true, 74 linkSuccess: true, 75 passMsg: "Adding a vector that's just 4 copies of a scalar stored in two different variables to another vector inside for loop should work." 76 } 77 ]); 78 </script> 79 </body> 80 </html>