glsl-function-dot.html (2321B)
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 dot function test</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-generator.js"> </script> 17 </head> 18 <body> 19 <div id="description"></div> 20 <div id="console"></div> 21 <script> 22 "use strict"; 23 24 GLSLGenerator.runFeatureTest({ 25 feature: "dot", 26 args: "$(type) p1, $(type) p2", 27 baseArgs: "value$(field)", 28 testFunc: "$(func)($(type),$(type))", 29 fragmentTolerance: 1, 30 emuFuncs: [ 31 { type: "float", 32 code: [ 33 "float $(func)_emu($(args)) {", 34 " return p1 * p2;", 35 "}"].join("\n") 36 }, 37 { type: "vec2", 38 code: [ 39 "float $(func)_emu($(args)) {", 40 " return p1.x * p2.x + p1.y * p2.y;", 41 "}"].join("\n") 42 }, 43 { type: "vec3", 44 code: [ 45 "float $(func)_emu($(args)) {", 46 " return p1.x * p2.x + p1.y * p2.y + p1.z * p2.z;", 47 "}"].join("\n") 48 }, 49 { type: "vec4", 50 code: [ 51 "float $(func)_emu($(args)) {", 52 " return p1.x * p2.x + p1.y * p2.y + p1.z * p2.z + p1.w * p2.w;", 53 "}"].join("\n") 54 } 55 ], 56 gridRes: 8, 57 tests: [ 58 ["$(output) = vec4(", 59 " $(func)(", 60 " $(input).x * 8.0 - 4.0,", 61 " $(input).y * 8.0 - 4.0) / 8.0,", 62 " 0,", 63 " 0,", 64 " 1);"].join("\n"), 65 ["$(output) = vec4(", 66 " 0,", 67 " $(func)(", 68 " $(input).xy * 8.0 - 4.0,", 69 " $(input).wz * 8.0 - 4.0) / 8.0,", 70 " 0, 1);"].join("\n"), 71 ["$(output) = vec4(", 72 " 0, 0,", 73 " $(func)(", 74 " $(input).xyz * 8.0 - 4.0,", 75 " $(input).yzw * 8.0 - 4.0) / 8.0,", 76 " 1);"].join("\n"), 77 ["$(output) = vec4(", 78 " $(func)(", 79 " vec4($(input).xyz, 0) * 8.0 - 4.0,", 80 " vec4(0, $(input).wzy) * 8.0 - 4.0) / 8.0,", 81 " 0, 0, 1);", 82 ].join("\n") 83 ] 84 }); 85 var successfullyParsed = true; 86 </script> 87 </body> 88 </html>