-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[AOT] Integrating Taichi AOT with Unity #4808
Comments
Excited to see that Taichi is moving toward this direction! Could you also write down the concrete interfaces provided by Unity RHI pluggins? E.g. |
Detailed usage of |
Note: when using the Vulkan resources (e.g.
cc @bobcao3 |
Implementation details:
It sounds quite straightforward. However, there are still some critical problems that need to be solved next: Taichi side:
Unity side:
|
PR #5204 introduced a C# language binding generator for unity integration, so C# scripts can directly interact with the C-APIs as a native plugin in the future. It feels to me that it solves most of the problems we have atm, including on-device copy. I'm gonna continue to work on the implicit-fem demo and see if it feels good to Unity developers. |
Unity integration is considered done!
|
Concisely describe the proposed feature
As a potential large need of the game industry, we should give support to integrate Taichi AOT with commercial game engines. The first one could be Unity.
Describe the solution you'd like (if any)
A reasonable way to integrate Taichi AOT into Unity is via unity native plugin interface, which provides the different low-level graphics APIs (e.g. vulkan/metal/d3d11/d3d12/opengl) and provides the ability to access Unity's rendering pipeline. The NativeRenderingPlugin (NRP) repo demonstrates how to use Unity native plugin interface.
A expected usage of Taichi AOT in Unity
Considering the new features and the portability, firstly, we can explore using Taichi AOT in Unity both with
vulkan
backend. And for simplicity, we can just treat the Taichi AOT module as a computing module (like compute shader) at the current stage.Based on C API for Taichi AOT, we can give a user's expected usage of Taichi AOT:
taichi_set_runtime_context_arg_*
APIs to set kernel's parameters.Detailed usage of Unity native plugin interface
When the Unity plugin loads,
UnityPluginLoad(IUnityInterfaces* unityInterfaces)
is called automatically. You can get aIUnityInterfaces
instance here.Then you can get different low-level interfaces via
IUnityInterfaces
by using:Let's take
vulkan
as an example:The structure of
IUnityGraphicsVulkan
is source code. Here you can useIUnityGraphicsVulkan::Instance()
andIUnityGraphicsVulkan::AccessBuffer(...)
to access Unity's vulkan device/queue/buffers.The text was updated successfully, but these errors were encountered: