Function pointers aren’t the only way to express a unit of work. Unity’s own job system does just this, albeit in a different way. Today we’ll compare the performance of Burst’s function pointers against jobs themselves!
Posts Tagged burst
Unity 2019.3 and Burst 1.2 bring us support for function pointers! Behind the scenes, these power everyday C# functionality like
abstract functions, delegates, and interfaces. Today we’ll look at how to use them and what Burst compiles them to.
IDisposable is becoming more and more prevalent in Unity. Previously, it was typically only used for I/O types like
FileStream. Now it’s used for in-memory types like
NativeArray<T> to avoid the garbage collector. Needing to call
Dispose manually means we’re explicitly managing memory, just like we’d do in lower-level languages like C++. That comes with some challenges, especially with shared ownership, which we’ll deal with today.
Unity provides exactly one collection:
NativeArray<T>. Compared to managed arrays in C#, these must be one-dimensional. So today we’re building a two-dimensional version of it:
NativeArray<T>. We’ll add this to the NativeCollections GitHub repository for easy inclusion into any project. Read on to learn more about the collection!
Job structs can’t contain managed types like
class instances, or delegates. This is currently a pain as a lot of the Unity API relies on these and so we’re forced to deal with them. Today we’ll talk about how we can use managed types in our jobs to bridge the gap.
A couple years ago, I wrote an article showing how to empower game designers with the ability to write simple formulas like
PlayerLevel*100+100. These are much more useful than just constants and don’t require any of the complexity of a real programming language. Today we’ll bring it into the Burst-compatible world and also improve its ability to handle more complex formulas.
Many algorithms get used over and over: searching, sorting, filtering, etc. C# makes these available with LINQ and functions like
Array.Sort, but these can’t be compiled by Burst because interfaces and delegates aren’t supported. So how do we implement these generic algorithms to avoid re-writing them over and over? Today we’ll explore one technique to solve this problem. Read on to learn how!