Skip to content

Commit db423c4

Browse files
authored
Merge pull request #8251 from Unity-Technologies/internal/6000.3/staging
Mirror Internal/6000.3/staging
2 parents c0e46fb + b2ca32b commit db423c4

File tree

62 files changed

+3107
-356
lines changed

Some content is hidden

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

62 files changed

+3107
-356
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public class InternalRenderGraphContext
118118
internal RenderGraphPass executingPass;
119119
internal NativeRenderPassCompiler.CompilerContextData compilerContext;
120120
internal bool contextlessTesting;
121+
internal bool forceResourceCreation;
121122
}
122123

123124
// InternalRenderGraphContext is public (but all members are internal)
@@ -1621,6 +1622,15 @@ public void BeginRecording(in RenderGraphParameters parameters)
16211622
m_RenderGraphContext.renderGraphPool = m_RenderGraphPool;
16221623
m_RenderGraphContext.defaultResources = m_DefaultResources;
16231624

1625+
// With the actual implementation of the Frame Debugger, we cannot re-use resources during the same frame
1626+
// or it breaks the rendering of the pass preview, since the FD copies the texture after the execution of the RG.
1627+
m_RenderGraphContext.forceResourceCreation =
1628+
#if UNITY_EDITOR || DEVELOPMENT_BUILD
1629+
FrameDebugger.enabled;
1630+
#else
1631+
false;
1632+
#endif
1633+
16241634
if (m_DebugParameters.immediateMode)
16251635
{
16261636
UpdateCurrentCompiledGraph(graphHash: -1, forceNoCaching: true);

Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ internal bool CreatePooledResource(InternalRenderGraphContext rgContext, int typ
10171017
var resource = m_RenderGraphResources[type].resourceArray[index];
10181018
if (!resource.imported)
10191019
{
1020-
resource.CreatePooledGraphicsResource();
1020+
resource.CreatePooledGraphicsResource(rgContext.forceResourceCreation);
10211021

10221022
if (m_RenderGraphDebug.enableLogging)
10231023
resource.LogCreation(m_FrameInformationLogger);

Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public virtual bool NeedsFallBack()
183183
return requestFallBack && writeCount == 0;
184184
}
185185

186-
public virtual void CreatePooledGraphicsResource() { }
186+
public virtual void CreatePooledGraphicsResource(bool forceResourceCreation) { }
187187
public virtual void CreateGraphicsResource() { }
188188
public virtual void UpdateGraphicsResource() { }
189189
public virtual void ReleasePooledGraphicsResource(int frameIndex) { }
@@ -231,7 +231,7 @@ public override void ReleaseGraphicsResource()
231231
graphicsResource = null;
232232
}
233233

234-
public override void CreatePooledGraphicsResource()
234+
public override void CreatePooledGraphicsResource(bool forceResourceCreation)
235235
{
236236
Debug.Assert(m_Pool != null, "RenderGraphResource: CreatePooledGraphicsResource should only be called for regular pooled resources");
237237

@@ -242,7 +242,7 @@ public override void CreatePooledGraphicsResource()
242242

243243
// If the pool doesn't have any available resource that we can use, we will create one
244244
// In any case, we will update the graphicsResource name based on the RenderGraph resource name
245-
if (!m_Pool.TryGetResource(hashCode, out graphicsResource))
245+
if (forceResourceCreation || !m_Pool.TryGetResource(hashCode, out graphicsResource))
246246
{
247247
CreateGraphicsResource();
248248
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace UnityEngine.Rendering
77
/// </summary>
88
[Serializable]
99
[SupportedOnRenderPipeline]
10-
[Categorization.CategoryInfo(Name = "R: VRS - Runtime Resources", Order = 1000)]
10+
[Categorization.CategoryInfo(Name = "VRS - Runtime Resources", Order = 1000)]
1111
public sealed class VrsRenderPipelineRuntimeResources : IRenderPipelineResources
1212
{
1313
/// <summary>
@@ -18,6 +18,7 @@ public sealed class VrsRenderPipelineRuntimeResources : IRenderPipelineResources
1818
bool IRenderPipelineGraphicsSettings.isAvailableInPlayerBuild => true;
1919

2020
[SerializeField]
21+
[Tooltip("Compute shader used for converting textures to shading rate values")]
2122
[ResourcePath("Runtime/Vrs/Shaders/VrsTexture.compute")]
2223
ComputeShader m_TextureComputeShader;
2324

@@ -31,6 +32,7 @@ public ComputeShader textureComputeShader
3132
}
3233

3334
[SerializeField]
35+
[Tooltip("Shader used when visualizing shading rate values as a color image")]
3436
[ResourcePath("Runtime/Vrs/Shaders/VrsVisualization.shader")]
3537
Shader m_VisualizationShader;
3638

Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ float3 AcesTonemap(float3 aces)
651651

652652
// --- Red modifier --- //
653653
half hue = rgb_2_hue(half3(aces));
654-
half centeredHue = center_hue(hue, RRT_RED_HUE);
654+
float centeredHue = center_hue(hue, RRT_RED_HUE); // UUM-125596 Must be float for subsequent calculations
655655
float hueWeight;
656656
{
657657
//hueWeight = cubic_basis_shaper(centeredHue, RRT_RED_WIDTH);

Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityDOTSInstancing.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ void SetupDOTSInstanceSelectMasks() {}
294294

295295
#ifdef UNITY_DOTS_INSTANCING_UNIFORM_BUFFER
296296
CBUFFER_START(unity_DOTSInstancing_IndirectInstanceVisibility)
297-
float4 unity_DOTSInstancing_IndirectInstanceVisibilityRaw[4096];
297+
float4 unity_DOTSInstancing_IndirectInstanceVisibilityRaw[1024];
298298
CBUFFER_END
299299
#else
300300
ByteAddressBuffer unity_DOTSInstancing_IndirectInstanceVisibility;

Packages/com.unity.render-pipelines.core/Tests/Editor/UnifiedRayTracing/TraceTransparentRays.urtshader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int _AnyHitDecision;
1717

1818
uint AnyHitExecute(UnifiedRT::HitContext hitContext, inout RayPayload payload)
1919
{
20-
payload.anyHits |= (1 << hitContext.InstanceID());
20+
payload.anyHits |= (1u << hitContext.InstanceID());
2121

2222
return _AnyHitDecision;
2323
}

Packages/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPBuildData.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using UnityEditor.SceneManagement;
34
using UnityEngine;
45
using UnityEngine.Rendering;
56
using UnityEngine.Rendering.HighDefinition;
@@ -16,6 +17,7 @@ internal class HDRPBuildData : IDisposable
1617
public List<HDRenderPipelineAsset> renderPipelineAssets { get; private set; } = new List<HDRenderPipelineAsset>();
1718
public bool playerNeedRaytracing { get; private set; }
1819
public bool stripDebugVariants { get; private set; } = true;
20+
public bool dynamicLightmapsUsed { get; private set; }
1921
public bool waterDecalMaskAndCurrent { get; private set; }
2022
public Dictionary<int, ComputeShader> rayTracingComputeShaderCache { get; private set; } = new();
2123
public Dictionary<int, ComputeShader> computeShaderCache { get; private set; } = new();
@@ -69,13 +71,43 @@ public HDRPBuildData(BuildTarget buildTarget, bool isDevelopmentBuild)
6971
m_Instance = this;
7072
}
7173

74+
public void SetDynamicLightmapsUsedInBuildScenes()
75+
{
76+
dynamicLightmapsUsed = DynamicLightmapsUsedInBuildScenes();
77+
}
78+
79+
static bool DynamicLightmapsUsedInBuildScenes()
80+
{
81+
var originalSetup = EditorSceneManager.GetSceneManagerSetup();
82+
83+
bool dynamicLightmapsUsed = false;
84+
foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
85+
{
86+
if (!scene.enabled) continue;
87+
88+
EditorSceneManager.OpenScene(scene.path, OpenSceneMode.Single);
89+
90+
if (Lightmapping.HasDynamicGILightmapTextures())
91+
{
92+
dynamicLightmapsUsed = true;
93+
break;
94+
}
95+
}
96+
97+
if (originalSetup.Length > 0)
98+
EditorSceneManager.RestoreSceneManagerSetup(originalSetup);
99+
100+
return dynamicLightmapsUsed;
101+
}
102+
72103
public void Dispose()
73104
{
74105
renderPipelineAssets?.Clear();
75106
rayTracingComputeShaderCache?.Clear();
76107
computeShaderCache?.Clear();
77108
playerNeedRaytracing = false;
78109
stripDebugVariants = true;
110+
dynamicLightmapsUsed = false;
79111
waterDecalMaskAndCurrent = false;
80112
buildingPlayerForHDRenderPipeline = false;
81113
runtimeShaders = null;

Packages/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessBuild.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public void OnPreprocessBuild(BuildReport report)
3333
bool isDevelopmentBuild = (report.summary.options & BuildOptions.Development) != 0;
3434
m_BuildData = new HDRPBuildData(EditorUserBuildSettings.activeBuildTarget, isDevelopmentBuild);
3535

36+
// Since the HDRPBuildData instance is used in a lot of places, doing this check here ensures that it is done before the build starts.
37+
m_BuildData.SetDynamicLightmapsUsedInBuildScenes();
38+
3639
if (m_BuildData.buildingPlayerForHDRenderPipeline)
3740
{
3841
// Now that we know that we are on HDRP we need to make sure everything is correct, otherwise we break the build.

Packages/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessShaders.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using UnityEditor.SceneManagement;
12
using UnityEngine;
23
using UnityEngine.Rendering;
34
using UnityEngine.Rendering.HighDefinition;
@@ -70,8 +71,10 @@ protected override bool DoShadersStripper(HDRenderPipelineAsset hdrpAsset, Shade
7071
// Remove editor only pass
7172
bool isSceneSelectionPass = snippet.passName == "SceneSelectionPass";
7273
bool isScenePickingPass = snippet.passName == "ScenePickingPass";
73-
bool metaPassUnused = (snippet.passName == "META") && (SupportedRenderingFeatures.active.enlighten == false ||
74-
((int)SupportedRenderingFeatures.active.lightmapBakeTypes | (int)LightmapBakeType.Realtime) == 0);
74+
75+
bool isEnlightenSupported = SupportedRenderingFeatures.active.enlighten && ((int)SupportedRenderingFeatures.active.lightmapBakeTypes | (int)LightmapBakeType.Realtime) != 0;
76+
bool metaPassUnused = (snippet.passName == "META") && (!isEnlightenSupported || !HDRPBuildData.instance.dynamicLightmapsUsed);
77+
7578
bool editorVisualization = inputData.shaderKeywordSet.IsEnabled(m_EditorVisualization);
7679
if (isSceneSelectionPass || isScenePickingPass || metaPassUnused || editorVisualization)
7780
return true;

0 commit comments

Comments
 (0)