Skip to content

Commit 7db7b9b

Browse files
Merge pull request #8287 from Unity-Technologies/internal/6000.3/staging
Mirror Internal/6000.3/staging
2 parents 65a7fde + d0663f1 commit 7db7b9b

66 files changed

Lines changed: 7673 additions & 214 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/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~/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.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3062,6 +3062,7 @@ out ScriptableCullingParameters cullingParams
30623062
frozenCullingParamAvailable = false;
30633063
}
30643064

3065+
cullingParams.conservativeEnclosingSphere = currentAsset.m_ShouldUseConservativeEnclosingSphere;
30653066
LightLoopUpdateCullingParameters(ref cullingParams, hdCamera);
30663067

30673068
// 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

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ internal TargetBuffer getConstrainedDepthBuffer()
5858
{
5959
TargetBuffer depth = targetDepthBuffer;
6060
if (depth == TargetBuffer.Camera &&
61+
HDRenderPipeline.currentAsset != null &&
6162
HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.dynamicResolutionSettings.enabled &&
62-
currentHDCamera.allowDynamicResolution &&
63+
currentHDCamera != null && currentHDCamera.allowDynamicResolution &&
6364
injectionPoint == CustomPassInjectionPoint.AfterPostProcess)
6465
{
6566
// This custom pass is injected after postprocessing, and Dynamic Resolution Scaling is enabled, which

Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawRenderer2DPass.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,18 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
110110
// Early out for preview camera
111111
if (cameraData.cameraType == CameraType.Preview)
112112
isLitView = false;
113+
114+
DebugHandler debugHandler = GetActiveDebugHandler(cameraData);
115+
if (debugHandler != null)
116+
isLitView = debugHandler.IsLightingActive;
113117
#endif
114118

115119
// Preset global light textures for first batch
116120
if (batchIndex == 0)
117121
{
118122
using (var builder = graph.AddRasterRenderPass<SetGlobalPassData>(k_SetLightBlendTexture, out var passData, m_SetLightBlendTextureProfilingSampler))
119123
{
120-
if (layerBatch.lightStats.useLights)
124+
if (layerBatch.lightStats.useLights && isLitView)
121125
{
122126
passData.lightTextures = universal2DResourceData.lightTextures[batchIndex];
123127
for (var i = 0; i < passData.lightTextures.Length; i++)
@@ -168,7 +172,7 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
168172
builder.UseRendererList(passData.rendererList);
169173
}
170174

171-
if (passData.layerUseLights)
175+
if (passData.layerUseLights && isLitView)
172176
{
173177
passData.lightTextures = universal2DResourceData.lightTextures[batchIndex];
174178
for (var i = 0; i < passData.lightTextures.Length; i++)

Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/Renderer2DRendergraph.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ private struct ImportResourceSummary
5656
CopyDepthPass m_CopyDepthPass;
5757
UpscalePass m_UpscalePass;
5858
CopyCameraSortingLayerPass m_CopyCameraSortingLayerPass;
59+
CapturePass m_CapturePass;
5960
FinalBlitPass m_FinalBlitPass;
6061
FinalBlitPass m_OffscreenUICoverPrepass;
6162
DrawScreenSpaceUIPass m_DrawOffscreenUIPass;
@@ -117,6 +118,7 @@ public Renderer2D(Renderer2DData data) : base(data)
117118

118119
m_UpscalePass = new UpscalePass(RenderPassEvent.AfterRenderingPostProcessing, m_BlitMaterial);
119120
m_CopyCameraSortingLayerPass = new CopyCameraSortingLayerPass(m_BlitMaterial);
121+
m_CapturePass = new CapturePass(RenderPassEvent.AfterRendering);
120122
m_FinalBlitPass = new FinalBlitPass(RenderPassEvent.AfterRendering + k_FinalBlitPassQueueOffset, m_BlitMaterial, m_BlitHDRMaterial);
121123
m_OffscreenUICoverPrepass = new FinalBlitPass(RenderPassEvent.BeforeRenderingPostProcessing, m_BlitMaterial, m_BlitOffscreenUICoverMaterial);
122124

@@ -201,7 +203,8 @@ private RenderPassInputSummary GetRenderPassInputs(UniversalCameraData cameraDat
201203
|| cameraData.cameraTargetDescriptor.msaaSamples > 1 && UniversalRenderer.PlatformRequiresExplicitMsaaResolve()
202204
|| m_Renderer2DData.useCameraSortingLayerTexture
203205
|| !Mathf.Approximately(cameraData.renderScale, 1.0f)
204-
|| (DebugHandler != null && DebugHandler.WriteToDebugScreenTexture(cameraData.resolveFinalTarget));
206+
|| (DebugHandler != null && DebugHandler.WriteToDebugScreenTexture(cameraData.resolveFinalTarget))
207+
|| cameraData.captureActions != null;
205208

206209
return inputSummary;
207210
}
@@ -958,6 +961,12 @@ private void OnAfterRendering(RenderGraph renderGraph)
958961
var finalBlitTarget = resolveToDebugScreen ? commonResourceData.debugScreenColor : commonResourceData.backBufferColor;
959962
var finalDepthHandle = resolveToDebugScreen ? commonResourceData.debugScreenDepth : commonResourceData.backBufferDepth;
960963

964+
// Capture pass for Unity Recorder
965+
if (hasCaptureActions)
966+
{
967+
m_CapturePass.RecordRenderGraph(renderGraph, frameData);
968+
}
969+
961970
if (applyFinalPostProcessing)
962971
{
963972
m_PostProcessPassRenderGraph.RenderFinalPassRenderGraph(renderGraph, frameData, in finalColorHandle, commonResourceData.overlayUITexture, in finalBlitTarget, needsColorEncoding);

0 commit comments

Comments
 (0)