SlideShare a Scribd company logo
Using Entity Command
Buffers
Elora Krzanich
Software Engineer, DOTS
Overview
3
— What are Entity Command Buffers?
– Recording Commands
– Playback Order
— Command Playback
– EntityCommandBufferSystems
– Immediate vs Deferred
— Traps to Avoid
— Possible Future Improvements
Entity Command Buffers
4
Problem They Solve
5
— Structural changes happen on the Main Thread
— Solution for recording changes in parallel through Jobs
What are they?
6
— Chains of data transformations that are recorded
– Either from the Main Thread or within Jobs (Concurrent)
— Played back at a specific point in the future
– From an EntityCommandBufferSystem
Commands
7
— Some available commands
– Instantiate, Create, or Destroy an Entity
– Add, Set, or Remove Component Data
– Add or Set IBufferElementData to an Entity
– Add or Set SharedComponent Data
– Add or Remove Components to each Entity in an EntityQuery
— Main Thread vs Concurrent Commands
– Main Thread: Managed Data OK
– Concurrent: Subset with No Managed Data Allowed
Main Thread Chain
— Single chain
— Played back in order of recording
8
Concurrent Chains
— Multiple chains
— Playback in order by JobIndex
– JobIndex unique per batch of work
— Deterministic
– JobIndex becomes a way to sort
commands
– Large continuous chunks of
monotonically increasing numbers
9
Concurrent Chains Recording
10
— Multiple threads recording from Concurrent
EntityCommandBuffer to their own chain
11
12
13
Concurrent Chains Playback (Today)
14
— Find the batch with the lowest job index
— Start executing commands linearly until the end of the batch
— Repeat looking for the next smallest until done
15
16
17
Command Playback
18
Deferred vs Immediate Playback
19
— Deferred
– Scheduling Playback later in another EntityCommandBufferSystem
– Systems already there
– Example: BeginInitializationEntityCommandBufferSystem
— Immediate
– Calling myCommandBuffer.Playback(…) right after recording
– PostUpdateCommands: Right after System’s Update()
EntityCommandBufferSystem Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Taken from SpawnFromEntity example
BeginInitializationEntityCommandBufferSystem m_EntityCommandBufferSystem;
protected override void OnCreate()
{
// 1: Set your command buffer system
m_EntityCommandBufferSystem = World.GetOrCreateSystem<BeginInitializationEntityCommandBufferSystem>();
}
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
// 2: Pass a Concurrent Command Buffer into the job
var job = new SpawnJob
{
CommandBuffer = m_EntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent()
}.Schedule(this, inputDeps);
// 3: Add the JobHandle to the Command Buffer System
m_EntityCommandBufferSystem.AddJobHandleForProducer(job);
return job;
}
20
21
22
23
24
25
26
27
28
29
30
Traps to Avoid
31
Knowing When Data Is Available
32
— Important to know when you will need that data to exist
— Tradeoff: Narrow window for playback vs longer deferment
– Systems running between recording and playback will see the “old”
data
Deferred Entities
33
— Instantiate(…) returns an Entity that’s deferred
– It does not exist yet
– Has a negative Entity ID
— During Playback
– Entity gets a positive ID once it’s created
– Future references to that Entity in the chain are fixed up
Storing a Reference to a Deferred
Entity ID
— When your ComponentData
stores a reference to some entity
that will be created later
— That Entity will be invalid!
34
Too Many Sync Points
35
— Sync points can prevent a lot of work to be done in parallel
— Playing back commands when you need that data
— Consolidate those points to specific times in the frame
– Use the pre-existing ECB Systems or create your own
ECB Invalid After Playback
36
— Once it’s played back, can’t record to it again
— Error regarding a Native Container
— Create a new ECB
Possible Future
Improvements
37
Bursted ECB
38
— Bursted Recording and Bursted Playback
— Recording Available Soon!
Bursted ECB Code Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Taken from SpawnFromEntity example
[BurstCompile(CompileSynchronously = true)]
struct SpawnJob : IJobForEachWithEntity<Spawner_FromEntity, LocalToWorld>
{
public EntityCommandBuffer.Concurrent CommandBuffer;
public void Execute(Entity entity, int index, [ReadOnly] ref Spawner_FromEntity spawnerFromEntity,
[ReadOnly] ref LocalToWorld location)
{
for (var x = 0; x < spawnerFromEntity.CountX; x++) // CountX = 100
{
for (var y = 0; y < spawnerFromEntity.CountY; y++) // CountY = 100
{
var instance = CommandBuffer.Instantiate(index, spawnerFromEntity.Prefab);
// Place the instantiated in a grid with some noise
var position = math.transform(location.Value,
new float3(x * 1.3F, noise.cnoise(new float2(x, y) * 0.21F) * 2, y * 1.3F));
CommandBuffer.SetComponent(index, instance, new Translation {Value = position});
}
}
CommandBuffer.DestroyEntity(index, entity);
}
}
39
40
36.2
Without Burst (in ms)
0.64
With Burst (in ms)*
*Average = 10x speedup
10kEntities
Batched Playback
41
— Processing certain commands in bulk for better performance
– Such as Instantiate or AddComponent
— All playback is still happening on the Main Thread
Entity Manager Feature Parity
42
— EntityManager has more options for each function
– Such as AddComponent ( NativeArray <Entity>, Component )
— Would like them to be unified
Review
43
What To Remember
44
— Chains of data transformations
— Played back at a specific point in the future
— Think about the point when you need that data
— No managed data within jobs, therefore no commands with
managed data within jobs
Thank you!
45

