Skip to content

Commit 1e55667

Browse files
Merge pull request #8299 from Unity-Technologies/internal/6000.5/staging
Internal/6000.5/staging
2 parents 8700510 + 4d9000d commit 1e55667

208 files changed

Lines changed: 34079 additions & 15466 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/Editor/InternalBridge/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
[assembly: InternalsVisibleTo("Unity.RenderPipelines.Core.Editor")]
44
[assembly: InternalsVisibleTo("Unity.RenderPipelines.HighDefinition.Editor")]
5+
[assembly: InternalsVisibleTo("Unity.RenderPipelines.Universal.Editor")]

Packages/com.unity.render-pipelines.core/Editor/InternalBridge/ObjectSelector.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,12 @@ public static void Show(UnityEngine.Object obj, Type requiredType, UnityEngine.O
1010
{
1111
UnityEditor.ObjectSelector.get.Show(obj, requiredType, objectBeingEdited, allowSceneObjects, allowedEntityIds, onObjectSelectorClosed, onObjectSelectedUpdated, showNoneItem);
1212
}
13+
14+
public static void SetVisualSelection(EntityId entityId)
15+
{
16+
UnityEditor.ObjectSelector.get.SetVisualSelection(entityId);
17+
}
18+
19+
public static bool isVisible => UnityEditor.ObjectSelector.isVisible;
1320
}
1421
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,7 @@ static internal void Init()
892892
Lightmapping.bakeStarted += OnBakeStarted;
893893
Lightmapping.bakeCancelled += OnBakeCancelled;
894894
Lightmapping.inputExtraction += OnInputExtraction;
895+
AssemblyReloadEvents.beforeAssemblyReload += CleanUp;
895896
}
896897
}
897898

Packages/com.unity.render-pipelines.core/Editor/Settings/PropertyDrawers/DefaultVolumeProfileSettingsPropertyDrawer.cs

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System;
2+
using UnityEditor.UIElements;
23
using UnityEngine;
34
using UnityEngine.Rendering;
45
using UnityEngine.UIElements;
6+
using Object = UnityEngine.Object;
57

68
namespace UnityEditor.Rendering
79
{
@@ -17,6 +19,7 @@ public abstract partial class DefaultVolumeProfileSettingsPropertyDrawer : Prope
1719
static DefaultVolumeProfileEditor s_DefaultVolumeProfileEditor;
1820

1921
VisualElement m_Root;
22+
ObjectField m_ObjectField;
2023

2124
/// <summary>SerializedObject representing the settings object</summary>
2225
protected SerializedObject m_SettingsSerializedObject;
@@ -31,6 +34,9 @@ public abstract partial class DefaultVolumeProfileSettingsPropertyDrawer : Prope
3134
/// <summary>Info box message</summary>
3235
protected abstract GUIContent volumeInfoBoxLabel { get; }
3336

37+
/// <summary>Label and tooltip used for the Default Volume Profile asset field.</summary>
38+
protected abstract GUIContent defaultVolumeProfileAssetLabel { get; }
39+
3440
/// <summary>
3541
/// CreatePropertyGUI implementation.
3642
/// </summary>
@@ -107,6 +113,142 @@ protected void DestroyDefaultVolumeProfileEditor()
107113
s_DefaultVolumeProfileSerializedProperty = null;
108114
}
109115

