Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public Analytic(Volume volume, VolumeProfile volumeProfile)
{
data.volume_name = Hash128.Compute(volume.name).ToString();
data.scene_name = EditorSceneManager.GetActiveScene().GetGUID();
data.volume_profile_asset_guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(volumeProfile.GetInstanceID()));
data.volume_profile_asset_guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(volumeProfile.GetEntityId()));
m_Data = data;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class CoreBuildData : IDisposable
/// </summary>
public List<RenderPipelineAsset> renderPipelineAssets { get; private set; } = new();

internal Dictionary<int, ComputeShader> computeShaderCache { get; private set; } = new();
internal Dictionary<EntityId, ComputeShader> computeShaderCache { get; private set; } = new();

internal bool pipelineSupportGPUResidentDrawer { get; private set; } = false;
internal bool playerNeedGPUResidentDrawer { get; private set; } = false;
Expand Down Expand Up @@ -81,7 +81,7 @@ private void CheckGPUResidentDrawerUsage()
return;

GraphicsSettings.GetRenderPipelineSettings<GPUResidentDrawerResources>()
.ForEachFieldOfType<ComputeShader>(computeShader => computeShaderCache.Add(computeShader.GetInstanceID(), computeShader));
.ForEachFieldOfType<ComputeShader>(computeShader => computeShaderCache.Add(computeShader.GetEntityId(), computeShader));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class SRPDisabledComputeShaderVariantStripper : IComputeShaderVariantStripper
public bool active => !CoreBuildData.instance.buildingPlayerForRenderPipeline;

public bool CanRemoveVariant([DisallowNull] ComputeShader shader, string _, ShaderCompilerData __)
=> CoreBuildData.instance.computeShaderCache.ContainsKey(shader.GetInstanceID());
=> CoreBuildData.instance.computeShaderCache.ContainsKey(shader.GetEntityId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ public void BindSamplingTextures(CommandBuffer cmd)
m_SamplingResources.Load();
}

SamplingResources.BindSobolBlueNoiseTextures(cmd, m_SamplingResources);
SamplingResources.Bind(cmd, m_SamplingResources);
}

public bool TryGetMeshForAccelerationStructure(Renderer renderer, out Mesh mesh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,16 @@ static AccelStructAdapter BuildAccelerationStructure()
Array.Fill(matIndices, renderer.component.renderingLayerMask); // repurpose the material id as we don't need it here
var perSubMeshMask = new uint[subMeshCount];
Array.Fill(perSubMeshMask, GetInstanceMask(renderer.component.shadowCastingMode));
accelStruct.AddInstance(renderer.component.GetInstanceID(), renderer.component, perSubMeshMask, matIndices, 1);
Span<bool> perSubMeshOpaqueness = stackalloc bool[subMeshCount];
perSubMeshOpaqueness.Fill(true);
accelStruct.AddInstance(EntityId.ToULong(renderer.component.GetEntityId()), renderer.component, perSubMeshMask, matIndices, perSubMeshOpaqueness, 1);
}

foreach (var terrain in contributors.terrains)
{
uint mask = GetInstanceMask(terrain.component.shadowCastingMode);
uint materialID = terrain.component.renderingLayerMask; // repurpose the material id as we don't need it here
accelStruct.AddInstance(terrain.component.GetInstanceID(), terrain.component, new uint[1] { mask }, new uint[1] { materialID }, 1);
accelStruct.AddInstance(EntityId.ToULong(terrain.component.GetEntityId()), terrain.component, new uint[1] { mask }, new uint[1] { materialID }, new bool[1] { true }, 1);
}

return accelStruct;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,16 @@ static AccelStructAdapter BuildAccelerationStructure()
var matIndices = GetMaterialIndices(renderer.component);
var perSubMeshMask = new uint[subMeshCount];
Array.Fill(perSubMeshMask, GetInstanceMask(renderer.component.shadowCastingMode));
Span<bool> perSubMeshOpaqueness = stackalloc bool[subMeshCount];
perSubMeshOpaqueness.Fill(true);

