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!
A couple weeks ago we took a look at the performance of function pointers in Burst. In doing so, we left out an alternative: good old switch
statements. Today we’ll put those to the test to see how they stack up next to Burst’s newfangled function pointers!
Now that we’ve seen how function pointers work and perform in Burst, let’s use them to build a higher-level feature: virtual functions!
Last week we took a look at function pointers in Burst 1.2 and Unity 2019.3. Today we’ll continue looking into them by analyzing their performance.
Unity 2019.3 and Burst 1.2 bring us support for function pointers! Behind the scenes, these power everyday C# functionality like virtual
and 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
-size buffers, fixed
blocks on arbitrary types with GetPinnableReference
, and 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 Action
, Func
, and 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!