More Related Content

What's hot

Wreaking Havok: an overview of Havok Physics in Unity – Unite Copenhagen 2019
Wreaking Havok: an overview of Havok Physics in Unity – Unite Copenhagen 2019Wreaking Havok: an overview of Havok Physics in Unity – Unite Copenhagen 2019
Wreaking Havok: an overview of Havok Physics in Unity – Unite Copenhagen 2019
Unity Technologies
 
Ue4 에서의 환경변화 구현
Ue4 에서의 환경변화 구현Ue4 에서의 환경변화 구현
Ue4 에서의 환경변화 구현
kyuil choi
 
Precomputed Voxelized-Shadows for Large-scale Scene and Many lights
Precomputed Voxelized-Shadows for Large-scale Scene and Many lightsPrecomputed Voxelized-Shadows for Large-scale Scene and Many lights
Precomputed Voxelized-Shadows for Large-scale Scene and Many lights
Seongdae Kim
 
190119 unreal engine c++ 입문 및 팁
190119 unreal engine c++ 입문 및 팁190119 unreal engine c++ 입문 및 팁
190119 unreal engine c++ 입문 및 팁
KWANGIL KIM
 
[KGC2014] DX9에서DX11로의이행경험공유
[KGC2014] DX9에서DX11로의이행경험공유[KGC2014] DX9에서DX11로의이행경험공유
[KGC2014] DX9에서DX11로의이행경험공유
Hwan Min
 
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
Codemotion
 
Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)
Alexander Dolbilov
 
Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)
Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)
Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)
Johan Andersson
 
LOD and Culling Systems That Scale - Unite LA
LOD and Culling Systems That Scale  - Unite LALOD and Culling Systems That Scale  - Unite LA
LOD and Culling Systems That Scale - Unite LA
Unity Technologies
 
Practical SPU Programming in God of War III
Practical SPU Programming in God of War IIIPractical SPU Programming in God of War III
Practical SPU Programming in God of War III
Slide_N
 
Motion blur
Motion blurMotion blur
Motion blur
changehee lee
 
Unreal python
Unreal pythonUnreal python
Unreal python
TonyCms
 
Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)
Tiago Sousa
 
Killzone Shadow Fall Demo Postmortem
Killzone Shadow Fall Demo PostmortemKillzone Shadow Fall Demo Postmortem
Killzone Shadow Fall Demo Postmortem
Guerrilla
 
Triangle Visibility buffer
Triangle Visibility bufferTriangle Visibility buffer
Triangle Visibility buffer
Wolfgang Engel
 
Speed up your asset imports for big projects - Unite Copenhagen 2019
Speed up your asset imports for big projects - Unite Copenhagen 2019Speed up your asset imports for big projects - Unite Copenhagen 2019
Speed up your asset imports for big projects - Unite Copenhagen 2019
Unity Technologies
 
Built for performance: the UIElements Renderer – Unite Copenhagen 2019
Built for performance: the UIElements Renderer – Unite Copenhagen 2019Built for performance: the UIElements Renderer – Unite Copenhagen 2019
Built for performance: the UIElements Renderer – Unite Copenhagen 2019
Unity Technologies
 
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle GamesWe Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
Unity Technologies
 
Best practices: Async vs. coroutines - Unite Copenhagen 2019
Best practices: Async vs. coroutines - Unite Copenhagen 2019Best practices: Async vs. coroutines - Unite Copenhagen 2019
Best practices: Async vs. coroutines - Unite Copenhagen 2019
Unity Technologies
 
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Johan Andersson
 

