| <!DOCTYPE html> |
| <html> |
| <body> |
| <canvas id="cvs" style="border: 1px solid black"></canvas> |
| <script src="../resources/runner.js"></script> |
| <script> |
| function clearThruJS(context, mask) { |
| context.clear(mask); |
| } |
| const clearNoJS = |
| Function.prototype.call.bind(WebGLRenderingContext.prototype.clear); |
| |
| const imports = { |
| '../clearCalls.js': { |
| 'clearThruJS': clearThruJS, |
| 'clearNoJS': clearNoJS |
| } |
| }; |
| fetch("resources/wasm_webgpu.wasm").then( |
| response => response.arrayBuffer()).then( |
| buffer => {console.log(buffer); return WebAssembly.compile(buffer)}).then( |
| wasmModule => WebAssembly.instantiate(wasmModule, imports)).then( |
| instance => { |
| const testFuncThruJS = instance.exports.clearManyTimesThruJS; |
| const gl = cvs.getContext("webgl"); |
| const kClearsPerIteration = 1_000_000; |
| |
| PerfTestRunner.measureTime({ |
| description: 'Test calls from WebAssembly to ' + |
| 'WebGLRenderingContext.prototype.clear through ' + |
| 'JavaScript', |
| setup: function() {}, |
| run: function() { |
| testFuncThruJS(gl, kClearsPerIteration); |
| }, |
| iterationCount: 5 |
| }); |
| }); |
| </script> |
| </body> |
| </html> |