accelStruct.AddInstance(renderer.component.GetInstanceID(), renderer.component, perSubMeshMask, matIndices, 1);
accelStruct.AddInstance(EntityId.ToULong(renderer.component.GetEntityId()), renderer.component, perSubMeshMask, matIndices, perSubMeshOpaqueness, 1);
}

foreach (var terrain in contributors.terrains)
{
uint mask = GetInstanceMask(terrain.component.shadowCastingMode);
accelStruct.AddInstance(terrain.component.GetInstanceID(), terrain.component, new uint[1] { mask }, new uint[1] { 0 }, 1);
accelStruct.AddInstance(EntityId.ToULong(terrain.component.GetEntityId()), terrain.component, new uint[1] { mask }, new uint[1] { 0 }, new bool[1] { true }, 1);
}

return accelStruct;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ static AccelStructAdapter BuildAccelerationStructure(int mask)
var maskAndMatDummy = new uint[subMeshCount];
System.Array.Fill(maskAndMatDummy, 0xFFFFFFFF);

accelStruct.AddInstance(renderer.component.GetInstanceID(), renderer.component, maskAndMatDummy, maskAndMatDummy, 1);
Span<bool> perSubMeshOpaqueness = stackalloc bool[subMeshCount];
perSubMeshOpaqueness.Fill(true);
accelStruct.AddInstance(EntityId.ToULong(renderer.component.GetEntityId()), renderer.component, maskAndMatDummy, maskAndMatDummy, perSubMeshOpaqueness, 1);
}

foreach (var terrain in contributors.terrains)
Expand All @@ -153,7 +155,7 @@ static AccelStructAdapter BuildAccelerationStructure(int mask)
if ((layerMask & mask) == 0)
continue;

accelStruct.AddInstance(terrain.component.GetInstanceID(), terrain.component, new uint[1] { 0xFFFFFFFF }, new uint[1] { 0xFFFFFFFF }, 1);
accelStruct.AddInstance(EntityId.ToULong(terrain.component.GetEntityId()), terrain.component, new uint[1] { 0xFFFFFFFF }, new uint[1] { 0xFFFFFFFF }, new bool[1] { true }, 1);
}

return accelStruct;
Expand Down Expand Up @@ -464,7 +466,7 @@ static uint[] GetMaterialIndices(Renderer renderer)
for (int i = 0; i < matIndices.Length; ++i)
{
if (i < renderer.sharedMaterials.Length && renderer.sharedMaterials[i] != null)
matIndices[i] = (uint)renderer.sharedMaterials[i].GetInstanceID();
matIndices[i] = (uint)renderer.sharedMaterials[i].GetEntityId().GetRawData();
else
matIndices[i] = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
using UnityEngine.Serialization;

namespace UnityEditor.Rendering.LookDev
{
Expand Down Expand Up @@ -334,16 +335,17 @@ public class ViewContext
// Careful here: we want to keep it while reloading script.
// But from one unity editor to an other, ID are not kept.
// So, only use it when reloading from script update.
[FormerlySerializedAs("viewedObjecHierarchytInstanceID")]
[SerializeField]
int viewedObjecHierarchytInstanceID;
EntityId viewedObjecHierarchytEntityId;

/// <summary>
/// Check if an Environment is registered for this view.
/// The result will be accurate even if the object have not been reloaded yet.
/// </summary>
public bool hasViewedObject =>
!String.IsNullOrEmpty(viewedObjectAssetGUID)
|| viewedObjecHierarchytInstanceID != 0;
|| viewedObjecHierarchytEntityId != EntityId.None;

/// <summary>Reference to the object given for instantiation.</summary>
public GameObject viewedObjectReference { get; private set; }
Expand Down Expand Up @@ -426,14 +428,14 @@ void LoadEnvironmentFromGUID()
public void UpdateViewedObject(GameObject viewedObject)
{
viewedObjectAssetGUID = "";
viewedObjecHierarchytInstanceID = 0;
viewedObjecHierarchytEntityId = EntityId.None;
viewedObjectReference = null;
if (viewedObject == null || viewedObject.Equals(null))
return;

bool fromHierarchy = viewedObject.scene.IsValid();
if (fromHierarchy)
viewedObjecHierarchytInstanceID = viewedObject.GetInstanceID();
viewedObjecHierarchytEntityId = viewedObject.GetEntityId();
else
viewedObjectAssetGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(viewedObject));
viewedObjectReference = viewedObject;
Expand All @@ -451,9 +453,9 @@ void LoadViewedObject()
string path = AssetDatabase.GUIDToAssetPath(viewedObjectAssetGUID);
viewedObjectReference = AssetDatabase.LoadAssetAtPath<GameObject>(path);
}
else if (viewedObjecHierarchytInstanceID != 0)
else if (viewedObjecHierarchytEntityId != EntityId.None)
{
viewedObjectReference = EditorUtility.InstanceIDToObject(viewedObjecHierarchytInstanceID) as GameObject;
viewedObjectReference = EditorUtility.EntityIdToObject(viewedObjecHierarchytEntityId) as GameObject;
}
}

