-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build a tiny RISC virtual machine which can interpret and execute native scripts #10071
Comments
Thanks @fwsGonzo for assisting me with my questions. |
1 doesnt web need wasm output anyway and most langs support wasm, gdscript could target it too instead building two paths 2 i know wasm doesnt work with how godot operates on non-web but with libgodot and hacking the wamr runtime separating scripting from inside godot it could work? 3 is libriscv an ir like mlir llvm, what is its goal? |
If we've already got gdscript in wasm, we can already use it. Like there's no benefit. If we can compile gdscript (feature doesn't exist) then we can also compile that to riscv (feature doesn't exist for basically the cost of a gcc compiler invoke).
|
2 the wasm to godot i seen it wasnt with libgodot but if its easier and works with consoles no problem |
Adds support for embedded sandboxed code. This would allow platforms without support for dynamic linking to ship with full binary translation performance. Essentially, this means that the code can be executed directly without needing to be linked at runtime, which can improve performance. This could potentially be beneficial for loading gdextension modules as it could speed up their execution. |
We discussed creating a proof-of-concept plan to validate the general idea.
Edited: So 3 and 4 relates to libriscv/libriscv#174 Edited:
Edited: Shared executables are implemented, but not loading a specific symbol Edited: Shared libraries are implemented, but crashing on a jump to a garbage location. |
it looks libriscv is simpler toolchain than what wasm is trying to do, very cool |
Since we can now load shared executables the next step is to load and execute a hello world function call with a shared object. |
There may be a few folks who, like me, misread this ticket slightly. I was thinking initially, "This is adding RISCV as a compile target for Godot extensions. If that is the case, why not add WASM as a target VM?" This proposal is not that. This proposal is, "Let us build a very tiny RISC virtual machine which can interpret and execute GDExtensions not targeted for it." |
We're working in @fwsGonzo 's discord https://discord.gg/ExhqfFMCDz feel free to join or discuss building a tiny RISC virtual machine which can interpret and execute GDExtensions. |
In https://github.com/fwsGonzo/godot-riscv 2b9eb6f0fb66745fafae3311a97f56f932763131 we implemented a print function from the RISCV machine in RISCV emulator that calls the host gdextension's print method. |
Not ready for release but the readme is updated. https://github.com/fwsGonzo/godot-riscv |
The project was renamed https://github.com/libriscv/godot-sandbox and we’re working on a future release on the godot asset library. |
https://github.com/libriscv/godot-sandbox/releases/tag/v0.12 v0.12: Automatic updates and program versioning
|
Closing as complete: https://github.com/libriscv/godot-sandbox/releases/tag/v0.17 We'll probably make a new godot engine proposal for mainline integration in the future, but not today. |
Describe the project you are working on
V-Sekai is a self-hostable MIT open source software stack built with Godot Engine 4. This project aims to provide a robust and flexible platform for game development.
Describe the problem or limitation you are having in your project
The main challenge we're facing is the inefficiency of compiling gdextension for multiple platform variants. Running a custom engine isn't feasible due to lack of adoption. We want more efficient and flexible ways to handle gdextension binaries. Additionally, we're interested in exploring the possibility of players distributing riscv binaries as user-generated scripts inside of godot scenes.
As part of our future work, we plan to convert gdscript bytecode via string templating the bytecode as c and compile it with the TCC c compiler.Describe the feature / enhancement and how it helps to overcome the problem or limitation
To address these issues, we propose building a tiny RISC virtual machine capable of interpreting and executing GDExtensions. The entire gdextension API would be wrapped and compiled as RISCV binaries. These binaries would function like shared libraries via librisc emulation, either as an interpreter or a register machine. An interpreter would allow us to maintain the fast developer iteration times that Godot Engine is known for, while an ahead-of-time compiled riscv binary would offer greater efficiency. We have already implemented instruction count limits.To address these issues, we propose building a tiny RISC virtual machine capable of interpreting and executing native scripts. The entire Godot Engine API would be wrapped and targeted as RISCV binaries. These binaries would execute via librisc emulation, either as an interpreter or a register machine. An interpreter would allow us to maintain the fast developer iteration times that Godot Engine is known for, while an ahead-of-time compiled riscv binary would offer greater efficiency. We have already implemented instruction count limits.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Our approach involves using libriscv's vmcall to call into the riscv emulator and exchange data.
If this enhancement will not be used often, can it be worked around with a few lines of script?
The alternative to using compiled code is slower gdscript or utilizing the godot orchestrator. However, these options may not provide the same level of efficiency and flexibility that our proposed solution offers.
Is there a reason why this should be core and not an add-on in the asset library?
While this could potentially be developed as an addon, we are currently tracking the proposal in godot-proposals for better visibility and collaboration. More information can be found at godot-riscv.
The text was updated successfully, but these errors were encountered: