There are many common algorithms that we use constantly: searching, filtering, mapping, and so forth. Today we’ll write a few in the Burst-friendly way as examples of how to write Burst-friendly code that’s still reusable and efficient.
Posts Tagged function
C# gives us lots of types of functions for us to call. We must constantly decide between them. Should this function be
static? Should it be
virtual? There are many factors that go into making the decision. Today we’ll look at the function types as a spectrum and hopefully get a little perspective on our options.
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!
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.
Continuing the series, today we’ll dive into local functions,
fixed blocks on arbitrary types with
stackalloc initializers to see how they’re all implemented in C++ and what assembly code ends up actually running on the CPU.
Sometimes it seems like Unity programming is a minefield. Plenty of innocuous-looking code secretly creates garbage and eventually the GC runs and causes a frame hitch. Today’s article is about some of those less-obvious ways to create garbage.
Two facts are at odds in Unity programming. First, delegates like
EventHandler are extremely common with or without events. Second, the garbage collector is a huge source of CPU spikes and memory fragmentation in our games. Why are these facts at odds? Because code that uses delegates is almost always written in a way that creates garbage. It’s an extremely easy trap to fall into, but this article will show you how to get out of it!