Open joshgoebel opened 2 years ago
Unless I've mistaken your intention, I don't see how this makes porting games easier unless you also force developers to use the getters and setters (and to never touch registers directly). This becomes pretty impractical for things like FRAMEBUFFER
where voodoo with the raw data is less uncommon.
Therefore, I'd say implementing the memory registers in a non-WASM runtime is actually easier than implementing the functions you proposed: just point the pointers in wasm.h
to variables rather than absolute memory addresses and do what the current WASM-4 runtimes do with the data in them.
I've started work on exactly this just for fun and it works great so far, so shoot me a message if you have any questions about how it could be done in practice.
This would make it easier to port WASM-4 goes too and from other platforms since one only needs to stub out the API.
Examples (in Zig)
Now:
After:
Porting to another platform would then only require implementing an equivalent (or stub)
setSystemFlags
function... and of course the compiler would likely optimize this down to nothing (by inlining the code) anyways, so I don't see a downside?