116+
/// <summary>
117+
/// Show modal dialog to confirm update of selected volume if needed and apply new volume profile.
118+
/// </summary>
119+
/// <param name="field">Object Field used to display Default Volume profile</param>
120+
/// <param name="newValue">New Volume profile</param>
121+
/// <param name="previousValue">Previous volume profile</param>
122+
/// <param name="defaultVolumeProfileSettings">Optionally provided default volume profile to extract default values</param>
123+
/// <typeparam name="TRenderPipeline">Render Pipeline type</typeparam>
124+
void ShowGlobalDefaultVolumeDialog<TRenderPipeline>(ObjectField field, Object newValue,
125+
Object previousValue, IDefaultVolumeProfileSettings defaultVolumeProfileSettings = null)
126+
where TRenderPipeline : RenderPipeline
127+
{
128+
bool confirmed = VolumeProfileUtils.UpdateGlobalDefaultVolumeProfileWithConfirmation<TRenderPipeline>(newValue as VolumeProfile, defaultVolumeProfileSettings?.volumeProfile);
129+
if (confirmed)
130+
{
131+
UpdateDefaultVolumeSerializedPropertyAndRecreate(field, newValue);
132+
}
133+
else
134+
{
135+
m_VolumeProfileSerializedProperty.objectReferenceValue = previousValue;
136+
m_VolumeProfileSerializedProperty.serializedObject.ApplyModifiedProperties();
137+
field.SetValueWithoutNotify(previousValue);
138+
// Update the ObjectSelector's visual selection if it's still open
139+
if (previousValue != null && ObjectSelector.isVisible)
140+
ObjectSelector.SetVisualSelection(previousValue.GetEntityId());
141+
}
142+
}
143+
144+
/// <summary>
145+
/// Update serialized property for Default Volume profile and recreate related Editors
146+
/// </summary>
147+
/// <param name="field">Object Field used to display Default Volume profile</param>
148+
/// <param name="newValue">New Volume profile</param>
149+
void UpdateDefaultVolumeSerializedPropertyAndRecreate(ObjectField field, Object newValue)
150+
{
151+
m_VolumeProfileSerializedProperty.objectReferenceValue = newValue;
152+
m_VolumeProfileSerializedProperty.serializedObject.ApplyModifiedProperties();
153+
field.SetValueWithoutNotify(newValue);
154+
DestroyDefaultVolumeProfileEditor();
155+
CreateDefaultVolumeProfileEditor();
156+
}
157+
158+
/// <summary>
159+
/// Draw ObjectField for Default Volume.
160+
/// </summary>
161+
/// <param name="defaultVolumeProfileSettings">Default value source if available</param>
162+
/// <typeparam name="TRenderPipeline">Render Pipeline type for Default Volume</typeparam>
163+
/// <typeparam name="TDefaultVolumeSettings">Default Volume settings container type</typeparam>
164+
/// <returns>New Object Field</returns>
165+
protected VisualElement DrawDefaultVolumeObjectField<TRenderPipeline, TDefaultVolumeSettings>(TDefaultVolumeSettings defaultVolumeProfileSettings = null)
166+
where TRenderPipeline: RenderPipeline
167+
where TDefaultVolumeSettings : class, IDefaultVolumeProfileSettings
168+
{
169+
VisualElement profileLine = new();
170+
var toggle = new Toggle();
171+
toggle.AddToClassList(Foldout.toggleUssClassName);
172+
var checkmark = toggle.Q(className: Toggle.checkmarkUssClassName);
173+
checkmark.AddToClassList(Foldout.checkmarkUssClassName);
174+
m_ObjectField = new ObjectField(defaultVolumeProfileAssetLabel.text)
175+
{
176+
tooltip = defaultVolumeProfileAssetLabel.tooltip,
177+
objectType = typeof(VolumeProfile),
178+
value = m_VolumeProfileSerializedProperty.objectReferenceValue as VolumeProfile,
179+
style =
180+
{
181+
flexShrink = 1,
182+
}
183+
};
184+
m_ObjectField.AddToClassList("unity-base-field__aligned"); //Align with other BaseField<T>
185+
m_ObjectField.Q<Label>().RegisterCallback<ClickEvent>(evt => toggle.value ^= true);
186+
187+
toggle.RegisterValueChangedCallback(evt =>
188+
{
189+
m_EditorContainer.style.display = evt.newValue ? DisplayStyle.Flex : DisplayStyle.None;
190+
m_DefaultVolumeProfileFoldoutExpanded.value = evt.newValue;
191+
});
192+
toggle.SetValueWithoutNotify(m_DefaultVolumeProfileFoldoutExpanded.value);
193+
m_EditorContainer.style.display = m_DefaultVolumeProfileFoldoutExpanded.value ? DisplayStyle.Flex : DisplayStyle.None;
194+
195+
profileLine.style.flexDirection = FlexDirection.Row;
196+
m_ObjectField.style.flexGrow = 1;
197+
198+
m_ObjectField.RegisterValueChangedCallback(evt =>
199+
{
200+
if (evt.newValue == evt.previousValue)
201+
return;
202+
203+
if (RenderPipelineManager.currentPipeline is not TRenderPipeline)
204+
{
205+
m_ObjectField.SetValueWithoutNotify(evt.previousValue);
206+
Debug.Log($"Cannot change Default Volume Profile when {typeof(TRenderPipeline).Name} is not active. Rolling back to previous value.");
207+
return;
208+
}
209+
210+
if (evt.newValue == null)
211+
{
212+
m_ObjectField.SetValueWithoutNotify(evt.previousValue);
213+
Debug.Log("This Volume Profile Asset cannot be null. Rolling back to previous value.");
214+
return;
215+
}
216+
217+
218+
if (evt.previousValue != null)
219+
{
220+
var newValue = evt.newValue;
221+
var oldValue = evt.previousValue;
222+
EditorApplication.delayCall += () => ShowGlobalDefaultVolumeDialog<TRenderPipeline>(m_ObjectField, newValue, oldValue, defaultVolumeProfileSettings);
223+
return;
224+
}
225+
226+
VolumeProfileUtils.UpdateGlobalDefaultVolumeProfile<TRenderPipeline>(evt.newValue as VolumeProfile, defaultVolumeProfileSettings?.volumeProfile);
227+
UpdateDefaultVolumeSerializedPropertyAndRecreate(m_ObjectField, evt.newValue);
228+
});
229+
230+
m_ObjectField.RegisterCallback<AttachToPanelEvent>(evt =>
231+
{
232+
if (GraphicsSettings.currentRenderPipeline == null || RenderPipelineManager.pipelineSwitchCompleted)
233+
HandleRenderPipelineChange<TRenderPipeline>();
234+
RenderPipelineManager.activeRenderPipelineTypeChanged += HandleRenderPipelineChange<TRenderPipeline>;
235+
});
236+
m_ObjectField.RegisterCallback<DetachFromPanelEvent>(evt => RenderPipelineManager.activeRenderPipelineTypeChanged -= HandleRenderPipelineChange<TRenderPipeline>);
237+
238+
profileLine.Add(toggle);
239+
profileLine.Add(m_ObjectField);
240+
241+
return profileLine;
242+
}
243+
244+
void HandleRenderPipelineChange<TRenderPipeline>()
245+
where TRenderPipeline: RenderPipeline
246+
{
247+
m_ObjectField.enabledSelf = RenderPipelineManager.currentPipeline is TRenderPipeline;
248+
}
249+
250+
251+
110252
/// <summary>
111253
/// Implementation of the Default Volume Profile asset field.
112254
/// </summary>

Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileUtils.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using UnityEngine;
44
using UnityEngine.Rendering;
5-
using UnityEngine.UIElements;
65

