MadSharp: Unsafe – Telegram
MadSharp: Unsafe
233 subscribers
8 photos
1 video
16 links
The channel is all about unobvious C#/Unity hacks and optimizations.
Blog: meetemq.com
Download Telegram
https://github.com/Meetem/ILCall

ILCall is now released at version 1.0.0 🎉🎉
You can make your IL additions by using provided sln to generate new ILCall.dll.

Binaries could be found in "Releases" section on GitHub.
👍6
An article on getting field offset of struct or class object, and how to make it cross-runtime, so it works in Unity (Mono/IL2CPP) and real dotnets.

Field offsets are good stuff to read/write fields without incurring into reflection, so we can avoid TypedReferences (not supported in IL2CPP) and also we avoid GC allocations for fieldInfo.SetValue(object target, object value), if both target and value are structs that's two boxing operations!

Let's dive in!
https://meetemq.com/2023/09/10/nets-fields-and-their-offsets/
🔥5
Запустил стрим, подпиливаем и пересобираем dotnet-runtime, буду юзать его для кастомного движка в поддержкой шарпа

https://www.youtube.com/live/U57DD1g6_nA?feature=shared
9👍1
Раз уж сегодня пятница, вечером в 19:00 МСК проведу стрим с ответами на вопросы. Буду рад ответить всем. Вопросы можно задать в комменты под постом, или прямо на стриме.
👍6
Наверняка у вас накопилось много вопросов.
И вот вам стрим где все можно спросит. Вопросы в чат на ютубе или в под этот пост. Начинаем через 5 минут.

https://www.youtube.com/live/Oy2LpjdmjFg?feature=shared
👍3
Forwarded from viruseg
Написал статью как работать с классом Gradient из под burst. И в процессе малость охренел, от того что моя реализация метода Evaluate оказалось в разы быстрее c++ реализации.
https://habr.com/ru/articles/761572/
👍14😐3
Finally!
There's a new article on .NET object layouts.
In the Part 1 the layouts of:
1. System.Object
2. T[] array
3. string

This article also reveals how to access those types in unsafe or unmanaged environment. How we can change the object type or get array/string length pointer to change it later.

https://meetemq.com/2023/09/27/managed-primitives-part-i/
🔥6👍1
👋 Анонс стрима

Всем привет, давно тут не было новостей. А все потому что я очень много работал, и реализовывал очень интересные вещи.

Работать я более менее закончил, поэтому запускаю стрим с вопросами и ответами про ансейф и все такое, можете заранее писать вопросы в комменты под этой новостью.

Когда? 16.01.2024
18:00 CET (20:00 MSK, 19:00 Kyiv)

Ссылочку выложу ближе к началу
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥12
Через полтора часа начинаем.
Пишите вопросы в комменты под этим или предыдущим постом.

18:00 CET
20:00 Msk
19:00 Kyiv

https://www.youtube.com/watch?v=vTXDPntqs6Y
🔥9👍2
Все знают что произошло.
Тем кто сочувствует — мои соболезнования. Сам только отхожу.
😢19
Ok, so I've managed to call MDI render on DX12 and Vulkan.
Previously I've been working on MDI for DX11 via NvAPI and it worked, tho NVIDIA doesn't have an API for passing an indirect count, but at least CPU count worked fine.

Unity mentioned that they may support MDI in BRG, but they actually don't and they don't even have plans to support it in Unity 6, so I made my little takeover.

There's a working proof of concept.
All material, shader, and render targets (basically a PSO) is set by Unity, so we don't need to go fully native.

Writing native rendering plugins for Unity is hard, mostly due to lack of documentation and even if it exists, there's a big chance it will not work.

😁 You are welcome to ask any questions in the comments, I will answer them in upcoming stream.
Please open Telegram to view this post
VIEW IN TELEGRAM
👍10🔥3
Сегодня сделаю стрим по обзору Unity Native Rendering Plugin
и ответами на вопросы.

Подключайтесь)

19:00 MSK
19:00 Kyiv
18:00 CEST

https://www.youtube.com/watch?v=XcjNVTHRxqI
👍7🔥32
Начинаем через 3 минуты!
Interseting discovery about Unity when using Vulkan.
See, Vulkan have two entry points to resolve functions: vkGetInstanceProcAddr and vkGetDeviceProcAddr.
vkGetInstanceProcAddr returns functions for a given VkInstance.
vkGetDeviceProcAddr on the other hand returns functions for a given VkDevice OR device child, e.g. VkQueue and VkCommandBuffer.
According to the docs, vkGetDeviceProcAddr is preferred when resolving device/-child functions, because returned address induce less overhead (probably because it doesn't need to resolve the child from VkInstance).

So, Unity requests vkGetDeviceProcAddr from Vulkan (or native plugin if hooked with InterceptVulkanInitialization). But actually never using it.
That means that all of the device/-child functions have an overhead to them. E.g. vkCmd* functions, vkQueue* functions etc. Those functions are actually used with insane frequency, in draw calls, uploading constants, binding buffer ranges etc.

The good thing is that we can reroute vkGetInstanceProcAddr to return pointers as vkGetDeviceProcAddr via native plugin. Which can give potential performance increase when events count is high.

How much performance? Well, you never know before you try. I think for 10K calls, say, on Android it could be measurable, like 0.5ms or something, but that's just my speculation.
👍5