What's hot (20)

Wreaking Havok: an overview of Havok Physics in Unity – Unite Copenhagen 2019
Wreaking Havok: an overview of Havok Physics in Unity – Unite Copenhagen 2019Wreaking Havok: an overview of Havok Physics in Unity – Unite Copenhagen 2019
Wreaking Havok: an overview of Havok Physics in Unity – Unite Copenhagen 2019
 
Ue4 에서의 환경변화 구현
Ue4 에서의 환경변화 구현Ue4 에서의 환경변화 구현
Ue4 에서의 환경변화 구현
 
Precomputed Voxelized-Shadows for Large-scale Scene and Many lights
Precomputed Voxelized-Shadows for Large-scale Scene and Many lightsPrecomputed Voxelized-Shadows for Large-scale Scene and Many lights
Precomputed Voxelized-Shadows for Large-scale Scene and Many lights
 
190119 unreal engine c++ 입문 및 팁
190119 unreal engine c++ 입문 및 팁190119 unreal engine c++ 입문 및 팁
190119 unreal engine c++ 입문 및 팁
 
[KGC2014] DX9에서DX11로의이행경험공유
[KGC2014] DX9에서DX11로의이행경험공유[KGC2014] DX9에서DX11로의이행경험공유
[KGC2014] DX9에서DX11로의이행경험공유
 
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
 
Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)
 
Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)
Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)
Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)
 
LOD and Culling Systems That Scale - Unite LA
LOD and Culling Systems That Scale  - Unite LALOD and Culling Systems That Scale  - Unite LA
LOD and Culling Systems That Scale - Unite LA
 
Practical SPU Programming in God of War III
Practical SPU Programming in God of War IIIPractical SPU Programming in God of War III
Practical SPU Programming in God of War III
 
Motion blur
Motion blurMotion blur
Motion blur
 
Unreal python
Unreal pythonUnreal python
Unreal python
 
Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)
 
Killzone Shadow Fall Demo Postmortem
Killzone Shadow Fall Demo PostmortemKillzone Shadow Fall Demo Postmortem
Killzone Shadow Fall Demo Postmortem
 
Triangle Visibility buffer
Triangle Visibility bufferTriangle Visibility buffer
Triangle Visibility buffer
 
Speed up your asset imports for big projects - Unite Copenhagen 2019
Speed up your asset imports for big projects - Unite Copenhagen 2019Speed up your asset imports for big projects - Unite Copenhagen 2019
Speed up your asset imports for big projects - Unite Copenhagen 2019
 
Built for performance: the UIElements Renderer – Unite Copenhagen 2019
Built for performance: the UIElements Renderer – Unite Copenhagen 2019Built for performance: the UIElements Renderer – Unite Copenhagen 2019
Built for performance: the UIElements Renderer – Unite Copenhagen 2019
 
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle GamesWe Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
 
Best practices: Async vs. coroutines - Unite Copenhagen 2019
Best practices: Async vs. coroutines - Unite Copenhagen 2019Best practices: Async vs. coroutines - Unite Copenhagen 2019
Best practices: Async vs. coroutines - Unite Copenhagen 2019
 
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
 

Similar to Using Entity Command Buffers – Unite Copenhagen 2019

Linux Kernel Tour
Linux Kernel TourLinux Kernel Tour
Linux Kernel Tour
samrat das
 
Operating System Assignment Help
Operating System Assignment HelpOperating System Assignment Help
Operating System Assignment Help
Programming Homework Help
 
Juniper防火墙case信息收集表
Juniper防火墙case信息收集表Juniper防火墙case信息收集表
Juniper防火墙case信息收集表
mickchen
 
Computer Science Assignment Help
Computer Science Assignment HelpComputer Science Assignment Help
Computer Science Assignment Help
Programming Homework Help
 
Here we can see detailed explanation on processes and their methods
Here we can see detailed explanation on processes and their methodsHere we can see detailed explanation on processes and their methods
Here we can see detailed explanation on processes and their methods
srivallipeyyala
 
Your first dive into systemd!
Your first dive into systemd!Your first dive into systemd!
Your first dive into systemd!
Etsuji Nakai
 
Parallelizing Conqueror's Blade
Parallelizing Conqueror's BladeParallelizing Conqueror's Blade
Parallelizing Conqueror's Blade
Intel® Software
 
