Unity LockBufferForWrite: When You Should Prefer Them and Why Your Choice Matters

Recently (2022.1) Unity introduced LockBufferForWrite buffer type, and respective API functions: Unity GraphicsBuffer.LockForWrite The documentation states “The returned native array points directly to GPU memory if possible.” It made me curious, how close is this “directly” exactly? Heaps in modern graphics API To summarize, currently there are two sources of the data between CPU and […]

Read More

Is .NET 8 performant enough?

While I’m experementing on making my execution environment for C++/C# interop I became curious about the performance of .NET 8 (under CoreCLR, not Mono). Maybe I can use it without Burst and transition via P/Invoke at all? Test suite Thankfully there’s already a test bench for Burst: https://github.com/nxrighthere/BurstBenchmarks As we can see there, .NET Core 3.1’s […]

Read More

.NET(s) Fields and their offsets

Field offsets can help you in numerous ways, first what comes in mind is that you can set fields of the struct or class instance without using TypedReference (doesn’t work in IL2CPP) and without GC allocs which comes with boxing when either instance or a value is a struct. Second, it could help you with unmanaged access to the class/struct for custom binary serialization, etc.

Read More