Skip to content

Commit a33bf32

Browse files
Merge pull request #8290 from Unity-Technologies/internal/6000.4/staging
Mirror Internal/6000.4/staging
2 parents cd07e25 + 5c632f3 commit a33bf32

73 files changed

Lines changed: 10981 additions & 200 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Packages/com.unity.render-pipelines.core/Runtime/Utilities/CoreUtils.cs

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,32 +1838,48 @@ public static IEnumerable<T> LoadAllAssets<T>(string extension = "asset", bool a
18381838
}
18391839
}
18401840

1841+
const char k_DirectorySeparatorChar = '/';
1842+
18411843
/// <summary>
18421844
/// Create any missing folders in the file path given.
18431845
/// </summary>
1844-
/// <param name="filePath">File or folder (ending with '/') path to ensure existence of each subfolder in. </param>
1846+
/// <param name="filePath">File or folder (ending with '/') path to ensure existence of each subfolder in.</param>
18451847
public static void EnsureFolderTreeInAssetFilePath(string filePath)
18461848
{
1847-
var path = filePath.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar);
1848-
if (!path.StartsWith("Assets" + Path.DirectorySeparatorChar, StringComparison.CurrentCultureIgnoreCase))
1849-
throw new ArgumentException($"Path should start with \"Assets/\". Got {filePath}.", filePath);
1849+
if (string.IsNullOrEmpty(filePath))
1850+
return;
1851+
1852+
// Normalize to forward slashes (Unity standard)
1853+
var path = filePath.Replace('\\', k_DirectorySeparatorChar);
1854+
1855+
if (!path.StartsWith("Assets/", StringComparison.Ordinal))
1856+
throw new ArgumentException($"Path should start with \"Assets/\". Got {filePath}.", nameof(filePath));
18501857

18511858
var folderPath = Path.GetDirectoryName(path);
18521859

1853-
if (!UnityEditor.AssetDatabase.IsValidFolder(folderPath))
1860+
if (string.IsNullOrEmpty(folderPath))
1861+
return;
1862+
1863+
// GetDirectoryName may reintroduce backslashes on Windows
1864+
folderPath = folderPath.Replace('\\', k_DirectorySeparatorChar);
1865+
1866+
// Early exit if folder already exists
1867+
if (AssetDatabase.IsValidFolder(folderPath))
1868+
return;
1869+
1870+
var folderNames = folderPath.Split(k_DirectorySeparatorChar);
1871+
string currentPath = "Assets";
1872+
1873+
for (int i = 1; i < folderNames.Length; ++i)
18541874
{
1855-
var folderNames = folderPath.Split(Path.DirectorySeparatorChar);
1856-
string rootPath = "";
1857-
foreach (var folderName in folderNames)
1858-
{
1859-
var newPath = rootPath + folderName;
1860-
if (!UnityEditor.AssetDatabase.IsValidFolder(newPath))
1861-
UnityEditor.AssetDatabase.CreateFolder(rootPath.TrimEnd(Path.DirectorySeparatorChar), folderName);
1862-
rootPath = newPath + Path.DirectorySeparatorChar;
1863-
}
1875+
string nextPath = currentPath + k_DirectorySeparatorChar + folderNames[i];
1876+
if (!UnityEditor.AssetDatabase.IsValidFolder(nextPath))
1877+
UnityEditor.AssetDatabase.CreateFolder(currentPath, folderNames[i]);
1878+
currentPath = nextPath;
18641879
}
18651880
}
18661881

1882+
18671883
/// <summary>
18681884
/// Returns the icon for the given type if it has an IconAttribute.
18691885
/// </summary>

Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -328,25 +328,6 @@ internal void SetOverridesTo(IEnumerable<VolumeParameter> enumerable, bool state
328328
}
329329
}
330330

