Skip to content

Commit 7ae5ef9

Browse files
Merge pull request #8288 from Unity-Technologies/internal/master
Mirror Internal/master
2 parents 513e413 + 44d490e commit 7ae5ef9

537 files changed

Lines changed: 12216 additions & 5388 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/Documentation~/UnifiedRayTracing/create-ray-tracing-context.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,20 @@ rtResources.Load();
3535
```
3636
**Note:** Since the Player doesn't give access to the Asset Database, this method only works in the Editor.
3737

38-
To load the [`RayTracingResources`](xref:UnityEngine.Rendering.UnifiedRayTracing.RayTracingResources) in the Player, you can also build the **unifiedraytracing** AssetBundle. For more information about how to build and load AssetBundles, refer to [AssetBundles](xref:AssetBundlesIntro).
38+
To load the [`RayTracingResources`](xref:UnityEngine.Rendering.UnifiedRayTracing.RayTracingResources) in the Player, you can also build an AssetBundle that includes the following SRP Core files:
39+
- Runtime/UnifiedRayTracing/Common/GeometryPool/GeometryPoolKernels.compute
40+
- Runtime/UnifiedRayTracing/Common/Utilities/CopyBuffer.compute
41+
- Runtime/UnifiedRayTracing/Compute/RadeonRays/kernels/copyPositions.compute
42+
- Runtime/UnifiedRayTracing/Compute/RadeonRays/kernels/bit_histogram.compute
43+
- Runtime/UnifiedRayTracing/Compute/RadeonRays/kernels/block_reduce_part.compute
44+
- Runtime/UnifiedRayTracing/Compute/RadeonRays/kernels/block_scan.compute
45+
- Runtime/UnifiedRayTracing/Compute/RadeonRays/kernels/build_hlbvh.compute
46+
- Runtime/UnifiedRayTracing/Compute/RadeonRays/kernels/restructure_bvh.compute
47+
- Runtime/UnifiedRayTracing/Compute/RadeonRays/kernels/scatter.compute
48+
49+
For more information about how to build and load AssetBundles, refer to [AssetBundles](xref:AssetBundlesIntro).
50+
51+
Once the AssetBundle is built, you can load it using the following:
3952
```C#
4053
var rtResources = new RayTracingResources();
4154

Packages/com.unity.render-pipelines.core/Editor/Lighting/LightingSearchColumnProviders.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ internal static string GetBakingMode(ProbeVolumeBakingSet bakingSet)
308308

309309
internal static void SetBakingMode(ProbeVolumeBakingSet bakingSet, string mode)
310310
{
311+
Undo.RecordObject(bakingSet, "Change Baking Mode");
311312
bakingSet.singleSceneMode = (mode == "Single Scene");
312313
}
313314

@@ -318,6 +319,7 @@ internal static int GetSkyOcclusionBakingSamples(ProbeVolumeBakingSet bakingSet)
318319

319320
internal static void SetSkyOcclusionBakingSamples(ProbeVolumeBakingSet bakingSet, int samples)
320321
{
322+
Undo.RecordObject(bakingSet, "Change Occlusion Baking");
321323
bakingSet.skyOcclusionBakingSamples = samples;
322324
}
323325

@@ -334,6 +336,7 @@ internal static void SetVolumeMode(GameObject go, string mode)
334336
if (!go.TryGetComponent<Volume>(out var volume))
335337
return;
336338

339+
Undo.RecordObject(volume, "Change Volume Mode");
337340
volume.isGlobal = (mode == "Global");
338341
}
339342

@@ -350,6 +353,7 @@ internal static void SetVolumeProfile(GameObject go, VolumeProfile profile)
350353
if (!go.TryGetComponent<Volume>(out var volume))
351354
return;
352355

356+
Undo.RecordObject(volume, "Change Volume Profile");
353357
volume.sharedProfile = profile;
354358
}
355359

@@ -368,6 +372,7 @@ internal static void SetLightShape(GameObject go, LightType value)
368372

369373
if (IsLightShapeApplicable(value))
370374
{
375+
Undo.RecordObject(light, "Change light Shape");
371376
light.type = value;
372377
}
373378
}

