Skip to content

Commit

Permalink
com.unity.netcode@0.51.0-preview.32
Browse files Browse the repository at this point in the history
## [0.51.0] - 2022-05-04

### Changed

* Package Dependencies
    * `com.unity.entities` to version `0.51.0`
* Updated transport dependency to 1.0.0.

## [0.50.1] - 2022-03-18

### Added

* Hybrid assemblies will not be included in DOTS Runtime builds.

### Changed

* Changed: Tick systems (Initialization, Simulation, Presentation) are not created as part of the default client-server bootstrap for Hybrid and the Client and Server worlds are updated by the PlayerLoop instead.

### Fixed

* Fixed an exception in `PhysicsWorldHistory` when enabling lag compensation.
* Fixed a rare compile error when source generators found invalid data in the package cache.
* Fixed issue that prevent systems been shown in System Hierarchy window.
* Fixed an issue where RPCs could be lost in rare cases when sending too many of them.
* Fix an incorrect overflow exception when pre-spawned or predicted spawned ghost serialize a subset of the fields.
  • Loading branch information
Unity Technologies committed May 4, 2022
1 parent 5ae2429 commit 42f7e23
Show file tree
Hide file tree
Showing 28 changed files with 120 additions and 95 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [0.51.0] - 2022-05-04

### Changed

* Package Dependencies
* `com.unity.entities` to version `0.51.0`
* Updated transport dependency to 1.0.0.



## [0.50.1] - 2022-03-18

### Added
Expand All @@ -18,8 +28,6 @@
* Fixed an issue where RPCs could be lost in rare cases when sending too many of them.
* Fix an incorrect overflow exception when pre-spawned or predicted spawned ghost serialize a subset of the fields.



## [0.50.0] - 2021-09-17