Expand All @@ -466,7 +468,7 @@ internal void LoadAll(bool reloadWithTemporaryID)
}

internal void CleanTemporaryObjectIndexes()
=> viewedObjecHierarchytInstanceID = 0;
=> viewedObjecHierarchytEntityId = EntityId.None;

/// <summary>Reset the camera state to default values</summary>
public void ResetCameraState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,17 @@ void Update()
public sealed override void OnInspectorGUI() { }
}

class EnvironmentLibraryCreator : ProjectWindowCallback.EndNameEditAction
class EnvironmentLibraryCreator : ProjectWindowCallback.AssetCreationEndAction
{
ObjectField m_Field = null;

public void SetField(ObjectField field)
=> m_Field = field;

public override void Cancelled(int instanceId, string pathName, string resourceFile)
public override void Cancelled(EntityId entityId, string pathName, string resourceFile)
=> m_Field = null;

public override void Action(int instanceId, string pathName, string resourceFile)
public override void Action(EntityId entityId, string pathName, string resourceFile)
{
var newAsset = CreateInstance<EnvironmentLibrary>();
newAsset.name = Path.GetFileName(pathName);
Expand All @@ -183,15 +183,15 @@ public override void Action(int instanceId, string pathName, string resourceFile
static void Create()
{
var icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance<EnvironmentLibraryCreator>(), "New EnvironmentLibrary.asset", icon, null);
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(EntityId.None, ScriptableObject.CreateInstance<EnvironmentLibraryCreator>(), "New EnvironmentLibrary.asset", icon, null);
}

public static void CreateAndAssignTo(ObjectField field)
{
var icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");
var assetCreator = ScriptableObject.CreateInstance<EnvironmentLibraryCreator>();
assetCreator.SetField(field);
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(assetCreator.GetInstanceID(), assetCreator, "New EnvironmentLibrary.asset", icon, null);
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(assetCreator.GetEntityId(), assetCreator, "New EnvironmentLibrary.asset", icon, null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ internal static class Icons
}

#region Asset Factory
class LensFlareDataSRPCreator : UnityEditor.ProjectWindowCallback.EndNameEditAction
class LensFlareDataSRPCreator : UnityEditor.ProjectWindowCallback.AssetCreationEndAction
{
public override void Action(int instanceId, string pathName, string resourceFile)
public override void Action(EntityId entityId, string pathName, string resourceFile)
{
LensFlareDataSRP asset = ScriptableObject.CreateInstance<LensFlareDataSRP>();
UnityEngine.Assertions.Assert.IsNotNull(asset, $"failed to create instance of {nameof(LensFlareDataSRP)}");
Expand All @@ -35,7 +35,7 @@ public override void Action(int instanceId, string pathName, string resourceFile
internal static void CreateLensFlareDataSRPAsset()
{
const string relativePath = "New Lens Flare (SRP).asset";
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance<LensFlareDataSRPCreator>(), relativePath, Icons.generic, null);
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(EntityId.None, ScriptableObject.CreateInstance<LensFlareDataSRPCreator>(), relativePath, Icons.generic, null);
}

internal static LensFlareDataSRP CreateLensFlareDataSRPAsset(Scene scene, string targetName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ namespace UnityEditor.Rendering
/// <summary>
/// <see cref="ProjectWindowCallback.EndNameEditAction"/> for <see cref="RenderPipelineGlobalSettings"/>
/// </summary>
public class RenderPipelineGlobalSettingsEndNameEditAction : ProjectWindowCallback.EndNameEditAction
[Obsolete("RenderPipelineGlobalSettingsEndNameEditAction is no longer used and will be removed in a future release.")]
public class RenderPipelineGlobalSettingsEndNameEditAction : ProjectWindowCallback.AssetCreationEndAction
{
private Type renderPipelineType { get; set; }
private Type renderPipelineGlobalSettingsType { get; set; }
private RenderPipelineGlobalSettings source { get; set; }

/// <inheritdoc/>
public override void Action(int instanceId, string pathName, string resourceFile)
public override void Action(EntityId instanceId, string pathName, string resourceFile)
{
RenderPipelineGlobalSettings assetCreated = RenderPipelineGlobalSettingsUtils.Create(renderPipelineGlobalSettingsType, pathName, source) as RenderPipelineGlobalSettings;

Expand Down Expand Up @@ -44,7 +45,7 @@ internal static RenderPipelineGlobalSettingsEndNameEditAction CreateEndNameEditA
internal static void StartEndNameEditAction(RenderPipelineGlobalSettingsEndNameEditAction action, string pathName)
{
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(
action.GetInstanceID(),
action.GetEntityId(),
action,
pathName,
CoreEditorStyles.globalSettingsIcon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class VolumeProfileFactory
static void CreateVolumeProfile()
{
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(
0,
EntityId.None,
ScriptableObject.CreateInstance<CreateVolumeProfileAction>(),
"New Volume Profile.asset",
null,
Expand All @@ -37,7 +37,7 @@ public static void CreateVolumeProfileWithCallback(string fullPath, Action<Volum
CoreUtils.EnsureFolderTreeInAssetFilePath(fullPath);

ProjectWindowUtil.StartNameEditingIfProjectWindowExists(
assetCreator.GetInstanceID(),
assetCreator.GetEntityId(),
assetCreator,
fullPath,
null,
Expand Down Expand Up @@ -118,18 +118,18 @@ public static T CreateVolumeComponent<T>(VolumeProfile profile, bool overrides =
}
}

class CreateVolumeProfileAction : EndNameEditAction
class CreateVolumeProfileAction : AssetCreationEndAction
{
public override void Action(int instanceId, string pathName, string resourceFile)
public override void Action(EntityId entityId, string pathName, string resourceFile)
{
var profile = VolumeProfileFactory.CreateVolumeProfileAtPath(pathName);
ProjectWindowUtil.ShowCreatedAsset(profile);
}
}

class CreateVolumeProfileWithCallbackAction : EndNameEditAction
class CreateVolumeProfileWithCallbackAction : AssetCreationEndAction
{
public override void Action(int instanceId, string pathName, string resourceFile)
public override void Action(EntityId entityId, string pathName, string resourceFile)
{
var profile = VolumeProfileFactory.CreateVolumeProfileAtPath(pathName);
ProjectWindowUtil.ShowCreatedAsset(profile);
Expand Down
Loading