331-
/// <summary>
332-
/// A custom hashing function that Unity uses to compare the state of parameters.
333-
/// </summary>
334-
/// <returns>A computed hash code for the current instance.</returns>
335-
public override int GetHashCode()
336-
{
337-
unchecked
338-
{
339-
//return parameters.Aggregate(17, (i, p) => i * 23 + p.GetHash());
340-
341-
int hash = 17;
342-
343-
for (int i = 0; i < parameterList.Length; i++)
344-
hash = hash * 23 + parameterList[i].GetHashCode();
345-
346-
return hash;
347-
}
348-
}
349-
350331
/// <summary>
351332
/// Returns true if any of the volume properites has been overridden.
352333
/// </summary>

Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeManager.cs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,14 @@ public void Initialize(VolumeProfile globalDefaultVolumeProfile = null, VolumePr
260260
void InitializeBaseTypesArray(VolumeProfile globalDefaultVolumeProfile = null)
261261
{
262262
using var profilerScope = k_ProfilerMarkerInitializeBaseTypesArray.Auto();
263-
#if UNITY_EDITOR
264-
LoadBaseTypesByReflection(GraphicsSettings.currentRenderPipelineAssetType);
265-
#else
263+
#if !UNITY_EDITOR
266264
if (globalDefaultVolumeProfile == null)
267265
{
268266
var defaultVolumeProfileSettings = GraphicsSettings.GetRenderPipelineSettings<IDefaultVolumeProfileAsset>();
269267
globalDefaultVolumeProfile = defaultVolumeProfileSettings?.defaultVolumeProfile;
270268
}
271-
LoadBaseTypes(globalDefaultVolumeProfile);
272269
#endif
270+
LoadBaseTypes(GraphicsSettings.currentRenderPipelineAssetType, globalDefaultVolumeProfile);
273271
}
274272

275273
//This is called by test where the basetypes are tuned for the purpose of the test.
@@ -311,7 +309,7 @@ public void Deinitialize()
311309
/// <param name="profile">The VolumeProfile to use as the global default profile.</param>
312310
public void SetGlobalDefaultProfile(VolumeProfile profile)
313311
{
314-
LoadBaseTypes(profile);
312+
LoadBaseTypes(GraphicsSettings.currentRenderPipelineAssetType, profile);
315313
globalDefaultProfile = profile;
316314
EvaluateVolumeDefaultState();
317315
}
@@ -423,8 +421,9 @@ public void DestroyStack(VolumeStack stack)
423421
/// LoadBaseTypes is responsible for loading the list of VolumeComponent types that will be used to build the default state of the VolumeStack. It uses the provided global default profile to determine which component types are relevant for the current render pipeline.
424422
/// This will be called only once at runtime on app boot
425423
/// </summary>
424+
/// <param name="rpType">The Pipeline Type used to check if each VolumeComponent is supported.</param>
426425
/// <param name="globalDefaultVolumeProfile">The global default volume profile to use to build the base component type array.</param>
427-
internal void LoadBaseTypes(VolumeProfile globalDefaultVolumeProfile)
426+
internal void LoadBaseTypesByDefaultVolume(Type rpType, VolumeProfile globalDefaultVolumeProfile)
428427
{
429428
if (globalDefaultVolumeProfile == null)
430429
{
@@ -434,13 +433,13 @@ internal void LoadBaseTypes(VolumeProfile globalDefaultVolumeProfile)
434433

435434
using (ListPool<Type>.Get(out var list))
436435
{
437-
var pipelineAssetType = GraphicsSettings.currentRenderPipelineAssetType;
438436
foreach (var comp in globalDefaultVolumeProfile.components)
439437
{
440-
if (comp == null) continue;
438+
if (comp == null)
439+
continue;
441440

442441
var componentType = comp.GetType();
443-
if (!SupportedOnRenderPipelineAttribute.IsTypeSupportedOnRenderPipeline(componentType, pipelineAssetType))
442+
if (!SupportedOnRenderPipelineAttribute.IsTypeSupportedOnRenderPipeline(componentType, rpType))
444443
continue;
445444

446445
list.Add(componentType);
@@ -469,15 +468,30 @@ internal Type[] LoadBaseTypesByReflection(Type pipelineAssetType)
469468
if (!SupportedOnRenderPipelineAttribute.IsTypeSupportedOnRenderPipeline(t, pipelineAssetType))
470469
continue;
471470

471+
if (t.GetCustomAttribute<ObsoleteAttribute>() != null)
472+
continue;
473+
472474
list.Add(t);
473475
}
474-
475476
m_BaseComponentTypeArray = list.ToArray();
476477
}
477478

478479
return m_BaseComponentTypeArray;
479480
}
480481
#endif
482+
/// <summary>
483+
/// Helper to choose a type loading depending if we are in Editor and Standalone.
484+
/// </summary>
485+
/// <param name="pipelineAssetType">The Pipeline Type used to check if each VolumeComponent is supported.</param>
486+
/// <param name="globalDefaultVolumeProfile">The global default volume profile to use to build the base component type array.</param>
487+
void LoadBaseTypes(Type pipelineAssetType, VolumeProfile globalDefaultVolumeProfile = null)
488+
{
489+
#if UNITY_EDITOR
490+
LoadBaseTypesByReflection(pipelineAssetType);
491+
#else
492+
LoadBaseTypesByDefaultVolume(pipelineAssetType, globalDefaultVolumeProfile);
493+
#endif
494+
}
481495

482496
internal void InitializeVolumeComponents()
483497
{

Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -321,33 +321,16 @@ public bool TryGetAllSubclassOf<T>(Type type, List<T> result)
321321
return count != result.Count;
322322
}
323323

324-
/// <summary>
325-
/// A custom hashing function that Unity uses to compare the state of parameters.
326-
/// </summary>
327-
/// <returns>A computed hash code for the current instance.</returns>
328-
public override int GetHashCode()
329-
{
330-
unchecked
331-
{
332-
int hash = 17;
333-
334-
for (int i = 0; i < components.Count; i++)
335-
hash = hash * 23 + components[i].GetHashCode();
336-
337-
return hash;
338-
}
339-
}
340-
341324
internal int GetComponentListHashCode()
342325
{
343326
unchecked
344327
{
345-
int hash = 17;
328+
var hashCode = HashFNV1A32.Create();
346329

347330
for (int i = 0; i < components.Count; i++)
348-
hash = hash * 23 + components[i].GetType().GetHashCode();
331+
hashCode.Append(components[i].GetType().GetHashCode());
349332

350-
return hash;
333+
return hashCode.value;
351334
}
352335
}
353336

Packages/com.unity.render-pipelines.core/Runtime/Vrs/Vrs.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ class VisualizationPassData
3838
/// <summary>
3939
/// Check if conversion of color texture to shading rate image is supported.
4040
/// Convenience to abstract all capabilities checks.
41+
///
42+
/// The `IsColorMaskTextureConversionSupported` method checks for the following:
43+
///- VRS hardware support through [ShadingRateInfo.supportsPerImageTile](xref:UnityEngine.Rendering.ShadingRateInfo.supportsPerImageTile). The `supportsPerImageTile` property determines whether your GPU can define different quality levels to different tiles.
44+
///- Compute shader support through [SystemInfo.supportsComputeShaders](xref:UnityEngine.Device.SystemInfo.supportsComputeShaders)
45+
///- Proper initialization of VRS utility functions and compute shaders required for converting color textures to shading rate image (SRI). This is automatically handled by the render pipeline. However, for custom implementations, you must call <see cref="InitializeResources"/> manually.
4146
/// </summary>
4247
/// <returns>Returns true if conversion of color texture to shading rate image is supported, false otherwise.</returns>
4348
public static bool IsColorMaskTextureConversionSupported()

Packages/com.unity.render-pipelines.core/Samples~/Common/Scripts/Editor/SamplesShowcaseEditorWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static void Init()
1919

2020
static void SceneOpened(Scene scene, OpenSceneMode openSceneMode)
2121
{
22-
var currentShowcase = (SamplesShowcase)FindFirstObjectByType(typeof(SamplesShowcase));
22+
var currentShowcase = (SamplesShowcase)FindAnyObjectByType(typeof(SamplesShowcase));
2323
if(currentShowcase != null)
2424
Selection.activeGameObject = currentShowcase.gameObject;
2525
}

Packages/com.unity.render-pipelines.core/Samples~/RendererShaderUserValue_Common/Scripts/VertexAnimationTextureBaker.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if UNITY_EDITOR
12
using UnityEngine;
23
using UnityEditor;
34
using System.Collections.Generic;
@@ -122,4 +123,5 @@ void BakeVATArray(GameObject target, List<AnimationClip> clips, int fps)
122123

123124
Debug.Log($"VAT Array (RGBAHalf) baked: {path} with {clips.Count} clips. Max frames = {maxFrames}");
124125
}
125-
}
126+
}
127+
#endif

