Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.2.1] - 2024-04-26

### Added

* MaterialReferences and MesheReferences have been provided as non allocating replacements for Materials and Meshes

### Changed
* Updated entities packages dependencies

### Deprecated

* RenderMeshArray.Materials is now obsolete, in favor of RenderMeshArray.MaterialReferences
* RenderMeshArray.Meshes is now obsolete, in favor of RenderMeshArray.MeshReferences
* Deprecated Materials and Meshes from RenderMeshArray as they now allocate.

### Removed

### Fixed

* Resolved a performance issue in UpdateHybridChunksStructure
* Fixed an allocation in RegisterMaterialsAndMeshes

### Security

### Known Issues
  • Loading branch information
Unity Technologies committed Apr 26, 2024
1 parent 9a14fc4 commit 9ab5ade
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 38 deletions.
35 changes: 34 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,43 @@ uid: changelog

# Changelog

## [1.2.1] - 2024-04-26

### Added

* MaterialReferences and MesheReferences have been provided as non allocating replacements for Materials and Meshes

### Changed
* Updated entities packages dependencies


### Deprecated

* RenderMeshArray.Materials is now obsolete, in favor of RenderMeshArray.MaterialReferences
* RenderMeshArray.Meshes is now obsolete, in favor of RenderMeshArray.MeshReferences
* Deprecated Materials and Meshes from RenderMeshArray as they now allocate.

### Removed


### Fixed

* Resolved a performance issue in UpdateHybridChunksStructure
* Fixed an allocation in RegisterMaterialsAndMeshes

### Security


### Known Issues




## [1.2.0] - 2024-03-22

### Changed

* fixed the issue with LOD objects being culled when the camera is static
* Fixed the issue with LOD objects being culled when the camera is static

### Fixed

Expand All @@ -18,6 +50,7 @@ uid: changelog

## [1.2.0-pre.12] - 2024-02-13


### Added

* `RenderMeshUnmanaged` an unmanaged IComponentData using the new UnityObjRef<T> for big performance gains in baking!
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
com.unity.entities.graphics copyright © 2024 Unity Technologies ApS
com.unity.entities.graphics copyright © 2023 Unity Technologies ApS

