When WASM got released (around 2017), there was already that discussion to allow direct bindings without a JS roundtrip, but AFAIK there is still no actual implementation for this in any browser.
392 karma · joined August 15, 2016
When WASM got released (around 2017), there was already that discussion to allow direct bindings without a JS roundtrip, but AFAIK there is still no actual implementation for this in any browser.
[0] https://www.sciencemediacenter.de/alle-angebote/rapid-reacti...
Unfortunately the license of Ultralight is questionable, and it's not open-source either by bypassing the WebKit license (which is very questionable as well since WebKit itself is BSD-licensed).
Having such a project as a free open-source variant would be a huge game changer in my opinion.
The Ray-Tracing Extension is currently only available for Windows and Linux.
My next plan is to implement the extension into Dawn's D3D12 backend, so I can build chromium with my Dawn fork and have Ray-Tracing available directly in the browser (at least for myself) :)
Multi-threading is possible with SharedArrayBuffers [0] and N-API allows to take the memory address of it. NVK is only a thin layer above Vulkan and JavaScript <-> C++ interopability is pretty fast. You only notice some overhead when making thousands of calls, because the C++ code cannot be inlined. But again, this is not something common in Vulkan.
Also JavaScript doesn't have essential features like Compute shaders for years now. Vulkan has all of it. Even though WebGPU [1] is in development, I don't expect it to give access to the Vulkan RTX pipeline anytime soon.
[0] SharedArrayBuffer: https://v8docs.nodesource.com/node-4.8/d4/db8/classv8_1_1_sh...
[1] WebGPU: https://github.com/gpuweb/gpuweb
Both implementations are very optimized and fast. Also DataView offers working with 64-bit values using the new BigInt type [2].
Here [3] a short example on how you can quickly build C-like structures in JavaScript
[0] DataView: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
[1] TextEncoder: https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder
[2] BigInt: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
[3] C-like Structures: https://jsfiddle.net/5tz0hsjq/
[0] https://github.com/maierfelix/node-vulkan/blob/master/exampl...
[1] https://github.com/maierfelix/node-vulkan/blob/master/genera...
There is some overhead but it seems acceptable. I get drops when calling a wasm function with a lot parameters (see .set).
[0] https://maierfelix.github.io/glmw/mat4/
Note: This benchmark is far from perfect but hopefully can provide some insights
Note: I'm either bad at doing correct benchmarks or the Javascript compiler is pretty sneaky at optimizing things.
[0] http://docs.nwjs.io/en/latest/For%20Users/Advanced/Protect%2...
this is a toy project I worked on for the past months. It's an early stage pokemon emerald emulator. Maps, tiles, animations, warps, sprites etc. are extracted from the provided ROM file.
After dragging a ROM file into the browser window, you can walk and explore the complete pokemon emerald world.
The game engine is created only for testing purposes, you will encounter a zillion bugs.
If you don't have a ROM file on hand (Attention, large GIFs):
- Warps: https://i.imgur.com/pYI9ipl.gif
- Behaviors: https://i.imgur.com/isgIRLD.gif
- Zooming: https://i.imgur.com/GMqDYKr.gif
- World Map: https://i.imgur.com/HmvBTAV.png
[0]: https://i.imgur.com/pYI9ipl.gif
[1]: https://i.imgur.com/isgIRLD.gif
Runtime type checking: https://maierfelix.github.io/Iroh/examples/type-checking/
JavaScript -> Flow conversion: https://maierfelix.github.io/Iroh/examples/auto-flow-types/
It's also possible to turn the runtime control-flow of running JavaScript into a playable game: https://maierfelix.github.io/src2game/
If you're wondering what the patched code looks like:
Input:
function add(a, b) {
return a + b;
};
add(2, 4);
Output: const $$STx1 = Iroh.stages["$$STx1"];
var $$frameValue = void 0;
$$STx1.$45(5)
function add(a, b) {
$$STx1.$4(6, this, add, arguments);
return $$STx1.$1(1, "add", $$STx1.$32(7, 1, a, b));
$$STx1.$5(6, this);
}
;
$$STx1.$44($$frameValue = $$STx1.$2(4, this, add, null, [$$STx1.$30(2, 2), $$STx1.$30(3, 4)]));
$$STx1.$46(5, $$frameValue)the code for the example is just ~100 LOC - it's a showcase of a library called "Iroh", which brings dynamic code analysis to the whole ES5 syntax. If you're wondering what the essence behind the example is, then I really recommend to give these links a try:
Github: https://github.com/maierfelix/Iroh
More examples: https://maierfelix.github.io/Iroh/examples/index.html
Cheers!
The most expensive data in 0.35 was:
- Pokemon models (They were dynamically loaded but cached then)
- Pokestop images (Server sends image url and client searches for a chached version)
- Syncing the player state with the client (Inventory, rewards, egg states..)
- Updating the map (Future pokemon spawns, pokestops/gyms in view..)
If a player is idle and doesn't move, just keeps farming a single pokestop and battles sometimes, then it should be relatively low cost since the game doesn't use a realtime communication (It's actually HTTPS based lol).