06.Mechanism_Limieted_Direct_Execution (4).pptx
06.Mechanism_Limieted_Direct_Execution (4).pptx06.Mechanism_Limieted_Direct_Execution (4).pptx
06.Mechanism_Limieted_Direct_Execution (4).pptx
AndrewSamir16
 
Boot prom basics
Boot prom basicsBoot prom basics
Boot prom basics
Ganesh Kumar Veerla
 
Ch04 system administration
Ch04 system administration Ch04 system administration
Ch04 system administration
Raja Waseem Akhtar
 
Ch04
Ch04Ch04
Когда предрелизный не только софт
Когда предрелизный не только софтКогда предрелизный не только софт
Когда предрелизный не только софт
CEE-SEC(R)
 
Java On CRaC
Java On CRaCJava On CRaC
Java On CRaC
Simon Ritter
 
Return Oriented Programming (ROP) Based Exploits - Part I
Return Oriented Programming  (ROP) Based Exploits  - Part IReturn Oriented Programming  (ROP) Based Exploits  - Part I
Return Oriented Programming (ROP) Based Exploits - Part I
n|u - The Open Security Community
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
Boulos Dib
 
Nikita Tuk: Handling background processes in iOS: problems & solutions
Nikita Tuk: Handling background processes in iOS: problems & solutionsNikita Tuk: Handling background processes in iOS: problems & solutions
Nikita Tuk: Handling background processes in iOS: problems & solutions
mdevtalk
 
maXbox Starter 42 Multiprocessing Programming
maXbox Starter 42 Multiprocessing Programming maXbox Starter 42 Multiprocessing Programming
maXbox Starter 42 Multiprocessing Programming
Max Kleiner
 
DEF CON 27 - KYLE GWINNUP - next generation process emulation with binee
DEF CON 27 - KYLE GWINNUP - next generation process emulation with bineeDEF CON 27 - KYLE GWINNUP - next generation process emulation with binee
DEF CON 27 - KYLE GWINNUP - next generation process emulation with binee
Felipe Prado
 
Command pattern vs. MVC: Lean Beans (are made of this)
Command pattern vs. MVC: Lean Beans (are made of this)Command pattern vs. MVC: Lean Beans (are made of this)
Command pattern vs. MVC: Lean Beans (are made of this)
philipdurbin
 
MongoDB World 2019: Becoming an Ops Manager Backup Superhero!
MongoDB World 2019: Becoming an Ops Manager Backup Superhero!MongoDB World 2019: Becoming an Ops Manager Backup Superhero!
MongoDB World 2019: Becoming an Ops Manager Backup Superhero!
MongoDB
 

Similar to Using Entity Command Buffers – Unite Copenhagen 2019 (20)

Linux Kernel Tour
Linux Kernel TourLinux Kernel Tour
Linux Kernel Tour
 
Operating System Assignment Help
Operating System Assignment HelpOperating System Assignment Help
Operating System Assignment Help
 
Juniper防火墙case信息收集表
Juniper防火墙case信息收集表Juniper防火墙case信息收集表
Juniper防火墙case信息收集表
 
Computer Science Assignment Help
Computer Science Assignment HelpComputer Science Assignment Help
Computer Science Assignment Help
 
Here we can see detailed explanation on processes and their methods
Here we can see detailed explanation on processes and their methodsHere we can see detailed explanation on processes and their methods
Here we can see detailed explanation on processes and their methods
 
Your first dive into systemd!
Your first dive into systemd!Your first dive into systemd!
Your first dive into systemd!
 
Parallelizing Conqueror's Blade
Parallelizing Conqueror's BladeParallelizing Conqueror's Blade
Parallelizing Conqueror's Blade
 
06.Mechanism_Limieted_Direct_Execution (4).pptx
06.Mechanism_Limieted_Direct_Execution (4).pptx06.Mechanism_Limieted_Direct_Execution (4).pptx
06.Mechanism_Limieted_Direct_Execution (4).pptx
 
Boot prom basics
Boot prom basicsBoot prom basics
Boot prom basics
 
Ch04 system administration
Ch04 system administration Ch04 system administration
Ch04 system administration
 
Ch04
Ch04Ch04
Ch04
 
Когда предрелизный не только софт
Когда предрелизный не только софтКогда предрелизный не только софт
Когда предрелизный не только софт
 
Java On CRaC
Java On CRaCJava On CRaC
Java On CRaC
 
