Skip to content

Commit 16d3fb2

Browse files
committed
Release 2
1 parent d6b6417 commit 16d3fb2

File tree

21 files changed

+210
-195
lines changed

21 files changed

+210
-195
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# ECS Cheat Sheet
2+
3+
Here is a quick reference of the common classes, interfaces, structs, and attributes that have been introduced in this documentation by [ECS](#ecs-related), [Burst compiler](#burst-compiler-related) and the [C# job system](#c#-job-system-related). Click the links below for more information from the Unity Manual and Scripting API.
4+
5+
> Note: This is not an exhaustive list and can be added to over time as ECS, and its related documentation, expands. Check the ECSJobDemo code and the [Scripting API]() under the namespaces mentioned below for more examples.
6+
7+
## C# job system related
8+
9+
> Note: These can also be used by ECS code, but they are part of the main Unity 2018.1 release and not part of the ECS packages.
10+
11+
| Namespace | Name | Type |
12+
| :-------------: |:-------------:| :-----:|
13+
| Unity.Collections | [NativeArray](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Collections.NativeArray_1.html) | Struct |
14+
| Unity.Collections | [NativeContainer](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Collections.LowLevel.Unsafe.NativeContainerAttribute.html) | Unsafe Class |
15+
| Unity.Collections | [NativeSlice](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Collections.NativeSlice_1.html) | Struct |
16+
| Unity.Jobs | [IJob](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Jobs.IJob.html) | Interface |
17+
| Unity.Jobs | [IJobParallelFor](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Jobs.IJobParallelFor.html) | Interface |
18+
| Unity.Jobs | [JobHandle](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Jobs.JobHandle.html) | Interface |
19+
| Unity.Jobs | [JobsUtility](https://docs.unity3d.com/es/2018.1/ScriptReference/Unity.Jobs.LowLevel.Unsafe.JobsUtility.html) | Unsafe Class |
20+
21+
### Attributes
22+
23+
* [[ReadOnly]](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Collections.ReadOnlyAttribute.html)
24+
* [[WriteOnly]](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Collections.WriteOnlyAttribute.html)
25+
26+
## ECS related
27+
28+
| Namespace | Name | Type |
29+
| :-------------: |:-------------:| :-----:|
30+
| Unity.Collections | [NativeHashMap](../../ECSJobDemos/Packages/com.unity.collections/Unity.Collections/NativeHashMap.cs) | Unsafe Struct |
31+
| Unity.Collections | [NativeList](../../ECSJobDemos/Packages/com.unity.collections/Unity.Collections/NativeList.cs) | Unsafe Struct |
32+
| Unity.Collections | [NativeQueue](../../ECSJobDemos/Packages/com.unity.collections/Unity.Collections/NativeQueue.cs) | Unsafe Struct |
33+
| Unity.Entities | [ComponentDataArray](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities/Iterators/ComponentDataArray.cs) | Unsafe Struct |
34+
| Unity.Entities | [ComponentDataFromEntity](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities/Iterators/ComponentDataFromEntity.cs) | Unsafe Struct |
35+
| Unity.Entities | [ComponentGroup](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities/Iterators/ComponentGroup.cs) | Unsafe Class |
36+
| Unity.Entities | [ComponentSystem](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities/ComponentSystem.cs) - [ECS Docs](./getting_started.md#what-is-ecs?) | Abstract Class |
37+
| Unity.Entities | [ComponentType](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities/Types/ComponentType.cs) | Struct |
38+
| Unity.Entities | [Entity](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities/EntityManager.cs) | Struct |
39+
| Unity.Entities | [EntityArchetype](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities/EntityManager.cs) | Unsafe Struct |
40+
| Unity.Entities | [EntityCommandBuffer](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities/EntityCommandBuffer.cs) | Unsafe Struct |
41+
| Unity.Entities | [EntityManager](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities/EntityManager.cs) | Unsafe Class |
42+
| Unity.Entities | [ExclusiveEntityTransaction](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities/ExclusiveEntityTransaction.cs) | Unsafe Struct |
43+
| Unity.Entities | [GameObjectEntity](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities.Hybrid/GameObjectEntity.cs) | Class |
44+
| Unity.Entities | [IComponentData](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities/IComponentData.cs) - [ECS Docs](./ecs_in_detail.md#icomponentdata) | Interface |
45+
| Unity.Entities | [IJobProcessComponentData](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities/IJobProcessComponentData.cs) | Interface |
46+
| Unity.Entities | [ISharedComponentData](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities/IComponentData.cs) - [ECS Docs](./ecs_in_detail.md#shared-componentdata) | Interface |
47+
| Unity.Entities | [JobComponentSystem](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities/ComponentSystem.cs) | Abstract Class |
48+
| Unity.Entities | [World](../../ECSJobDemos/Packages/com.unity.entities/Unity.Entities/Injection/World.cs) | Class |
49+
| Unity.Jobs | [IJobParallelForBatch](../../ECSJobDemos/Packages/com.unity.jobs/Unity.Jobs/IJobParallelForBatch.cs) | Interface |
50+
| Unity.Jobs | [IJobParallelForFilter](../../ECSJobDemos/Packages/com.unity.jobs/Unity.Jobs/IJobParallelForFilter.cs) | Interface |
51+
| Unity.Rendering | [MeshInstanceRendererComponent](../../ECSJobDemos/Packages/com.unity.entities/Unity.Rendering.Hybrid/MeshInstanceRendererComponent.cs) | Class |
52+
| Unity.Transforms | [PositionComponent](../../ECSJobDemos/Packages/com.unity.entities/Unity.Transforms/PositionComponent.cs) | Class |
53+
| Unity.Transforms | [CopyInitialTransformFromGameObjectComponent](../../ECSJobDemos/Packages/com.unity.entities/Unity.Transforms.Hybrid/CopyInitialTransformFromGameObjectComponent.cs) | Class |
54+
| Unity.Transforms | [TransformMatrixComponent](../../ECSJobDemos/Packages/com.unity.entities/Unity.Transforms/TransformMatrixComponent.cs) | Class |
55+
56+
### Attributes
57+
58+
* [Inject]
59+
60+
#### Unsafe attributes
61+
62+
* [[NativeContainer]](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Collections.LowLevel.Unsafe.NativeContainerAttribute.html)
63+
* [[NativeContainerIsAtomicWriteOnly]](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Collections.LowLevel.Unsafe.NativeContainerIsAtomicWriteOnlyAttribute.html)
64+
* [[NativeContainerSupportsMinMaxWriteRestriction]](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Collections.LowLevel.Unsafe.NativeContainerSupportsMinMaxWriteRestrictionAttribute.html)
65+
* [[NativeContainerNeedsThreadIndex]](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Collections.LowLevel.Unsafe.NativeContainerNeedsThreadIndexAttribute.html)
66+
* [[NativeContainerSupportsDeallocateOnJobCompletion]](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Collections.LowLevel.Unsafe.NativeContainerSupportsDeallocateOnJobCompletionAttribute.html)
67+
* [[NativeDisableUnsafePtrRestriction]](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Collections.LowLevel.Unsafe.NativeDisableUnsafePtrRestrictionAttribute.html)
68+
* [[NativeSetClassTypeToNullOnSchedule]](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Collections.LowLevel.Unsafe.NativeSetClassTypeToNullOnScheduleAttribute.html)
69+
70+
### Other
71+
72+
* \#if ENABLE_UNITY_COLLECTIONS_CHECKS ... #endif
73+
74+
## Burst compiler related
75+
76+
### Attributes
77+
78+
* [[BurstDiscard]](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Unity.Burst.BurstDiscardAttribute.html)
79+
* [ComputeJobOptimization]

Documentation/content/ecs_concepts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ECS concepts
22

3-
If you are familiar with [Entity-component-system](https://en.wikipedia.org/wiki/Entity%E2%80%93component%E2%80%93system) concepts, you might see the potential for naming conflicts with Unity's existing __GameObject__/__Component__ setup. Below is a list comparing how ECS concepts map to Unity's implementation:
3+
If you are familiar with [Entity-component-system](https://en.wikipedia.org/wiki/Entity%E2%80%93component%E2%80%93system) (ECS) concepts, you might see the potential for naming conflicts with Unity's existing __GameObject__/__Component__ setup. Below is a list comparing how ECS concepts map to Unity's implementation:
44

55
### Entity → Entity
66

Documentation/content/ecs_in_detail.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ See [ExclusiveEntityTransaction](#exclusiveentitytransaction) for more on avoidi
174174

175175
## Shared ComponentData
176176

177-
IComponentData is appropriate for data that varies between Entities, such as storing a world position. __ISharedComponentData__ is useful when many Entities have something in common, for example in the boid demo we instantiate many Entities from the same Prefab and thus the __InstanceRenderer__ between many boid Entities is exactly the same.
177+
IComponentData is appropriate for data that varies between Entities, such as storing a world position. __ISharedComponentData__ is useful when many Entities have something in common, for example in the boid demo we instantiate many Entities from the same Prefab and thus the __MeshInstanceRenderer__ between many boid Entities is exactly the same.
178178

179179
```cs
180180
[System.Serializable]
181-
public struct InstanceRenderer : ISharedComponentData
181+
public struct MeshInstanceRenderer : ISharedComponentData
182182
{
183183
public Mesh mesh;
184184
public Material material;
@@ -188,7 +188,7 @@ public struct InstanceRenderer : ISharedComponentData
188188
}
189189
```
190190

191-
In the boid demo we never change the InstanceRenderer component, but we do move all the Entities __TransformMatrix__ every frame.
191+
In the boid demo we never change the MeshInstanceRenderer component, but we do move all the Entities __TransformMatrix__ every frame.
192192

193193
The great thing about ISharedComponentData is that there is literally zero memory cost on a per Entity basis.
194194

Documentation/content/ecs_principles_and_vision.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# ECS principles and vision
1+
# Entity Component System principles and vision
2+
3+
The Entity Component System is built on a set of principles. These principles provide a good context for what we are trying to achieve. Some of the principles are clearly reflected in the code. Others are simply goals that we set for ourselves.
24

35
## Performance by default
46

@@ -8,10 +10,11 @@ We measure ourselves against the performance that can be achieved in C++ with ha
810

911
We are using a combination of compiler technology (Burst), containers (Unity.Collections), data layout of components (ECS) to make it easy to write efficient code by default.
1012

11-
* Multicore - TODO
12-
* SIMD - TODO
13-
* Data layout & iteration - TODO
14-
* Instantiation speed - TODO
13+
* Data layout & iteration - The Entity Component System gurantees linear data layout when iterating entities in chunks by default. This is a critical part of the performance gains provided by the Entity Component System.
14+
* The C# job system lets you write multithreaded code in a simple way. It also safe. The C# Job Debugger detects any race conditions.
15+
* Burst is our compiler specifically for C# jobs. C# job code follows certain patterns that we can use to produce more efficient machine code. Code is compiled & optimized for each target platforms taking advantage of SIMD instructions.
16+
17+
An example of this is the performance of Instantiation. Comparing to the theoretical limit, of instantiating 100.000 entities with 320 bytes of a memcpy takes 9ms. Instantiating those entities via the Entity Component System takes 10ms. So we are very close to the theoretical lmit.
1518

1619
At Unite Austin we showcased a demo with 100.000 individual units in a massive battle simulation running at 60 FPS. All game code was running multicore.
1720
[See ECS performance demo [Video]](https://www.youtube.com/watch?v=0969LalB7vw)
@@ -45,17 +48,18 @@ We are focused on providing best of class network engine support for hosted game
4548
* FPS - Simulation on the server
4649
* RTS - Deterministic lock step simulation
4750
* Arcade games - GGPO
48-
TODO: More detail / Links (maybe a game type example of what you would use each network architecture for)
51+
52+
> Note: To set expectations right, we are not yet shipping any networking code on top of Entity Component System. It is work in progress.
4953
5054
## Determinism
5155

5256
Our build pipeline must be [deterministic](https://en.wikipedia.org/wiki/Deterministic_algorithm). Users can choose if all simulation code should run deterministically.
5357

54-
This is important for networking, replay features and even advanced debugging tools.
58+
You should always get the same results with the same inputs, no matter what device is being used. This is important for networking, replay features and even advanced debugging tools.
5559

56-
We will leverage our Burst compiler to produce exact floating point math between different platforms. Imagine a linux server & iOS device running the same floating point math code. This is useful for many scenarios particularly for connected games, but also debugging, replay etc.
60+
To do this we will leverage our Burst compiler to produce exact floating point math between different platforms. Imagine a linux server & iOS device running the same floating point math code. This is useful for many scenarios particularly for connected games, but also debugging, replay etc.
5761

58-
TODO - link/explain the floating math problem a little before the burst compiler solved it (so those who are unaware of the fp math issue get the point.) Is this a good reference I'm not sure: https://hal.archives-ouvertes.fr/file/index/docid/281429/filename/floating-point-article.pdf
62+
> Note: Floating point math discrepancies is a problem that Unity decided to tackle head on. This issue has been known about for some time, but so far there has not been a need great enough to encourage people to solve it. For some insight into this problem, including some of the workarounds needed to avoid solving it, consider reading [Floating-Point Determinism by Bruce Dawson](https://randomascii.wordpress.com/2013/07/16/floating-point-determinism/).
5963
6064
## Sandbox
6165

0 commit comments

Comments
 (0)