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!
Posts Tagged performance
Today we continue stealing float
bits, but in an entirely different way this time. We’ll end up with the ability to switch between float
and 21-bit integer modes and to know which mode we’re in. We can do all of this without using any more than four bytes just by exploiting a little knowledge of the float
data format. Read on to learn how!
With a bit of understanding and some C# trickery, we can exploit how float
works to cram in a few more bits and make some big performance gains. Today we’ll see how to steal some of the bits from a float
!
A reader recently asked what the fastest way to take an absolute value was. It occurred to me that there are a lot of ways to do this in Unity! So today we’ll try them all out and see which is best.
Unity’s Native Collections package, currently in Preview, provides a hash map but not a hash set. Today we’ll supplement NativeHashMap<TKey, TValue>
with our own NativeHashSet<T>
as part of the NativeCollections repo. Read on for performance results and to see how to use it!
Assertions are an incredibly handy tool, but do they work in Burst-compiled jobs? Today we’ll find out!
Ever wonder how code compiled with IL2CPP can call code compiled by Burst? Today we’ll dive into the details and find out!
Unity 2019.1’s new Burst job compiler has two options to increase performance even further: FloatPrecision
and FloatMode
. By sacrificing some exactness in our calculations, we should be able to increase speed. Today’s article is about using those options and examining the results to verify the results.
The Unity.Mathematics package documentation has a curious statement: “Note that currently, for an optimal usage of this library, it is recommended to use SIMD 4 wide types (float4, int4, bool4…)” Today we’ll explore why we should consider using float4
, not float3
, after years of using Vector3
.
Along with Unity 2019.1 and Burst, the Unity.Mathematics package is now out of Preview. It offers alternatives to longstanding core types in Unity such as Vector3
, Matrix4x4
, and Quaternion
. Today we’ll see how switching to these types can improve performance in Burst-compiled jobs.