76
namespace UnityEditor.Rendering
87
{
@@ -65,7 +64,7 @@ internal static void AssignValuesToProfile(VolumeProfile targetProfile, VolumeCo
6564
}
6665

6766
/// <summary>
68-
/// Assign the global default default profile to VolumeManager. Ensures that defaultVolumeProfile contains
67+
/// Assign the global default profile to VolumeManager. Ensures that defaultVolumeProfile contains
6968
/// overrides for every component. If defaultValueSource is provided, it will be used as the source for
7069
/// default values instead of default-constructing them.
7170
/// If components will be added to the profile, a confirmation dialog is displayed.

Packages/com.unity.render-pipelines.core/Runtime/Debugging/RuntimeDebugWindow.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class RuntimeDebugWindow : MonoBehaviour
2020
bool m_PortraitOrientation;
2121
bool m_IsDirty;
2222

23+
int m_UIVersion = 0;
24+
2325
void Awake()
2426
{
2527
DebugManager.instance.onSetDirty -= RequestRecreateGUI;
@@ -38,12 +40,17 @@ void Awake()
3840
m_PanelRenderer.RegisterUIReloadCallback(OnUIReload);
3941
}
4042

41-
internal void OnUIReload(PanelRenderer renderer, VisualElement rootElement)
43+
internal void OnUIReload(PanelRenderer renderer, VisualElement rootElement, int version)
4244
{
4345
// Called on initial load AND on any asset change
4446
if (rootElement == null || rootElement.childCount == 0)
4547
return;
4648

49+
if (version == m_UIVersion)
50+
return;
51+
52+
m_UIVersion = version;
53+
4754
m_PanelRootElement = rootElement;
4855
m_RootVisualElement = rootElement[0];
4956

Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,9 @@ internal GPUResidentDrawer(in GPUResidentDrawerSettings settings, in InternalGPU
484484
RenderPipelineManager.beginCameraRendering += OnBeginCameraRendering;
485485
RenderPipelineManager.endCameraRendering += OnEndCameraRendering;
486486

487+
const string useLegacyLightmapsKeyword = "USE_LEGACY_LIGHTMAPS";
488+
Shader.EnableKeyword(useLegacyLightmapsKeyword);
489+
487490
if (!internalSettings.isManagedByUnitTest)
488491
InsertIntoPlayerLoop();
489492

@@ -522,6 +525,9 @@ internal void Dispose()
522525
if (!m_InternalSettings.isManagedByUnitTest)
523526
RemoveFromPlayerLoop();
524527

528+
const string useLegacyLightmapsKeyword = "USE_LEGACY_LIGHTMAPS";
529+
Shader.DisableKeyword(useLegacyLightmapsKeyword);
530+
525531
m_WorldProcessor.Dispose();
526532
m_WorldProcessor = null;
527533
m_SpeedTreeWindGPUDataUpdater.Dispose();

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

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

124123
// InternalRenderGraphContext is public (but all members are internal)
@@ -1243,12 +1242,13 @@ public void BeginRecording(in RenderGraphParameters parameters)
12431242

12441243
// With the actual implementation of the Frame Debugger, we cannot re-use resources during the same frame
12451244
// or it breaks the rendering of the pass preview, since the FD copies the texture after the execution of the RG.
1246-
m_RenderGraphContext.forceResourceCreation =
1245+
// When disabled, this mode prevents resources released in the current frame from being reused until the next frame.
12471246
#if UNITY_EDITOR || DEVELOPMENT_BUILD
1248-
FrameDebugger.enabled;
1247+
bool enableMemoryAliasing = !FrameDebugger.enabled;
12491248
#else
1250-
false;
1249+
bool enableMemoryAliasing = true;
12511250
#endif
1251+
m_Resources.EnableIntraFrameMemoryAliasing(enableMemoryAliasing);
12521252
}
12531253

12541254
/// <summary>
@@ -1647,6 +1647,33 @@ internal void ClearGlobalBindings()
16471647
m_RenderGraphContext.cmd.SetGlobalTexture(globalTex.Key, defaultResources.blackTexture);
16481648
}
16491649
}
1650+
1651+
/// <summary>
1652+
/// Enables or disables intra-frame memory aliasing for render graph resources.
1653+
/// When enabled, resources released within the same execution can be immediately reused by subsequent passes.
1654+
/// When disabled, resources released in the current execution cannot be reused until the next execution.
1655+
/// Note: An execution corresponds to a single RenderGraph recording/execution cycle. Multiple executions can occur
1656+
/// within the same frame (e.g., Frame Debugger cascade-repaints, multiple cameras).
1657+
/// This is primarily used for testing purposes and for Frame Debugger compatibility.
1658+
/// </summary>
1659+
/// <param name="enabled">True to enable intra-frame memory aliasing, false to disable it.</param>
1660+
internal void SetIntraFrameMemoryAliasing(bool enabled)
1661+
{
1662+
m_Resources.EnableIntraFrameMemoryAliasing(enabled);
1663+
}
1664+
1665+
#if UNITY_EDITOR
1666+
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
1667+
static void ResetStaticsOnLoad()
1668+
{
1669+
s_RegisteredExecutions.Clear();
1670+
s_EnableCompilationCachingForTests = null;
1671+
onGraphRegistered = null;
1672+
onGraphUnregistered = null;
1673+
onExecutionRegistered = null;
1674+
s_DebugSessionWasActive = false;
1675+
}
1676+
#endif
16501677
}
16511678

16521679
/// <summary>

0 commit comments

Comments
 (0)