MADCSHARP Telegram 11
Finally managed to create a generic solution for direct function calling. This will even work under Burst, because it allows to use calli unmanaged cdecl calls, and .NET runtime can provide us this with Marshal.GetFunctionPointerForDelegate.

Tho this call creates some wrapper and reverse P/Invoke call, on IL2CPP it's absolutely useless, so we can call this function directly.

FuncIL2CPP/FuncIL2CPPStatic provides us this ability and we can safely use it within burst and call managed land functions without any conversion.

GetUnityCaller() returns a special call which can directly call IL2CPP methods without jumping to RuntimeMethodHandle->methodPtr again in again. This caller works in cross-runtime mode, so you can use it without unity without any limitations, tho it will give very little performance penalty.

For some reason IL2CPP doesn't compile the code where TReturn is returned by ref with Fully Shared Generics enabled, this is why I'm using RefReturn struct to overcome this behavior.

P.S. Different platforms using different function pointer alignment, WebGL doesn't restricts function to be aligned by 1 byte, which means I can't use first bit to store isIL2CPP flag, while Android ARMv7 (32bit) allows functions to store last bit, so I can't use it either. So for Unity IL2CPP direct calls I've made 64-bit field for funcPtr (even on 32-bit platforms) and use last (0x8000000000000000) bit as indicator for IL2CPP direct call. To make direct il2cpp calls faster it's possible to reinterpret to AsIL2CPP() if you are sure that you are running on IL2CPP.

#if ENABLE_IL2CPP
FuncIL2CPP func = unityCall.AsIL2CPP();
#else
FuncManaged func = unityCall.AsManaged();
#endif
👏3🔥2



tgoop.com/madcsharp/11
Create:
Last Update:

Finally managed to create a generic solution for direct function calling. This will even work under Burst, because it allows to use calli unmanaged cdecl calls, and .NET runtime can provide us this with Marshal.GetFunctionPointerForDelegate.

Tho this call creates some wrapper and reverse P/Invoke call, on IL2CPP it's absolutely useless, so we can call this function directly.

FuncIL2CPP/FuncIL2CPPStatic provides us this ability and we can safely use it within burst and call managed land functions without any conversion.

GetUnityCaller() returns a special call which can directly call IL2CPP methods without jumping to RuntimeMethodHandle->methodPtr again in again. This caller works in cross-runtime mode, so you can use it without unity without any limitations, tho it will give very little performance penalty.

For some reason IL2CPP doesn't compile the code where TReturn is returned by ref with Fully Shared Generics enabled, this is why I'm using RefReturn struct to overcome this behavior.

P.S. Different platforms using different function pointer alignment, WebGL doesn't restricts function to be aligned by 1 byte, which means I can't use first bit to store isIL2CPP flag, while Android ARMv7 (32bit) allows functions to store last bit, so I can't use it either. So for Unity IL2CPP direct calls I've made 64-bit field for funcPtr (even on 32-bit platforms) and use last (0x8000000000000000) bit as indicator for IL2CPP direct call. To make direct il2cpp calls faster it's possible to reinterpret to AsIL2CPP() if you are sure that you are running on IL2CPP.

#if ENABLE_IL2CPP
FuncIL2CPP func = unityCall.AsIL2CPP();
#else
FuncManaged func = unityCall.AsManaged();
#endif

BY MadSharp: Unsafe





Share with your friend now:
tgoop.com/madcsharp/11

View MORE
Open in Telegram


Telegram News

Date: |

Public channels are public to the internet, regardless of whether or not they are subscribed. A public channel is displayed in search results and has a short address (link). There have been several contributions to the group with members posting voice notes of screaming, yelling, groaning, and wailing in different rhythms and pitches. Calling out the “degenerate” community or the crypto obsessives that engage in high-risk trading, Co-founder of NFT renting protocol Rentable World emiliano.eth shared this group on his Twitter. He wrote: “hey degen, are you stressed? Just let it out all out. Voice only tg channel for screaming”. It’s yet another bloodbath on Satoshi Street. As of press time, Bitcoin (BTC) and the broader cryptocurrency market have corrected another 10 percent amid a massive sell-off. Ethereum (EHT) is down a staggering 15 percent moving close to $1,000, down more than 42 percent on the weekly chart. Done! Now you’re the proud owner of a Telegram channel. The next step is to set up and customize your channel. Private channels are only accessible to subscribers and don’t appear in public searches. To join a private channel, you need to receive a link from the owner (administrator). A private channel is an excellent solution for companies and teams. You can also use this type of channel to write down personal notes, reflections, etc. By the way, you can make your private channel public at any moment.
from us


Telegram MadSharp: Unsafe
FROM American