Packages/com.unity.render-pipelines.core/Editor/PathTracing/BakeInputSerialization.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -734,11 +734,11 @@ public static UInt64 TilingModeToLightmapExpandedBufferSize(TilingMode tilingMod
734734
// TODO: We need to change the naming of the entries in the enum see: https://jira.unity3d.com/browse/GFXFEAT-728
735735
switch (tilingMode)
736736
{
737-
case TilingMode.None: bufferSize = 1048576; break; // UI: Highest Performance
738-
case TilingMode.Quarter: bufferSize = 524288; break; // UI: High Performance
739-
case TilingMode.Sixteenth: bufferSize = 262144; break; // UI: Automatic (but it is not automatic)
740-
case TilingMode.Sixtyfourth: bufferSize = 131072; break; // UI: Low Memory Usage
741-
case TilingMode.TwoHundredFiftySixth: bufferSize = 65536; break; // UI: Lowest Memory Usage
737+
case TilingMode.None: bufferSize = 2097152; break; // UI: Highest Performance
738+
case TilingMode.Quarter: bufferSize = 1048576; break; // UI: High Performance
739+
case TilingMode.Sixteenth: bufferSize = 524288; break; // UI: Automatic
740+
case TilingMode.Sixtyfourth: bufferSize = 262144; break; // UI: Low Memory Usage
741+
case TilingMode.TwoHundredFiftySixth: bufferSize = 131072; break; // UI: Lowest Memory Usage
742742
default: Debug.Assert(false, "Unknown tiling mode."); break;
743743
}
744744
return math.max(bufferSize, kMinBufferSize);

Packages/com.unity.render-pipelines.core/Editor/PathTracing/BakeInputToWorldConversion.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,9 @@ static Vector2 GetPyramidLightRect(float coneAngleInRads, float pyramidAspectRad
319319

320320
static float GetLightShadowRadius(UnityEngine.LightType lightType, in LightData lightData)
321321
{
322-
return (Util.IsPunctualLightType(lightType) && lightType != UnityEngine.LightType.Pyramid && lightType != UnityEngine.LightType.Box) ? lightData.shape0 : 0.0f;
322+
if (lightType == UnityEngine.LightType.Pyramid)
323+
return lightData.shape1; // For pyramid lights, shadow radius is in shape1 (shape0 is aspect ratio)
324+
return (Util.IsPunctualLightType(lightType) && lightType != UnityEngine.LightType.Box) ? lightData.shape0 : 0.0f;
323325
}
324326

325327
internal static void InjectEnvironmentLight(

Packages/com.unity.render-pipelines.core/Runtime/Camera/FreeCamera.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ public class FreeCamera : MonoBehaviour
3838
public float m_Turbo = 10.0f;
3939

4040
#if !USE_INPUT_SYSTEM
41-
private static string kMouseX = "Mouse X";
42-
private static string kMouseY = "Mouse Y";
43-
private static string kRightStickX = "Controller Right Stick X";
44-
private static string kRightStickY = "Controller Right Stick Y";
45-
private static string kVertical = "Vertical";
46-
private static string kHorizontal = "Horizontal";
47-
48-
private static string kYAxis = "YAxis";
49-
private static string kSpeedAxis = "Speed Axis";
41+
private static readonly string kMouseX = "Mouse X";
42+
private static readonly string kMouseY = "Mouse Y";
43+
private static readonly string kRightStickX = "Controller Right Stick X";
44+
private static readonly string kRightStickY = "Controller Right Stick Y";
45+
private static readonly string kVertical = "Vertical";
46+
private static readonly string kHorizontal = "Horizontal";
47+
48+
private static readonly string kYAxis = "YAxis";
49+
private static readonly string kSpeedAxis = "Speed Axis";
5050
#endif
5151

5252
#if USE_INPUT_SYSTEM

Packages/com.unity.render-pipelines.core/Runtime/CommandBuffers/CommandBufferHelpers.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Runtime.CompilerServices;
3+
using Unity.Scripting.LifecycleManagement;
34
using UnityEngine.VFX;
45

56
namespace UnityEngine.Rendering
@@ -9,8 +10,13 @@ namespace UnityEngine.Rendering
910
/// </summary>
1011
public struct CommandBufferHelpers
1112
{
13+
// These variables are just wrappers for the CommandBuffer supplied to methods below, so their state doesn't need
14+
// to be reset when entering play mode.
15+
[NoAutoStaticsCleanup]
1216
internal static RasterCommandBuffer rasterCmd = new RasterCommandBuffer(null, null, false);
17+
[NoAutoStaticsCleanup]
1318
internal static ComputeCommandBuffer computeCmd = new ComputeCommandBuffer(null, null, false);
19+
[NoAutoStaticsCleanup]
1420
internal static UnsafeCommandBuffer unsafeCmd = new UnsafeCommandBuffer(null, null, false);
1521

1622
/// <summary>

Packages/com.unity.render-pipelines.core/Runtime/Common/CommandBufferPool.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ public static class CommandBufferPool
1010
{
1111
static ObjectPool<CommandBuffer> s_BufferPool = new ObjectPool<CommandBuffer>(null, x => x.Clear());
1212

13+
#if UNITY_EDITOR
14+
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
15+
static void ResetStaticsOnLoad()
16+
{
17+
s_BufferPool = new ObjectPool<CommandBuffer>(null, x => x.Clear());
18+
}
19+
#endif
20+
1321
/// <summary>
1422
/// Get a new Command Buffer.
1523
/// </summary>

Packages/com.unity.render-pipelines.core/Runtime/Common/ComponentSingleton.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
14
namespace UnityEngine.Rendering
25
{
6+
#if UNITY_EDITOR
7+
static class ComponentSingletonRegistry
8+
{
9+
static readonly List<Component> s_Instances = new();
10+
11+
internal static void Register(Component instance) => s_Instances.Add(instance);
12+
13+
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
14+
static void ResetStaticsOnLoad()
15+
{
16+
foreach (var instance in s_Instances)
17+
if (instance != null)
18+
CoreUtils.Destroy(instance.gameObject);
19+
s_Instances.Clear();
20+
}
21+
}
22+
#endif
23+
324
// Use this class to get a static instance of a component
425
// Mainly used to have a default instance
526

@@ -11,6 +32,7 @@ public static class ComponentSingleton<TType>
1132
where TType : Component
1233
{
1334
static TType s_Instance = null;
35+
1436
/// <summary>
1537
/// Instance of the required component type.
1638
/// </summary>
@@ -28,6 +50,9 @@ public static TType instance
2850

2951
go.SetActive(false);
3052
s_Instance = go.AddComponent<TType>();
53+
#if UNITY_EDITOR
54+
ComponentSingletonRegistry.Register(s_Instance);
55+
#endif
3156
}
3257

3358
return s_Instance;

Packages/com.unity.render-pipelines.core/Runtime/Common/ConstantBuffer.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ namespace UnityEngine.Rendering
88
/// </summary>
99
public class ConstantBuffer
1010
{
11-
static List<ConstantBufferBase> m_RegisteredConstantBuffers = new List<ConstantBufferBase>();
11+
static readonly List<ConstantBufferBase> m_RegisteredConstantBuffers = new List<ConstantBufferBase>();
12+
13+
#if UNITY_EDITOR
14+
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
15+
static void ResetStaticsOnLoad()
16+
{
17+
ReleaseAll();
18+
}
19+
#endif
1220

1321
/// <summary>
1422
/// Update the GPU data of the constant buffer and bind it globally via a command buffer.

Packages/com.unity.render-pipelines.core/Runtime/Common/ContextContainer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Runtime.CompilerServices;
44
using Unity.Mathematics;
5+
using Unity.Scripting.LifecycleManagement;
56

67
namespace UnityEngine.Rendering
78
{
@@ -152,10 +153,14 @@ public void Dispose()
152153
m_ActiveItemIndices.Clear();
153154
}
154155

156+
// Static s_TypeCount and TypeId<T>.value fields don't need to be reset when entering playmode.
157+
// s_TypeCount is only incremented by the static initialization of TypeId<T>.value.
158+
[NoAutoStaticsCleanup]
155159
static uint s_TypeCount;
156160

157161
static class TypeId<T>
158162
{
163+
[NoAutoStaticsCleanup]
159164
public static uint value = s_TypeCount++;
160165
}
161166

0 commit comments

Comments
 (0)