Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.4.3] - 2024-10-16

### Fixed
* Entities graphics constantly allocating more memory without releasing it until next time system update is called.
  • Loading branch information
Unity Technologies committed Oct 16, 2024
1 parent bdc7d9e commit 79bd77e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 17 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ uid: changelog

# Changelog

## [1.4.3] - 2024-10-16

### Fixed
* Entities graphics constantly allocating more memory without releasing it until next time system update is called.


## [1.4.2] - 2024-10-04

### Changed
Expand All @@ -17,7 +23,6 @@ uid: changelog
* Enable entities motion vector pass participation for URP.
* PruneUploadBufferPool API to request pruning of the upload buffer pool.


### Fixed

* GameObjects that depend on vertex shader logic to generate procedural motion vectors through object motion vector passes will now also do the same when baked to Entities and rendered through Entities Graphics.
Expand Down
28 changes: 22 additions & 6 deletions Unity.Entities.Graphics/EntitiesGraphicsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ public unsafe partial class EntitiesGraphicsSystem : SystemBase
const float kMaxBatchGrowFactor = 2f;
const int kNumNewChunksPerThread = 1; // TODO: Tune this
const int kNumScatteredIndicesPerThread = 8; // TODO: Tune this
const int kMaxCullingPassesWithoutAllocatorRewind = 1024;

const int kMaxChunkMetadata = 1 * 1024 * 1024;
const ulong kMaxGPUAllocatorMemory = 1024 * 1024 * 1024; // 1GiB of potential memory space
Expand Down Expand Up @@ -783,7 +784,7 @@ public unsafe partial class EntitiesGraphicsSystem : SystemBase
#if UNITY_EDITOR
float m_CamMoveDistance;
#endif

int m_NumberOfCullingPassesAccumulatedWithoutAllocatorRewind;
#if UNITY_EDITOR
private EntitiesGraphicsPerThreadStats* m_PerThreadStats = null;
private EntitiesGraphicsStats m_Stats;
Expand Down Expand Up @@ -1067,6 +1068,8 @@ protected override void OnCreate()

m_ThreadLocalAllocators = new ThreadLocalAllocator(-1);

m_NumberOfCullingPassesAccumulatedWithoutAllocatorRewind = 0;

if (ErrorShaderEnabled)
{
m_ErrorMaterial = EntitiesGraphicsUtils.LoadErrorMaterial();
Expand Down Expand Up @@ -1285,11 +1288,7 @@ protected override void OnUpdate()

// Make sure any release jobs that have stored pointers in temp allocated
// memory have finished before we rewind
m_CullingJobReleaseDependency.Complete();
m_CullingJobReleaseDependency = default;
m_ReleaseDependency.Complete();
m_ReleaseDependency = default;
m_ThreadLocalAllocators.Rewind();
RewindThreadLocalAllocator();

m_LastSystemVersionAtLastUpdate = LastSystemVersion;

Expand Down Expand Up @@ -1428,6 +1427,16 @@ private void ResetLod()
m_ResetLod = true;
}

private void RewindThreadLocalAllocator()
{
m_CullingJobReleaseDependency.Complete();
m_CullingJobReleaseDependency = default;
m_ReleaseDependency.Complete();
m_ReleaseDependency = default;
m_ThreadLocalAllocators.Rewind();
m_NumberOfCullingPassesAccumulatedWithoutAllocatorRewind = 0;
}

