liveBook · Manning

Burst

As explained in High Performance Unity Game Development

Unity's optimizing compiler that converts compatible C# code into highly optimized native code.

Burst is Unity’s high-performance compiler for DOTS code. It uses SIMD instructions to apply the same operation to multiple data values at once, accelerating array-based gameplay work. section 12.0 section 12.6

Using Burst comes with practical constraints:

  • Code must use NativeArray and DOTS-compatible types, such as float2; this ties the code to Unity and limits reuse for server-side gameplay validation. section 12.5 section 12.6
  • Burst can process four floating-point values in one 128-bit register. Its performance benefits come with added code complexity. section 12.5
Listing 12.3 Allocating NativeArray gameplay data
public static void AllocateGameData(GameData gameData, Balance balance)
{
    gameData.EnemyPosition = 
        new NativeArray<float2>(balance.MaxEnemies, Allocator.Persistent); #A
    gameData.EnemyType = 
        new NativeArray<int>(balance.MaxEnemies, Allocator.Persistent);
    gameData.AliveEnemyIndices = 
        new NativeArray<int>(balance.MaxEnemies, Allocator.Persistent);
    gameData.DeadEnemyIndices = 
        new NativeArray<int>(balance.MaxEnemies, Allocator.Persistent);
    gameData.EnemyVelocityNative = 
        new NativeArray<float>(balance.EnemyVelocity, Allocator.Persistent);
}

Example NativeArray allocation for gameplay data used by Burst-oriented code. section 12.1.2

How High Performance Unity Game Development covers it

How deep it goes
Explains SIMD processing and compatible data requirements, but does not detail compiler internals.
Examples
Uses enemy-movement code and four floating-point values processed in one 128-bit register as examples.
What it assumes
Assumes gameplay data is arranged in arrays and specifies NativeArray and DOTS-compatible types for Burst.
What you can do after
Apply Burst to compatible array-based Unity code to process multiple values per instruction.
How it connects
Connects Burst to data-oriented design, NativeArray, Jobs, and ECS.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of High Performance Unity Game Development. The section links point to the parts of the book it draws on.