Licensed under the Unity Companion License for Unity-dependent projects (see https://unity3d.com/legal/licenses/unity_companion_license).

Expand Down
16 changes: 8 additions & 8 deletions Unity.Entities.Graphics/EntitiesGraphicsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ private void GetFilteredRenderMeshArrays(out List<RenderMeshArray> renderArrays,
for (int i = renderArrays.Count - 1; i >= 0; --i)
{
var array = renderArrays[i];
if (array.Materials == null || array.Meshes == null)
if (array.MaterialReferences == null || array.MeshReferences == null)
{
discardedIndices.Add(i);
}
Expand Down Expand Up @@ -488,16 +488,16 @@ private JobHandle RegisterMaterialsAndMeshes(JobHandle inputDeps)
for (int ri = 0; ri < renderArrays.Count; ++ri)
{
var renderArray = renderArrays[ri];
if (renderArray.Materials == null || renderArray.Meshes == null)
if (renderArray.MaterialReferences == null || renderArray.MeshReferences == null)
{
Debug.LogError("This loop should not process null RenderMeshArray components");
continue;
}

var sharedIndex = sharedIndices[ri];
var sharedVersion = sharedVersions[ri];
var materialCount = renderArray.Materials.Length;
var meshCount = renderArray.Meshes.Length;
var materialCount = renderArray.MaterialReferences.Length;
var meshCount = renderArray.MeshReferences.Length;
var matMeshIndexCount = renderArray.MaterialMeshIndices != null ? renderArray.MaterialMeshIndices.Length : 0;
uint4 hash128 = renderArray.GetHash128();

Expand Down Expand Up @@ -538,7 +538,7 @@ private JobHandle RegisterMaterialsAndMeshes(JobHandle inputDeps)

for (int i = 0; i < materialCount; ++i)
{
var material = renderArray.MaterialsInternal[i];
var material = renderArray.MaterialReferences[i];
var id = m_RendererSystem.RegisterMaterial(material);
if (id == BatchMaterialID.Null)
{
Expand All @@ -550,7 +550,7 @@ private JobHandle RegisterMaterialsAndMeshes(JobHandle inputDeps)

for (int i = 0; i < meshCount; ++i)
{
var mesh = renderArray.MeshesInternal[i];
var mesh = renderArray.MeshReferences[i];
var id = m_RendererSystem.RegisterMesh(mesh);
if (id == BatchMeshID.Null)
Debug.LogWarning($"Registering mesh {(mesh ? mesh.Value.ToString() : "null")} at index {i} inside a RenderMeshArray failed.");
Expand Down Expand Up @@ -633,8 +633,8 @@ internal void LogBoundsCheckErrorMessages()
? e.ToString()
: authoring.ToString();

int numMeshes = rma.Meshes?.Length ?? 0;
int numMaterials = rma.Materials?.Length ?? 0;
int numMeshes = rma.MeshReferences?.Length ?? 0;
int numMaterials = rma.MaterialReferences?.Length ?? 0;
int numMatMeshIndex = rma.MaterialMeshIndices?.Length ?? 0;

if (mmi.HasMaterialMeshIndexRange)
Expand Down
36 changes: 22 additions & 14 deletions Unity.Entities.Graphics/RenderMeshArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,10 @@ public RenderMeshArray(ReadOnlySpan<UnityObjectRef<Material>> materials, ReadOnl
ResetHash128();
}

internal UnityObjectRef<Mesh>[] MeshesInternal
/// <summary>
/// Accessor property for the mesh references array.
/// </summary>
public UnityObjectRef<Mesh>[] MeshReferences
{
get => m_Meshes;
set
Expand All @@ -336,7 +339,10 @@ internal UnityObjectRef<Mesh>[] MeshesInternal
}
}

internal UnityObjectRef<Material>[] MaterialsInternal
/// <summary>
/// Accessor property for the material references array.
/// </summary>
public UnityObjectRef<Material>[] MaterialReferences
{
get => m_Materials;
set
Expand All @@ -362,6 +368,7 @@ public MaterialMeshIndex[] MaterialMeshIndices
/// <summary>
/// Accessor property for the meshes array.
/// </summary>
[Obsolete("Meshes has been deprecated; use MeshReferences instead.", false)]
public Mesh[] Meshes
{
get
Expand Down Expand Up @@ -390,6 +397,7 @@ public Mesh[] Meshes
/// <summary>
/// Accessor property for the materials array.
/// </summary>
[Obsolete("Materials has been deprecated; use MaterialReferences instead.", false)]
public Material[] Materials
{
get
Expand Down Expand Up @@ -560,24 +568,24 @@ public static RenderMeshArray CombineRenderMeshArrays(List<RenderMeshArray> rend

foreach (var rma in renderMeshArrays)
{
totalMeshes += rma.Meshes?.Length ?? 0;
totalMaterials += rma.Meshes?.Length ?? 0;
totalMeshes += rma.MeshReferences?.Length ?? 0;
totalMaterials += rma.MeshReferences?.Length ?? 0;
}

var meshes = new Dictionary<UnityObjectRef<Mesh>, bool>(totalMeshes);
var materials = new Dictionary<UnityObjectRef<Material>, bool>(totalMaterials);

foreach (var rma in renderMeshArrays)
{
foreach (var mesh in rma.Meshes)
foreach (var mesh in rma.MeshReferences)
{
if (mesh != null)
if (mesh.IsValid())
meshes[mesh] = true;
}

foreach (var material in rma.Materials)
foreach (var material in rma.MaterialReferences)
{
if (material != null)
if (material.IsValid())
materials[material] = true;
}
}
Expand Down Expand Up @@ -644,11 +652,11 @@ public Material GetMaterial(MaterialMeshInfo materialMeshInfo)
Assert.IsTrue(range.length > 0);

int firstMaterialIndex = MaterialMeshIndices[range.start].MaterialIndex;
return Materials[firstMaterialIndex];
return MaterialReferences[firstMaterialIndex];
}
else
{
return Materials[materialMeshInfo.MaterialArrayIndex];
return MaterialReferences[materialMeshInfo.MaterialArrayIndex];
}
}

Expand All @@ -672,14 +680,14 @@ public List<Material> GetMaterials(MaterialMeshInfo materialMeshInfo)
for (int i = range.start; i < range.end; i++)
{
int materialIndex = MaterialMeshIndices[i].MaterialIndex;
materials.Add(Materials[materialIndex]);
materials.Add(MaterialReferences[materialIndex]);
}

return materials;
}
else
{
var material = Materials[materialMeshInfo.MaterialArrayIndex];
var material = MaterialReferences[materialMeshInfo.MaterialArrayIndex];
return new List<Material> { material };
}
}
Expand All @@ -701,11 +709,11 @@ public Mesh GetMesh(MaterialMeshInfo materialMeshInfo)
Assert.IsTrue(range.length > 0);

int firstMeshIndex = MaterialMeshIndices[range.start].MeshIndex;
return Meshes[firstMeshIndex];
return MeshReferences[firstMeshIndex];
}
else
{
return Meshes[materialMeshInfo.MeshArrayIndex];
return MeshReferences[materialMeshInfo.MeshArrayIndex];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ protected override void OnCreate()
{
All = new[]
{
ComponentType.ChunkComponentReadOnly<EntitiesGraphicsChunkInfo>(),
ComponentType.ReadOnly<DisableRendering>(),
},
});
Expand Down
18 changes: 9 additions & 9 deletions ValidationExceptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
{
"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.2.0"
"PackageVersion": "1.2.1"
},
{
"ValidationTest": "API Validation",
"ExceptionMessage": "Breaking changes require a new major version.",
"PackageVersion": "1.2.0"
}
{
"ValidationTest": "API Validation",
"ExceptionMessage": "Additions require a new minor or major version.",
"PackageVersion": "1.2.1"
}
],
"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.2.0"
"PackageVersion": "1.2.1"
},
{
"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.2.0"
"PackageVersion": "1.2.1"
},
{
"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.2.0"
"PackageVersion": "1.2.1"
}
]
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "com.unity.entities.graphics",
"displayName": "Entities Graphics",
"version": "1.2.0",
"version": "1.2.1",
"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.",
"dependencies": {
"com.unity.entities": "1.2.0",
"com.unity.entities": "1.2.1",
"com.unity.modules.particlesystem": "1.0.0",
"com.unity.render-pipelines.core": "14.0.9"
},
Expand All @@ -17,15 +17,15 @@
"unity"
],
"_upm": {
"changelog": "### Changed\n\n* fixed the issue with LOD objects being culled when the camera is static\n\n### Fixed\n\n* Entities Graphics should now never run out of space in the NewChunks buffer.\n* A null reference exception thrown in some cases when using MeshRenderers with missing materials and/or meshes"
"changelog": "### Added\n\n* MaterialReferences and MesheReferences have been provided as non allocating replacements for Materials and Meshes\n\n### Changed\n* Updated entities packages dependencies\n\n\n### Deprecated\n\n* RenderMeshArray.Materials is now obsolete, in favor of RenderMeshArray.MaterialReferences\n* RenderMeshArray.Meshes is now obsolete, in favor of RenderMeshArray.MeshReferences\n* Deprecated Materials and Meshes from RenderMeshArray as they now allocate.\n\n### Removed\n\n\n### Fixed\n\n* Resolved a performance issue in UpdateHybridChunksStructure\n* Fixed an allocation in RegisterMaterialsAndMeshes\n\n### Security\n\n\n### Known Issues"
},
"upmCi": {
"footprint": "8c29b61b26490f1fa6cbfbe876e7bbde992f6711"
"footprint": "a82699c29cedddf992dcce1d6ae9e2c429483285"
},
"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": "ea4236421d61011e37e71d22108c5e4e70cf71d7"
"revision": "6ecf7a215623cca37079c6f1a3e6f2f686c91721"
}
}

0 comments on commit 9ab5ade

Please sign in to comment.