Return Oriented Programming (ROP) Based Exploits - Part I
Return Oriented Programming  (ROP) Based Exploits  - Part IReturn Oriented Programming  (ROP) Based Exploits  - Part I
Return Oriented Programming (ROP) Based Exploits - Part I
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
Nikita Tuk: Handling background processes in iOS: problems & solutions
Nikita Tuk: Handling background processes in iOS: problems & solutionsNikita Tuk: Handling background processes in iOS: problems & solutions
Nikita Tuk: Handling background processes in iOS: problems & solutions
 
maXbox Starter 42 Multiprocessing Programming
maXbox Starter 42 Multiprocessing Programming maXbox Starter 42 Multiprocessing Programming
maXbox Starter 42 Multiprocessing Programming
 
DEF CON 27 - KYLE GWINNUP - next generation process emulation with binee
DEF CON 27 - KYLE GWINNUP - next generation process emulation with bineeDEF CON 27 - KYLE GWINNUP - next generation process emulation with binee
DEF CON 27 - KYLE GWINNUP - next generation process emulation with binee
 
Command pattern vs. MVC: Lean Beans (are made of this)
Command pattern vs. MVC: Lean Beans (are made of this)Command pattern vs. MVC: Lean Beans (are made of this)
Command pattern vs. MVC: Lean Beans (are made of this)
 
MongoDB World 2019: Becoming an Ops Manager Backup Superhero!
MongoDB World 2019: Becoming an Ops Manager Backup Superhero!MongoDB World 2019: Becoming an Ops Manager Backup Superhero!
MongoDB World 2019: Becoming an Ops Manager Backup Superhero!
 

More from Unity Technologies

Build Immersive Worlds in Virtual Reality
Build Immersive Worlds  in Virtual RealityBuild Immersive Worlds  in Virtual Reality
Build Immersive Worlds in Virtual Reality
Unity Technologies
 
Augmenting reality: Bring digital objects into the real world
Augmenting reality: Bring digital objects into the real worldAugmenting reality: Bring digital objects into the real world
Augmenting reality: Bring digital objects into the real world
Unity Technologies
 
Let’s get real: An introduction to AR, VR, MR, XR and more
Let’s get real: An introduction to AR, VR, MR, XR and moreLet’s get real: An introduction to AR, VR, MR, XR and more
Let’s get real: An introduction to AR, VR, MR, XR and more
Unity Technologies
 
Using synthetic data for computer vision model training
Using synthetic data for computer vision model trainingUsing synthetic data for computer vision model training
Using synthetic data for computer vision model training
Unity Technologies
 
Unity Roadmap 2020: Live games
Unity Roadmap 2020: Live games Unity Roadmap 2020: Live games
Unity Roadmap 2020: Live games
Unity Technologies
 
Unity Roadmap 2020: Core Engine & Creator Tools
Unity Roadmap 2020: Core Engine & Creator ToolsUnity Roadmap 2020: Core Engine & Creator Tools
Unity Roadmap 2020: Core Engine & Creator Tools
Unity Technologies
 
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
Unity Technologies
 
Unity XR platform has a new architecture – Unite Copenhagen 2019
Unity XR platform has a new architecture – Unite Copenhagen 2019Unity XR platform has a new architecture – Unite Copenhagen 2019
Unity XR platform has a new architecture – Unite Copenhagen 2019
Unity Technologies
 
Turn Revit Models into real-time 3D experiences
Turn Revit Models into real-time 3D experiencesTurn Revit Models into real-time 3D experiences
Turn Revit Models into real-time 3D experiences
Unity Technologies
 
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
Unity Technologies
 
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
Unity Technologies
 
QA your code: The new Unity Test Framework – Unite Copenhagen 2019
QA your code: The new Unity Test Framework – Unite Copenhagen 2019QA your code: The new Unity Test Framework – Unite Copenhagen 2019
QA your code: The new Unity Test Framework – Unite Copenhagen 2019
Unity Technologies
 
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
Unity Technologies
 
Supplying scalable VR training applications with Innoactive - Unite Copenhage...
Supplying scalable VR training applications with Innoactive - Unite Copenhage...Supplying scalable VR training applications with Innoactive - Unite Copenhage...
Supplying scalable VR training applications with Innoactive - Unite Copenhage...
Unity Technologies
 
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
Unity Technologies
 
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
Unity Technologies
 
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
Unity Technologies
 
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
Unity Technologies
 
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019
Unity Technologies
 