### Added
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Authoring/Hybrid/PreSpawnedGhostsConversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PreSpawnedGhostsConversion : GameObjectConversionSystem
{
protected override void OnUpdate()
{
var hashToEntity = new NativeHashMap<ulong, Entity>(128, Allocator.TempJob);
var hashToEntity = new NativeParallelHashMap<ulong, Entity>(128, Allocator.TempJob);
// TODO: Check that the GhostAuthoringComponent is interpolated, as we don't support predicted atm
Entities.ForEach((GhostAuthoringComponent ghostAuthoring) =>
{
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Command/CommandReceiveSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected struct ReceiveJobData
[ReadOnly] public ComponentTypeHandle<NetworkSnapshotAckComponent> snapshotAckType;
[ReadOnly] public ComponentTypeHandle<NetworkIdComponent> networkIdType;
[ReadOnly] public ComponentTypeHandle<CommandTargetComponent> commmandTargetType;
[ReadOnly] public NativeHashMap<SpawnedGhost, Entity> ghostMap;
[ReadOnly] public NativeParallelHashMap<SpawnedGhost, Entity> ghostMap;

public uint serverTick;
public NetDebug netDebug;
Expand Down
Binary file modified Runtime/Gen/GeneratorShared.dll
Binary file not shown.
Binary file modified Runtime/Gen/Unity.NetCode.SourceGenerators.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions Runtime/NetDebugSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public NetDebug.LogLevelType LogLevel

#if NETCODE_DEBUG
private BeginSimulationEntityCommandBufferSystem m_Barrier;
public NativeHashMap<int, FixedString128Bytes> ComponentTypeNameLookup { get; private set; }
public NativeParallelHashMap<int, FixedString128Bytes> ComponentTypeNameLookup { get; private set; }
#endif

protected override void OnCreate()
{
m_NetDebug.Initialize();
#if NETCODE_DEBUG
m_Barrier = World.GetOrCreateSystem<BeginSimulationEntityCommandBufferSystem>();
ComponentTypeNameLookup = new NativeHashMap<int, FixedString128Bytes>(1024, Allocator.Persistent);
ComponentTypeNameLookup = new NativeParallelHashMap<int, FixedString128Bytes>(1024, Allocator.Persistent);
#else
Enabled = false;
#endif
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Rpc/IRpcCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public struct RpcSerializerState

public struct RpcDeserializerState
{
public NativeHashMap<SpawnedGhost, Entity> ghostMap;
public NativeParallelHashMap<SpawnedGhost, Entity> ghostMap;
}

public interface IRpcCommandSerializer<T> where T: struct, IComponentData
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Rpc/RpcQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public struct RpcQueue<TActionSerializer, TActionRequest>
where TActionSerializer : struct, IRpcCommandSerializer<TActionRequest>
{
internal ulong rpcType;
[ReadOnly] internal NativeHashMap<ulong, int> rpcTypeHashToIndex;
[ReadOnly] internal NativeParallelHashMap<ulong, int> rpcTypeHashToIndex;
internal bool dynamicAssemblyList;

public unsafe void Schedule(DynamicBuffer<OutgoingRpcDataStreamBufferComponent> buffer,
Expand Down
8 changes: 4 additions & 4 deletions Runtime/Rpc/RpcSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public int CompareTo(RpcData other)
private EntityQuery m_RpcBufferGroup;
private BeginSimulationEntityCommandBufferSystem m_Barrier;
private NativeList<RpcData> m_RpcData;
private NativeHashMap<ulong, int> m_RpcTypeHashToIndex;
private NativeParallelHashMap<ulong, int> m_RpcTypeHashToIndex;
private NativeQueue<RpcReceiveError> m_RpcErrors;
private bool m_CanRegister;
private NetDebugSystem m_NetDebugSystem;
Expand All @@ -105,7 +105,7 @@ public RpcSystem()
{
m_CanRegister = true;
m_RpcData = new NativeList<RpcData>(16, Allocator.Persistent);
m_RpcTypeHashToIndex = new NativeHashMap<ulong, int>(16, Allocator.Persistent);
m_RpcTypeHashToIndex = new NativeParallelHashMap<ulong, int>(16, Allocator.Persistent);
m_DynamicAssemblyList = DynamicAssemblyList;
}

Expand Down Expand Up @@ -202,8 +202,8 @@ struct RpcExecJob : IJobChunk
public BufferTypeHandle<OutgoingRpcDataStreamBufferComponent> outBufferType;
public NativeQueue<RpcReceiveError>.ParallelWriter errors;
[ReadOnly] public NativeList<RpcData> execute;
[ReadOnly] public NativeHashMap<ulong, int> hashToIndex;
[ReadOnly] public NativeHashMap<SpawnedGhost, Entity> ghostMap;
[ReadOnly] public NativeParallelHashMap<ulong, int> hashToIndex;
[ReadOnly] public NativeParallelHashMap<SpawnedGhost, Entity> ghostMap;

[ReadOnly] public ComponentTypeHandle<NetworkSnapshotAckComponent> ackType;
public uint localTime;
Expand Down
12 changes: 6 additions & 6 deletions Runtime/Snapshot/GhostChunkSerializationState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,26 +419,26 @@ static public ConnectionStateData Create(Entity connection)
return new ConnectionStateData
{
Entity = connection,
SerializationState = new UnsafeHashMap<ArchetypeChunk, GhostChunkSerializationState>(1024, Allocator.Persistent),
ClearHistory = new UnsafeHashMap<int, uint>(256, Allocator.Persistent),
SerializationState = new UnsafeParallelHashMap<ArchetypeChunk, GhostChunkSerializationState>(1024, Allocator.Persistent),
ClearHistory = new UnsafeParallelHashMap<int, uint>(256, Allocator.Persistent),
#if NETCODE_DEBUG
NetDebugPacket = new NetDebugPacket(),
#endif
GhostStateData = new GhostStateList(1024, 1024, Allocator.Persistent),
AckedPrespawnSceneMap = new UnsafeHashMap<ulong, int>(256, Allocator.Persistent),
AckedPrespawnSceneMap = new UnsafeParallelHashMap<ulong, int>(256, Allocator.Persistent),
m_NewLoadedPrespawnRanges = UnsafeList<PrespawnHelper.GhostIdInterval>.Create(32, Allocator.Persistent),
};
}

public Entity Entity;
public UnsafeHashMap<ArchetypeChunk, GhostChunkSerializationState> SerializationState;
public UnsafeHashMap<int, uint> ClearHistory;
public UnsafeParallelHashMap<ArchetypeChunk, GhostChunkSerializationState> SerializationState;
public UnsafeParallelHashMap<int, uint> ClearHistory;
#if NETCODE_DEBUG
public NetDebugPacket NetDebugPacket;
#endif

public GhostStateList GhostStateData;
public UnsafeHashMap<ulong, int> AckedPrespawnSceneMap;
public UnsafeParallelHashMap<ulong, int> AckedPrespawnSceneMap;
public ref UnsafeList<PrespawnHelper.GhostIdInterval> NewLoadedPrespawnRanges => ref m_NewLoadedPrespawnRanges[0];
private UnsafeList<PrespawnHelper.GhostIdInterval>* m_NewLoadedPrespawnRanges;

Expand Down
14 changes: 7 additions & 7 deletions Runtime/Snapshot/GhostChunkSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,30 @@ internal unsafe struct GhostChunkSerializer
public ComponentTypeHandle<GhostChildEntityComponent> ghostChildEntityComponentType;
public BufferTypeHandle<GhostGroup> ghostGroupType;
public NetworkSnapshotAckComponent snapshotAck;
public UnsafeHashMap<ArchetypeChunk, GhostChunkSerializationState> chunkSerializationData;
public UnsafeParallelHashMap<ArchetypeChunk, GhostChunkSerializationState> chunkSerializationData;
public DynamicComponentTypeHandle* ghostChunkComponentTypesPtr;
public int ghostChunkComponentTypesLength;
public uint currentTick;
public NetworkCompressionModel compressionModel;
public GhostSerializerState serializerState;
public int NetworkId;
public NativeHashMap<RelevantGhostForConnection, int> relevantGhostForConnection;
public NativeParallelHashMap<RelevantGhostForConnection, int> relevantGhostForConnection;
public GhostRelevancyMode relevancyMode;
public UnsafeHashMap<int, uint> clearHistoryData;
public UnsafeParallelHashMap<int, uint> clearHistoryData;
public ConnectionStateData.GhostStateList ghostStateData;
public uint CurrentSystemVersion;

public NetDebug netDebug;
#if NETCODE_DEBUG
public NetDebugPacket netDebugPacket;
public NativeHashMap<int, FixedString128Bytes> componentTypeNameLookup;
public NativeParallelHashMap<int, FixedString128Bytes> componentTypeNameLookup;
public bool enablePacketLogging;
public bool enablePerComponentProfiling;
public FixedString64Bytes ghostTypeName;
FixedString512Bytes debugLog;
#endif

[ReadOnly] public NativeHashMap<ArchetypeChunk, SnapshotPreSerializeData> SnapshotPreSerializeData;
[ReadOnly] public NativeParallelHashMap<ArchetypeChunk, SnapshotPreSerializeData> SnapshotPreSerializeData;
public bool forceSingleBaseline;
public bool keepSnapshotHistoryOnStructuralChange;
public bool snaphostHasCompressedGhostSize;
Expand Down Expand Up @@ -1234,7 +1234,7 @@ private void UpdateChunkHistory(int ghostType, ArchetypeChunk currentChunk, Ghos
{
var ghostSystemState = currentChunk.GetNativeArray(ghostSystemStateType);
var ghostEntities = currentChunk.GetNativeArray(entityType);
NativeHashMap<uint, IntPtr> prevSnapshots = default;
NativeParallelHashMap<uint, IntPtr> prevSnapshots = default;
for (int currentIndexInChunk = 0; currentIndexInChunk < currentChunk.Count; ++currentIndexInChunk)
{
ref var ghostState = ref ghostStateData.GetGhostState(ghostSystemState[currentIndexInChunk]);
Expand All @@ -1257,7 +1257,7 @@ private void UpdateChunkHistory(int ghostType, ArchetypeChunk currentChunk, Ghos
if (prevSnapshots.IsCreated)
prevSnapshots.Clear();
else
prevSnapshots = new NativeHashMap<uint, IntPtr>(GhostSystemConstants.SnapshotHistorySize, Allocator.Temp);
prevSnapshots = new NativeParallelHashMap<uint, IntPtr>(GhostSystemConstants.SnapshotHistorySize, Allocator.Temp);
for (int history = 0; history < GhostSystemConstants.SnapshotHistorySize; ++history)
{
// We do not want to copy snapshot data from the write index since it is ok to keep incomplete data there
Expand Down
12 changes: 6 additions & 6 deletions Runtime/Snapshot/GhostPreSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ internal unsafe struct SnapshotPreSerializeData
}
internal unsafe struct GhostPreSerializer : IDisposable
{
public NativeHashMap<ArchetypeChunk, SnapshotPreSerializeData> SnapshotData;
private NativeHashMap<ArchetypeChunk, SnapshotPreSerializeData> PreviousSnapshotData;
public NativeParallelHashMap<ArchetypeChunk, SnapshotPreSerializeData> SnapshotData;
private NativeParallelHashMap<ArchetypeChunk, SnapshotPreSerializeData> PreviousSnapshotData;
private EntityQuery m_Query;

public GhostPreSerializer(EntityQuery query)
{
SnapshotData = new NativeHashMap<ArchetypeChunk, SnapshotPreSerializeData>(1024, Allocator.Persistent);
PreviousSnapshotData = new NativeHashMap<ArchetypeChunk, SnapshotPreSerializeData>(1024, Allocator.Persistent);
SnapshotData = new NativeParallelHashMap<ArchetypeChunk, SnapshotPreSerializeData>(1024, Allocator.Persistent);
PreviousSnapshotData = new NativeParallelHashMap<ArchetypeChunk, SnapshotPreSerializeData>(1024, Allocator.Persistent);
m_Query = query;
}
void CleanupSnapshotData()
Expand Down Expand Up @@ -112,8 +112,8 @@ public void Dispose()
[BurstCompile]
struct GhostPreSerializeJob : IJobEntityBatch
{
public NativeHashMap<ArchetypeChunk, SnapshotPreSerializeData>.ParallelWriter SnapshotData;
[ReadOnly] public NativeHashMap<ArchetypeChunk, SnapshotPreSerializeData> PreviousSnapshotData;
public NativeParallelHashMap<ArchetypeChunk, SnapshotPreSerializeData>.ParallelWriter SnapshotData;
[ReadOnly] public NativeParallelHashMap<ArchetypeChunk, SnapshotPreSerializeData> PreviousSnapshotData;


[ReadOnly] public BufferFromEntity<GhostComponentSerializer.State> GhostComponentCollectionFromEntity;
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Snapshot/GhostPredictionDebugSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void Execute(int i)
struct PredictionDebugJob : IJobChunk
{
public DynamicTypeList DynamicTypeList;
[ReadOnly] public NativeHashMap<ArchetypeChunk, System.IntPtr> predictionState;
[ReadOnly] public NativeParallelHashMap<ArchetypeChunk, System.IntPtr> predictionState;

[ReadOnly] public ComponentTypeHandle<GhostComponent> ghostType;
[ReadOnly] public ComponentTypeHandle<PredictedGhostComponent> predictedGhostType;
Expand Down
12 changes: 6 additions & 6 deletions Runtime/Snapshot/GhostPredictionHistorySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ struct PredictionStateEntry
public System.IntPtr data;
}

internal NativeHashMap<ArchetypeChunk, System.IntPtr> PredictionState;
internal NativeParallelHashMap<ArchetypeChunk, System.IntPtr> PredictionState;
internal JobHandle PredictionStateWriteJobHandle {get; private set;}
JobHandle m_PredictionStateReadJobHandle;
NativeHashMap<ArchetypeChunk, int> m_StillUsedPredictionState;
NativeParallelHashMap<ArchetypeChunk, int> m_StillUsedPredictionState;
NativeQueue<PredictionStateEntry> m_NewPredictionState;
NativeQueue<PredictionStateEntry> m_UpdatedPredictionState;
EntityQuery m_PredictionQuery;
Expand All @@ -134,8 +134,8 @@ protected override void OnCreate()
m_GhostPredictionSystemGroup = World.GetExistingSystem<GhostPredictionSystemGroup>();
m_ClientSimulationSystemGroup = World.GetExistingSystem<ClientSimulationSystemGroup>();

PredictionState = new NativeHashMap<ArchetypeChunk, System.IntPtr>(128, Allocator.Persistent);
m_StillUsedPredictionState = new NativeHashMap<ArchetypeChunk, int>(128, Allocator.Persistent);
PredictionState = new NativeParallelHashMap<ArchetypeChunk, System.IntPtr>(128, Allocator.Persistent);
m_StillUsedPredictionState = new NativeParallelHashMap<ArchetypeChunk, int>(128, Allocator.Persistent);
m_NewPredictionState = new NativeQueue<PredictionStateEntry>(Allocator.Persistent);
m_UpdatedPredictionState = new NativeQueue<PredictionStateEntry>(Allocator.Persistent);
m_PredictionQuery = GetEntityQuery(ComponentType.ReadOnly<PredictedGhostComponent>(), ComponentType.ReadOnly<GhostComponent>());
Expand Down Expand Up @@ -238,8 +238,8 @@ struct PredictionBackupJob : IJobChunk
{
public DynamicTypeList DynamicTypeList;

[ReadOnly]public NativeHashMap<ArchetypeChunk, System.IntPtr> predictionState;
public NativeHashMap<ArchetypeChunk, int>.ParallelWriter stillUsedPredictionState;
[ReadOnly]public NativeParallelHashMap<ArchetypeChunk, System.IntPtr> predictionState;
public NativeParallelHashMap<ArchetypeChunk, int>.ParallelWriter stillUsedPredictionState;
public NativeQueue<PredictionStateEntry>.ParallelWriter newPredictionState;
public NativeQueue<PredictionStateEntry>.ParallelWriter updatedPredictionState;
[ReadOnly] public ComponentTypeHandle<GhostComponent> ghostComponentType;
Expand Down
8 changes: 4 additions & 4 deletions Runtime/Snapshot/GhostPredictionSmoothingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct SmoothingActionState
}

NativeList<ComponentType> m_UserSpecifiedComponentData;
NativeHashMap<ComponentType, SmoothingActionState> m_SmoothingActions;
NativeParallelHashMap<ComponentType, SmoothingActionState> m_SmoothingActions;

struct SmoothingAction : IComponentData {}
Entity m_HasSmoothingAction;
Expand Down Expand Up @@ -122,7 +122,7 @@ protected override void OnCreate()
m_PredictionQuery = GetEntityQuery(ComponentType.ReadOnly<PredictedGhostComponent>(), ComponentType.ReadOnly<GhostComponent>());

m_UserSpecifiedComponentData = new NativeList<ComponentType>(8, Allocator.Persistent);
m_SmoothingActions = new NativeHashMap<ComponentType, SmoothingActionState>(32, Allocator.Persistent);
m_SmoothingActions = new NativeParallelHashMap<ComponentType, SmoothingActionState>(32, Allocator.Persistent);

RequireSingletonForUpdate<GhostCollection>();
RequireSingletonForUpdate<SmoothingAction>();
Expand Down Expand Up @@ -176,7 +176,7 @@ struct PredictionSmoothingJob : IJobChunk
{
public DynamicTypeList DynamicTypeList;
public DynamicTypeList UserList;
[ReadOnly] public NativeHashMap<ArchetypeChunk, System.IntPtr> predictionState;
[ReadOnly] public NativeParallelHashMap<ArchetypeChunk, System.IntPtr> predictionState;

[ReadOnly] public ComponentTypeHandle<GhostComponent> ghostType;
[ReadOnly] public ComponentTypeHandle<PredictedGhostComponent> predictedGhostType;
Expand All @@ -190,7 +190,7 @@ struct PredictionSmoothingJob : IJobChunk
[ReadOnly] public StorageInfoFromEntity childEntityLookup;
[ReadOnly] public BufferTypeHandle<LinkedEntityGroup> linkedEntityGroupType;

[ReadOnly] public NativeHashMap<ComponentType, SmoothingActionState> smoothingActions;
[ReadOnly] public NativeParallelHashMap<ComponentType, SmoothingActionState> smoothingActions;
public uint tick;

const GhostComponentSerializer.SendMask requiredSendMask = GhostComponentSerializer.SendMask.Predicted;
Expand Down
Loading

0 comments on commit 42f7e23

Please sign in to comment.