Packages/com.unity.render-pipelines.core/Tests/Editor/CoreUtils.Tests.EnsureFolderTreeInAssetFilePath.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.IO;
3+
using System.Text;
34
using NUnit.Framework;
45
using UnityEngine.Rendering;
56

@@ -23,7 +24,13 @@ partial class CoreUtilsTests
2324
[TestCase("Assets/TestFolder/Folder#Test/SubFolder/", TestName = "Folder name containing a hash character")]
2425
[TestCase("Assets/TestFolder/Folder@Test/SubFolder/File.txt", TestName = "File name containing @ character")]
2526
[TestCase("Assets/TestFolder/Folder\\SubFolder/File", TestName = "File without extension")]
26-
27+
[TestCase("Assets/TestFolder//DoubleSlash/File.txt", TestName = "Path with double slashes")]
28+
[TestCase("Assets/TestFolder///TripleSlash/File.txt", TestName = "Path with triple slashes")]
29+
[TestCase("Assets/TestFolder/Mixed\\Separators/File.txt", TestName = "Mixed forward and backslashes")]
30+
[TestCase("Assets/TestFolder/A/B/C/D/E/F/G/H/I/J/Deep.txt", TestName = "Deep nested path (10 levels)")]
31+
[TestCase("Assets/TestFolder/Unicode文件夹/File.txt", TestName = "Unicode characters in folder name")]
32+
[TestCase("Assets/TestFolder/Émojis😀/File.txt", TestName = "Emoji in folder name")]
33+
[TestCase("Assets/TestFolder/VeryLongFolderNameThatExceedsNormalLength123456789012345678901234567890/File.txt", TestName = "Very long folder name")]
2734
public void EnsureFolderTreeInAssetFilePath(string path)
2835
{
2936
string folderPath = Path.GetDirectoryName(path);
@@ -34,15 +41,31 @@ public void EnsureFolderTreeInAssetFilePath(string path)
3441
[Test]
3542
[TestCase("Assets", TestName = "Just Assets and not Assets/")]
3643
[TestCase("NotAssetsFolder/TestFolder/", TestName = "FilePath does not start with Assets/")]
44+
[TestCase("assets/TestFolder/", TestName = "Lowercase assets (case sensitivity)")]
45+
[TestCase("ASSETS/TestFolder/", TestName = "Uppercase ASSETS")]
46+
[TestCase("FileName.txt", TestName = "FileName.txt")]
47+
[TestCase("C:\\Filename.txt", TestName = "C:\\Filename.txt")]
3748
public void EnsureFolderTreeInAssetFilePathThrows(string folderPath)
3849
{
3950
Assert.Throws<ArgumentException>(() => CoreUtils.EnsureFolderTreeInAssetFilePath(folderPath));
4051
}
4152

53+
[Test]
54+
public void EnsureFolderTreeInAssetFilePath_NullOrEmpty_DoesNotThrow()
55+
{
56+
Assert.DoesNotThrow(() => CoreUtils.EnsureFolderTreeInAssetFilePath(null));
57+
Assert.DoesNotThrow(() => CoreUtils.EnsureFolderTreeInAssetFilePath(""));
58+
Assert.DoesNotThrow(() => CoreUtils.EnsureFolderTreeInAssetFilePath(string.Empty));
59+
}
60+
4261
[TearDown]
4362
public void TearDown()
4463
{
45-
AssetDatabase.DeleteAsset("Assets/TestFolder");
64+
if (AssetDatabase.IsValidFolder("Assets/TestFolder"))
65+
{
66+
AssetDatabase.DeleteAsset("Assets/TestFolder");
67+
}
68+
AssetDatabase.Refresh();
4669
}
4770
}
4871
}

Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3088,6 +3088,7 @@ out ScriptableCullingParameters cullingParams
30883088
frozenCullingParamAvailable = false;
30893089
}
30903090

3091+
cullingParams.conservativeEnclosingSphere = currentAsset.m_ShouldUseConservativeEnclosingSphere;
30913092
LightLoopUpdateCullingParameters(ref cullingParams, hdCamera);
30923093

30933094
// If we don't use environment light (like when rendering reflection probes)

Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ namespace UnityEngine.Rendering.HighDefinition
2424
#endif
2525
public partial class HDRenderPipelineAsset : RenderPipelineAsset<HDRenderPipeline>, IVirtualTexturingEnabledRenderPipeline, IProbeVolumeEnabledRenderPipeline, IGPUResidentRenderPipeline, IRenderGraphEnabledRenderPipeline, ISTPEnabledRenderPipeline
2626
{
27+
//This is not exposed to the UI. It can be enabled via Debug inspector if it is really needed.
28+
[SerializeField] internal bool m_ShouldUseConservativeEnclosingSphere;
2729
/// <inheritdoc/>
2830
public override string renderPipelineShaderTag => HDRenderPipeline.k_ShaderTagName;
2931

0 commit comments

Comments
 (0)