Digital twins: the power of a virtual visual copy - Unite Copenhagen 2019
Digital twins: the power of a virtual visual copy - Unite Copenhagen 2019Digital twins: the power of a virtual visual copy - Unite Copenhagen 2019
Digital twins: the power of a virtual visual copy - Unite Copenhagen 2019
Unity Technologies
 

More from Unity Technologies (20)

Build Immersive Worlds in Virtual Reality
Build Immersive Worlds  in Virtual RealityBuild Immersive Worlds  in Virtual Reality
Build Immersive Worlds in Virtual Reality
 
Augmenting reality: Bring digital objects into the real world
Augmenting reality: Bring digital objects into the real worldAugmenting reality: Bring digital objects into the real world
Augmenting reality: Bring digital objects into the real world
 
Let’s get real: An introduction to AR, VR, MR, XR and more
Let’s get real: An introduction to AR, VR, MR, XR and moreLet’s get real: An introduction to AR, VR, MR, XR and more
Let’s get real: An introduction to AR, VR, MR, XR and more
 
Using synthetic data for computer vision model training
Using synthetic data for computer vision model trainingUsing synthetic data for computer vision model training
Using synthetic data for computer vision model training
 
Unity Roadmap 2020: Live games
Unity Roadmap 2020: Live games Unity Roadmap 2020: Live games
Unity Roadmap 2020: Live games
 
Unity Roadmap 2020: Core Engine & Creator Tools
Unity Roadmap 2020: Core Engine & Creator ToolsUnity Roadmap 2020: Core Engine & Creator Tools
Unity Roadmap 2020: Core Engine & Creator Tools
 
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
 
Unity XR platform has a new architecture – Unite Copenhagen 2019
Unity XR platform has a new architecture – Unite Copenhagen 2019Unity XR platform has a new architecture – Unite Copenhagen 2019
Unity XR platform has a new architecture – Unite Copenhagen 2019
 
Turn Revit Models into real-time 3D experiences
Turn Revit Models into real-time 3D experiencesTurn Revit Models into real-time 3D experiences
Turn Revit Models into real-time 3D experiences
 
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
 
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
 
QA your code: The new Unity Test Framework – Unite Copenhagen 2019
QA your code: The new Unity Test Framework – Unite Copenhagen 2019QA your code: The new Unity Test Framework – Unite Copenhagen 2019
QA your code: The new Unity Test Framework – Unite Copenhagen 2019
 
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
 
Supplying scalable VR training applications with Innoactive - Unite Copenhage...
Supplying scalable VR training applications with Innoactive - Unite Copenhage...Supplying scalable VR training applications with Innoactive - Unite Copenhage...
Supplying scalable VR training applications with Innoactive - Unite Copenhage...
 
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
 
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
 
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
 
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
 
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019
 
Digital twins: the power of a virtual visual copy - Unite Copenhagen 2019
Digital twins: the power of a virtual visual copy - Unite Copenhagen 2019Digital twins: the power of a virtual visual copy - Unite Copenhagen 2019
Digital twins: the power of a virtual visual copy - Unite Copenhagen 2019
 

Recently uploaded

“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
saastr
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 

Recently uploaded (20)

“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
Artificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic WarfareArtificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic Warfare
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 

