Replies: 5 comments
-
Hello and welcome. The interoperability in the plugin is not a traditional P/Invoke, which has a significant performance cost relative to regular function calls. That's why there is no traditional glue code. This approach passes runtime pointers - bypassing the symbol table entirely. As soon as the plugin is loaded by the engine into memory, initialization logic starts gathering pointers of native functions into internal buffers which are passed to the managed runtime. When a user enters play mode, the runtime resolves assemblies with dependencies and invokes functionality, which generates optimized interop functions based on |
Beta Was this translation helpful? Give feedback.
-
Worth noting that with C# 9.0 it will be possible to replace my custom IL generators with a new function pointers feature which is essentially the same thing. There's also neat improvements in .NET 5 like the Pinned Object Heap for arrays, and low-level API to avoid GC transitions in some cases. |
Beta Was this translation helpful? Give feedback.
-
Wow. I never though about this way. This is amazing. Great work. But one thing is still confusing for me, how does the type converting happen? You can't call a native function which returns a string for example, or can you? With P/Invoke the layer of it takes care of the converting. |
Beta Was this translation helpful? Give feedback.
-
The traditional way of passing mutable strings to native functions is expensive. A pre-allocated byte buffer from the pool is used instead as a parameter and later converted to a managed string. See how |
Beta Was this translation helpful? Give feedback.
-
The runtime IL generation is now replaced with C# 9.0 function pointers, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey.
I know thats not a normal question and I think its not easy to answer this question either. But I am very curious on how it works under the hood?
What I know is that you are using CoreCLR in order to host a C# runtime to call specific things. But as I searched through your code I couldn't really find a DllImport or P/Invoke in order to glue C# and C++ together. I just saw some Delegate creation and don't quite understand this.
It would be glad if you could explain me a bit so its easier for me to fit UnrealCLR for my needs.
Thanks in advanced and really thank you for your work, its incredible.
Have a nice day
Beta Was this translation helpful? Give feedback.
All reactions