// This function does only return a meaningful IncludeExcludeListFilter object when called from a BRG culling callback.
static IncludeExcludeListFilter GetPickingIncludeExcludeListFilterForCurrentCullingCallback(EntityManager entityManager, in BatchCullingContext cullingContext)
{
Expand Down Expand Up @@ -1494,6 +1503,13 @@ private JobHandle OnPerformCulling(BatchRendererGroup rendererGroup, BatchCullin
return m_CullingJobDependency;
}

//if we have accumulated too many culling passes without rewinding the allocator in system update, force the rewind here. Otherwise when system update doesn't tick but culling does, we might run out of memory
if (m_NumberOfCullingPassesAccumulatedWithoutAllocatorRewind == kMaxCullingPassesWithoutAllocatorRewind)
{
RewindThreadLocalAllocator();
}
++m_NumberOfCullingPassesAccumulatedWithoutAllocatorRewind;

var lodParams = LODGroupExtensions.CalculateLODParams(cullingContext.lodParameters);

JobHandle cullingDependency;
Expand Down
17 changes: 11 additions & 6 deletions ValidationExceptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,34 @@
{
"ValidationTest": "API Updater Configuration Validation",
"ExceptionMessage": "stdout:\nAPIUpdater Configuration Validation\n-----------------------------------\n\nConfiguration Validation Tests (Failed: 0, Total: 1, Ignored 0):\n----------------------------------------------------------------\n\n\nAuto Generated Tests (Failed: 1, Total: 1, Ignored 0):\n------------------------------------------------------\n1) Expected updates not applied for configuration:\n[*] System.SByte [*] Unity.Rendering.MaterialMeshInfo::Submesh -> * Unity.Rendering.MaterialMeshInfo::SubMesh\n\nInput : unsafe class Test : object { System.SByte Method(System.SByte memberValue, Unity.Rendering.MaterialMeshInfo obj) { System.SByte local = obj.Submesh; return Method(obj.Submesh, obj); } }\nExpected: unsafe class Test : object { System.UInt16 Method(System.UInt16 memberValue, Unity.Rendering.MaterialMeshInfo obj) { System.UInt16 local = obj.SubMesh; return Method(obj.SubMesh, obj); } }\nActual : unsafe class Test : object { System.SByte Method(System.SByte memberValue, Unity.Rendering.MaterialMeshInfo obj) { System.SByte local = obj.SubMesh; return Method(obj.SubMesh, obj); } }\n\n\nBase type validation (Failed: 0, Total: 0, Ignored 0):\n------------------------------------------------------\nstderr:\n",
"PackageVersion": "1.4.2"
"PackageVersion": "1.4.3"
},
{
"ValidationTest": "API Validation",
"ExceptionMessage": "Breaking changes require a new major version.",
"PackageVersion": "1.4.2"
}
"PackageVersion": "1.4.3"
},
{
"ValidationTest": "API Validation",
"ExceptionMessage": "Additions require a new minor or major version.",
"PackageVersion": "1.4.3"
}
],
"WarningExceptions": [
{
"ValidationTest": "Manifest Validation",
"ExceptionMessage": "Package dependency [email protected] must be promoted to production before this package is promoted to production. (Except for core packages)",
"PackageVersion": "1.4.2"
"PackageVersion": "1.4.3"
},
{
"ValidationTest": "Folder Structure Validation",
"ExceptionMessage": "The Resources Directory should not be used in packages. For more guidance, please visit https://docs.unity3d.com/Manual/BestPracticeUnderstandingPerformanceInUnity6.html",
"PackageVersion": "1.4.2"
"PackageVersion": "1.4.3"
},
{
"ValidationTest": "Package Lifecycle Validation",
"ExceptionMessage": "com.unity.entities.graphics has never been promoted to production before. Please contact Release Management through slack in #devs-pkg-promotion to promote the first version of your package before trying to use this automated pipeline. Read more about this error and potential solutions at https://docs.unity3d.com/Packages/com.unity.package-validation-suite@latest/index.html?preview=1&subfolder=/manual/lifecycle_validation_error.html#the-very-first-version-of-a-package-must-be-promoted-by-release-management",
"PackageVersion": "1.4.2"
"PackageVersion": "1.4.3"
}
]
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.unity.entities.graphics",
"displayName": "Entities Graphics",
"version": "1.4.2",
"version": "1.4.3",
"unity": "2022.3",
"unityRelease": "11f1",
"description": "The Entities Graphics package provides systems and components for drawing meshes using DOTS, including support for instanced mesh rendering and LOD.",
Expand All @@ -17,15 +17,15 @@
"unity"
],
"_upm": {
"changelog": "### Changed\n\n* Updated Burst dependency to version 1.8.18\n* Updated entities packages dependencies\n\n### Added\n\n* The new `ProceduralMotion_Tag` tag component data type informs Entities Graphics that an Entity needs to participate in the object motion vector pass. The tag is automatically added for entities that go through the builtin MeshRendererBaker path.\n* Enable entities motion vector pass participation for URP.\n* PruneUploadBufferPool API to request pruning of the upload buffer pool.\n\n\n### Fixed\n\n* GameObjects that depend on vertex shader logic to generate procedural motion vectors through object motion vector passes will now also do the same when baked to Entities and rendered through Entities Graphics."
"changelog": "### Fixed\n* Entities graphics constantly allocating more memory without releasing it until next time system update is called."
},
"upmCi": {
"footprint": "0272692301aadf6ab8f8a54a59dd19a7ea2445c3"
"footprint": "6a13371f12053bdd67b593a0076cbd3c777a3351"
},
"documentationUrl": "https://docs.unity3d.com/Packages/[email protected]/manual/index.html",
"repository": {
"url": "https://github.cds.internal.unity3d.com/unity/dots.git",
"type": "git",
"revision": "f9f023a1661a1a7a17264c9907b75c9b46434416"
"revision": "97e332ca8068d973f6571bcb144c924ebd679c79"
}
}

0 comments on commit 79bd77e

Please sign in to comment.