Using Entity Command Buffers – Unite Copenhagen 2019

  • 1.
  • 2. Using Entity Command Buffers Elora Krzanich Software Engineer, DOTS
  • 3. Overview 3 — What are Entity Command Buffers? – Recording Commands – Playback Order — Command Playback – EntityCommandBufferSystems – Immediate vs Deferred — Traps to Avoid — Possible Future Improvements
  • 5. Problem They Solve 5 — Structural changes happen on the Main Thread — Solution for recording changes in parallel through Jobs
  • 6. What are they? 6 — Chains of data transformations that are recorded – Either from the Main Thread or within Jobs (Concurrent) — Played back at a specific point in the future – From an EntityCommandBufferSystem
  • 7. Commands 7 — Some available commands – Instantiate, Create, or Destroy an Entity – Add, Set, or Remove Component Data – Add or Set IBufferElementData to an Entity – Add or Set SharedComponent Data – Add or Remove Components to each Entity in an EntityQuery — Main Thread vs Concurrent Commands – Main Thread: Managed Data OK – Concurrent: Subset with No Managed Data Allowed
  • 8. Main Thread Chain — Single chain — Played back in order of recording 8
  • 9. Concurrent Chains — Multiple chains — Playback in order by JobIndex – JobIndex unique per batch of work — Deterministic – JobIndex becomes a way to sort commands – Large continuous chunks of monotonically increasing numbers 9
  • 10. Concurrent Chains Recording 10 — Multiple threads recording from Concurrent EntityCommandBuffer to their own chain
  • 11. 11
  • 12. 12
  • 13. 13
  • 14. Concurrent Chains Playback (Today) 14 — Find the batch with the lowest job index — Start executing commands linearly until the end of the batch — Repeat looking for the next smallest until done
  • 15. 15
  • 16. 16
  • 17. 17
  • 19. Deferred vs Immediate Playback 19 — Deferred – Scheduling Playback later in another EntityCommandBufferSystem – Systems already there – Example: BeginInitializationEntityCommandBufferSystem — Immediate – Calling myCommandBuffer.Playback(…) right after recording – PostUpdateCommands: Right after System’s Update()
  • 20. EntityCommandBufferSystem Example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 // Taken from SpawnFromEntity example BeginInitializationEntityCommandBufferSystem m_EntityCommandBufferSystem; protected override void OnCreate() { // 1: Set your command buffer system m_EntityCommandBufferSystem = World.GetOrCreateSystem<BeginInitializationEntityCommandBufferSystem>(); } protected override JobHandle OnUpdate(JobHandle inputDeps) { // 2: Pass a Concurrent Command Buffer into the job var job = new SpawnJob { CommandBuffer = m_EntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent() }.Schedule(this, inputDeps); // 3: Add the JobHandle to the Command Buffer System m_EntityCommandBufferSystem.AddJobHandleForProducer(job); return job; } 20
  • 21. 21
  • 22. 22
  • 23. 23
  • 24. 24
  • 25. 25
  • 26. 26
  • 27. 27
  • 28. 28
  • 29. 29
  • 30. 30
  • 32. Knowing When Data Is Available 32 — Important to know when you will need that data to exist — Tradeoff: Narrow window for playback vs longer deferment – Systems running between recording and playback will see the “old” data
  • 33. Deferred Entities 33 — Instantiate(…) returns an Entity that’s deferred – It does not exist yet – Has a negative Entity ID — During Playback – Entity gets a positive ID once it’s created – Future references to that Entity in the chain are fixed up
  • 34. Storing a Reference to a Deferred Entity ID — When your ComponentData stores a reference to some entity that will be created later — That Entity will be invalid! 34
  • 35. Too Many Sync Points 35 — Sync points can prevent a lot of work to be done in parallel — Playing back commands when you need that data — Consolidate those points to specific times in the frame – Use the pre-existing ECB Systems or create your own
  • 36. ECB Invalid After Playback 36 — Once it’s played back, can’t record to it again — Error regarding a Native Container — Create a new ECB
  • 38. Bursted ECB 38 — Bursted Recording and Bursted Playback — Recording Available Soon!
  • 39. Bursted ECB Code Example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 // Taken from SpawnFromEntity example [BurstCompile(CompileSynchronously = true)] struct SpawnJob : IJobForEachWithEntity<Spawner_FromEntity, LocalToWorld> { public EntityCommandBuffer.Concurrent CommandBuffer; public void Execute(Entity entity, int index, [ReadOnly] ref Spawner_FromEntity spawnerFromEntity, [ReadOnly] ref LocalToWorld location) { for (var x = 0; x < spawnerFromEntity.CountX; x++) // CountX = 100 { for (var y = 0; y < spawnerFromEntity.CountY; y++) // CountY = 100 { var instance = CommandBuffer.Instantiate(index, spawnerFromEntity.Prefab); // Place the instantiated in a grid with some noise var position = math.transform(location.Value, new float3(x * 1.3F, noise.cnoise(new float2(x, y) * 0.21F) * 2, y * 1.3F)); CommandBuffer.SetComponent(index, instance, new Translation {Value = position}); } } CommandBuffer.DestroyEntity(index, entity); } } 39
  • 40. 40 36.2 Without Burst (in ms) 0.64 With Burst (in ms)* *Average = 10x speedup 10kEntities
  • 41. Batched Playback 41 — Processing certain commands in bulk for better performance – Such as Instantiate or AddComponent — All playback is still happening on the Main Thread
  • 42. Entity Manager Feature Parity 42 — EntityManager has more options for each function – Such as AddComponent ( NativeArray <Entity>, Component ) — Would like them to be unified
  • 44. What To Remember 44 — Chains of data transformations — Played back at a specific point in the future — Think about the point when you need that data — No managed data within jobs, therefore no commands with managed data within jobs

Editor's Notes

  1. Data Oriented Tech Stack
  2. Telling them what to do and when to do it Some common issues we’ve seen people run into And possibilities for the future to make ECBs even more awesome!
  3. Explain what problem they try to solve Structural changes on the Main Thread, like Creating/Destroying Entities or Adding/Removing Components Here’s the solution to record changes in parallel and then play them back sequentially
  4. In jobs use the .Concurrent version of the ECB Data transforms like SetComponent EntityCommandBufferSystem is the system where an ECB executes all of the commands you recorded
  5. Multiple chains, one for each thread Monotonically = +1 each step
  6. Multiple threads (0, 1 and 2) recording to Concurrent EntityCommandBuffer Number of chains is equal to the number of threads These blocks might be different commands Instantiate Entity, SetComponentData, etc
  7. Thread0 finishes one batch and picks up another These batches don’t necessarily have to be uniform, it depends on the logic of your job
  8. What the chains look like after all commands are registered
  9. Remember we still want to keep determinism
  10. Multiple chains with various JobIndexes
  11. Find the lowest batch index, start executing commands Repeat until all commands are processed, which will end up looking like this…
  12. Playback the smallest job index from each thread until the end of the batch, then look for the next one
  13. Deferred vs Immediate: How long between recording the command and executing it? Deferred can be to the end of the frame, to the next frame, or at some other point you’ve determined Immediate will happen right after the commands were recorded Maybe you’ve used an ECB because you wanted to take advantage of Jobs (and soon Burst) for recording Other CommandBufferSystems BeginInitializationEntityCommandBufferSystem EndInitializationEntityCommandBufferSystem BeginSimulationEntityCommandBufferSystem EndSimulationEntityCommandBufferSystem BeginPresentationEntityCommandBufferSystem EndPresentationEntityCommandBufferSystem
  14. 1: Have a command buffer system 2: Pass in the concurrent version 3: The System needs to know about the job so that it can make sure it completes before trying to playback the command buffer This will have the Instantiate commands from the SpawnJob of this frame And then playback the commands at the BeginInitializeEntityCommandBufferSystem on the next frame This way the system knows to finish this job before it tries to playback your commands
  15. In this RPG, my character can cast poison on enemies That poison has a duration during which the enemy takes damage from Poison As a DPS, I want to do as much damage as possible to my enemies
  16. Stop everything and Add this component to my target Recorded using PostUpdateCommands so this happens right after my Ability System
  17. Poison is ticked, but no one’s taken any damage (DPS Life)
  18. Damage is taken
  19. This might not be your desired outcome or the player’s expectation They get cheated a frame of damage since will remove the poison once value is 0 With rendering, it would have shown up on the target before it took any damage
  20. Record the command to Add Poison at the beginning of the next simulation phase
  21. The BeginSimulationECBSystem plays back the AddComponent I recorded last frame Now there is a DOTS Poison component and Health component associated with this entity
  22. Since I want my poison damage to last for the entire duration of the cool down, this is the intended behavior
  23. Important to know when you will need that data to exist so that you can use the correct approach when playing back the commands Be mindful of other systems running between recording and playback, they will see the old data (which may be fine)
  24. Why is this a problem? It’s not, until you try…
  25. Using CommandBuffer.Instantiate(…) then referring to that entity outside of the command buffer Not currently possible to tie negative EntityID to its future positive EntityID
  26. Using a lot of sync points can prevent a lot of work to be done in parallel across systems Be sure you are playing back commands when you need them and try to consolidate those points to specific times in the frame
  27. So I had a system that added my DOTS Poison component to an ECB Then the BeginSimulationECBSystem played back that command That ECB is now Invalid and I’ll need to create a new one the next time my Ability System is run
  28. Next Entities package release for Burst ECB Recording
  29. We add CompileSynchronously = true because it only runs once at the beginning and don’t want Burst to JIT it after we need it (looking at caching the Burst code?) For this example x and y were both 100, so further optimizations could have been made to take advantage of more threads But say we have a single spawner that spawns a 100 x 100 grid (10000 Entities)
  30. On average, we see a 10x speedup, but in this case Burst was able to optimize where we didn’t It went from being a spawning setup you NEED to optimize, to being something that might be good enough So don’t underestimate what Burst can do for you!
  31. Many structural changes could be done in bulk Like making one big structural change instead of lots of little ones if we know we want to create X number of the same types of Entities And then you can serially set the data
  32. Another thing EntityManager can do is Add, Remove Chunk Components