Skip to content

Commit a0f9052

Browse files
Internal/6000.3/staging
Internal/6000.3/staging
2 parents fb02907 + 0181123 commit a0f9052

File tree

189 files changed

+10596
-2448
lines changed

Some content is hidden

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

189 files changed

+10596
-2448
lines changed

Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugState.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,35 @@ public sealed class DebugStateInt : DebugState<int> { }
182182
[Serializable, DebugState(typeof(DebugUI.ObjectPopupField), typeof(DebugUI.CameraSelector), typeof(DebugUI.ObjectField))]
183183
public sealed class DebugStateObject : DebugState<UnityEngine.Object>
184184
{
185+
[SerializeField] string m_UserData;
186+
187+
/// <inheritdoc/>
188+
public override void SetValue(object value, DebugUI.IValueField field)
189+
{
190+
// DebugStateObject is used to serialize the selected camera reference in DebugUI.CameraSelector. For SceneView Camera this doesn't work because
191+
// the camera is never saved and always recreated. So we use a special string to identify this case and restore the reference later.
192+
if (field is DebugUI.CameraSelector && SceneView.lastActiveSceneView != null && (Camera)value == SceneView.lastActiveSceneView.camera)
193+
{
194+
m_UserData = "SceneViewCamera";
195+
}
196+
else
197+
{
198+
m_UserData = null;
199+
}
200+
base.SetValue(value, field);
201+
}
202+
203+
/// <inheritdoc/>
204+
public override object GetValue()
205+
{
206+
if (value == null && m_UserData != null && m_UserData == "SceneViewCamera" && SceneView.lastActiveSceneView != null && SceneView.lastActiveSceneView.camera != null)
207+
{
208+
value = SceneView.lastActiveSceneView.camera;
209+
}
210+
211+
return base.GetValue();
212+
}
213+
185214
/// <summary>
186215
/// Returns the hash code of the Debug Item.
187216
/// </summary>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class DefaultLightTransport : LightingBaker
9494

9595
public override void Initialize(bool bakeProbeOcclusion, NativeArray<Vector3> probePositions)
9696
{
97-
if (!InputExtraction.ExtractFromScene(out input))
97+
if (!InputExtraction.ExtractFromScene(out input, true))
9898
{
9999
Debug.LogError("InputExtraction.ExtractFromScene failed.");
100100
return;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public override void Initialize(ProbeVolumeBakingSet bakingSet, NativeArray<Vect
109109
batchResult = new Vector3[k_MaxProbeCountPerBatch];
110110

111111
var computeBufferTarget = GraphicsBuffer.Target.CopyDestination | GraphicsBuffer.Target.CopySource
112-
| GraphicsBuffer.Target.Structured | GraphicsBuffer.Target.Raw;
112+
| GraphicsBuffer.Target.Structured;
113113

114114
// Create acceletation structure
115115
m_AccelerationStructure = BuildAccelerationStructure(voSettings.collisionMask);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ void ShowWarnings()
428428
{
429429
for (int i = 0; i < SceneManager.sceneCount; i++)
430430
{
431-
var scene = SceneManager.GetSceneAt(i);
431+
Scene scene = SceneManager.GetSceneAt(i);
432432
if (scene.isLoaded && ProbeVolumeBakingSet.GetBakingSetForScene(scene) != activeSet)
433433
scenesToUnload.Add(scene);
434434
}
@@ -467,7 +467,7 @@ void ShowWarnings()
467467
if (scenesToUnload.All(s => !s.isDirty) || EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
468468
{
469469
foreach (var scene in scenesToUnload)
470-
EditorSceneManager.CloseScene(scene, false);
470+
EditorSceneManager.CloseScene(scene, string.IsNullOrEmpty(scene.path)); // Remove the scene from the hierarchy iff it has never been saved.
471471
}
472472
break;
473473
}

Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/VirtualOffset/TraceVirtualOffset.urtshader

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,22 @@ void RayGenExecute(UnifiedRT::DispatchInfo dispatchInfo)
8787
if (!hit.IsValid() || hit.isFrontFace)
8888
{
8989
validHits++;
90-
continue;
9190
}
92-
93-
float distanceDiff = hit.hitDistance - minDist;
94-
if (distanceDiff < DISTANCE_THRESHOLD)
91+
else if (hit.IsValid())
9592
{
96-
UnifiedRT::HitGeomAttributes attributes = UnifiedRT::FetchHitGeomAttributes(hit, UnifiedRT::kGeomAttribFaceNormal);
97-
float dotSurface = dot(ray.direction, attributes.faceNormal);
98-
99-
// If new distance is smaller by at least kDistanceThreshold, or if ray is at least DOT_THRESHOLD more colinear with normal
100-
if (distanceDiff < -DISTANCE_THRESHOLD || dotSurface - maxDotSurface > DOT_THRESHOLD)
93+
float distanceDiff = hit.hitDistance - minDist;
94+
if (distanceDiff < DISTANCE_THRESHOLD)
10195
{
102-
outDirection = ray.direction;
103-
maxDotSurface = dotSurface;
104-
minDist = hit.hitDistance;
96+
UnifiedRT::HitGeomAttributes attributes = UnifiedRT::FetchHitGeomAttributes(hit, UnifiedRT::kGeomAttribFaceNormal);
97+
float dotSurface = dot(ray.direction, attributes.faceNormal);
98+
99+
// If new distance is smaller by at least kDistanceThreshold, or if ray is at least DOT_THRESHOLD more colinear with normal
100+
if (distanceDiff < -DISTANCE_THRESHOLD || dotSurface - maxDotSurface > DOT_THRESHOLD)
101+
{
102+
outDirection = ray.direction;
103+
maxDotSurface = dotSurface;
104+
minDist = hit.hitDistance;
105+
}
105106
}
106107
}
107108
}

Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphTestsCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public void CleanupRenderGraph()
187187
m_RenderGraphTestPipeline.invalidContextForTesting = false;
188188
// Cleaning all Render Graph resources and data structures
189189
// Nothing remains, Render Graph in next test will start from scratch
190-
m_RenderGraph.ForceCleanup();
190+
m_RenderGraph.CleanupResourcesAndGraph();
191191
}
192192
}
193193
}

Packages/com.unity.render-pipelines.core/Editor/Upscaling.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#if UNITY_EDITOR
2+
#if ENABLE_UPSCALER_FRAMEWORK && ENABLE_NVIDIA && ENABLE_NVIDIA_MODULE
3+
using UnityEditor;
4+
using UnityEngine;
5+
using UnityEngine.NVIDIA;
6+
7+
[CustomEditor(typeof(DLSSOptions))]
8+
public class DLSSOptionsEditor : Editor
9+
{
10+
// Declare variables to hold each property
11+
private SerializedProperty m_QualityMode;
12+
private SerializedProperty m_FixedResolution;
13+
private SerializedProperty m_PresetQuality;
14+
private SerializedProperty m_PresetBalanced;
15+
private SerializedProperty m_PresetPerformance;
16+
private SerializedProperty m_PresetUltraPerformance;
17+
private SerializedProperty m_PresetDLAA;
18+
private void OnEnable()
19+
{
20+
// Find each property by its exact field name in DLSSOptions.cs
21+
m_QualityMode = serializedObject.FindProperty("DLSSQualityMode");
22+
m_FixedResolution = serializedObject.FindProperty("FixedResolutionMode");
23+
m_PresetQuality = serializedObject.FindProperty("DLSSRenderPresetQuality");
24+
m_PresetBalanced = serializedObject.FindProperty("DLSSRenderPresetBalanced");
25+
m_PresetPerformance = serializedObject.FindProperty("DLSSRenderPresetPerformance");
26+
m_PresetUltraPerformance = serializedObject.FindProperty("DLSSRenderPresetUltraPerformance");
27+
m_PresetDLAA = serializedObject.FindProperty("DLSSRenderPresetDLAA");
28+
}
29+
30+
#region STYLES
31+
private static readonly string[] DLSSPerfQualityLabels =
32+
{ // should follow enum value ordering in DLSSQuality enum
33+
DLSSQuality.MaximumPerformance.ToString(),
34+
DLSSQuality.Balanced.ToString(),
35+
DLSSQuality.MaximumQuality.ToString(),
36+
DLSSQuality.UltraPerformance.ToString(),
37+
DLSSQuality.DLAA.ToString()
38+
};
39+
private static string[][] DLSSPresetOptionsForEachPerfQuality = PopulateDLSSQualityPresetLabels();
40+
private static string[][] PopulateDLSSQualityPresetLabels()
41+
{
42+
int CountBits(uint bitMask) // System.Numerics.BitOperations not available
43+
{
44+
int count = 0;
45+
while (bitMask > 0)
46+
{
47+
count += (bitMask & 1) > 0 ? 1 : 0;
48+
bitMask >>= 1;
49+
}
50+
return count;
51+
}
52+
53+
System.Array perfQualities = System.Enum.GetValues(typeof(DLSSQuality));
54+
string[][] labels = new string[perfQualities.Length][];
55+
foreach (DLSSQuality quality in perfQualities)
56+
{
57+
uint presetBitmask = GraphicsDevice.GetAvailableDLSSPresetsForQuality(quality);
58+
int numPresets = CountBits(presetBitmask) + 1; // +1 for default option which is available to all quality enums
59+
labels[(int)quality] = new string[numPresets];
60+
61+
int iWrite = 0;
62+
System.Array presets = System.Enum.GetValues(typeof(DLSSPreset));
63+
foreach (DLSSPreset preset in presets)
64+
{
65+
if (preset == DLSSPreset.Preset_Default)
66+
{
67+
labels[(int)quality][iWrite++] = "Default Preset";
68+
continue;
69+
}
70+
71+
if ((presetBitmask & (uint)preset) != 0)
72+
{
73+
string presetName = preset.ToString().Replace('_', ' ');
74+
labels[(int)quality][iWrite++] = presetName + " - " + GraphicsDevice.GetDLSSPresetExplanation(preset);
75+
}
76+
}
77+
}
78+
return labels;
79+
}
80+
81+
private static readonly GUIContent renderPresetsLabel = new GUIContent("Render Presets", "Selects an internal DLSS tuning profile. Presets adjust reconstruction behavior, trading off between sharpness, stability, and performance. Different presets may work better depending on scene content and motion.");
82+
#endregion
83+
84+
85+
// DLSSOptions contain DLSS presets for each quality mode.
86+
// The presets available for each quality mode may be different from one another and change over time between DLSS releases.
87+
// E.g. DLAAPreset = { F, J, K }
88+
// BalancedPreset = { J, K }
89+
// Instead of letting Unity default-render the GUI, we write our own inspector logic to enforce the preset value requirements.
90+
void DrawPresetDropdown(ref SerializedProperty presetProp, DLSSQuality perfQuality)
91+
{
92+
// each DLSSQuality has a different set of DLSSPresets, represented by a bitmask.
93+
uint presetBitmask = GraphicsDevice.GetAvailableDLSSPresetsForQuality(perfQuality);
94+
bool propHasInvalidPresetValue = presetProp.uintValue != 0 && (presetBitmask & presetProp.uintValue) == 0;
95+
if (propHasInvalidPresetValue)
96+
{
97+
Debug.LogWarningFormat("DLSS Preset {0} not found for quality setting {1}, resetting to default value.",
98+
((DLSSPreset)presetProp.uintValue).ToString(),
99+
perfQuality.ToString()
100+
);
101+
presetProp.uintValue = 0;
102+
}
103+
104+
// We don't want to deal with List<DLSSPreset> & using bitmasks,
105+
// so we need some bit ops to convert between GUI index <--> Preset value
106+
int FindPresetGUIIndex(uint presetBitmask, uint presetValue)
107+
{
108+
int i = 0;
109+
while (presetValue > 0)
110+
{
111+
i += (presetBitmask & 1) > 0 ? 1 : 0;
112+
presetBitmask >>= 1;
113+
presetValue >>= 1;
114+
}
115+
return i; // includes 0=default, goes like 1=preset_A, 2=preset_B ...
116+
}
117+
uint GUIIndexToPresetValue(uint presetBitmask, uint index)
118+
{
119+
// e.g. bitset: 100101 --> 3 bits set, supports 4 presets (0=default, +3 other presets).
120+
// ^ i = 1 -> Preset A = 1
121+
// ^ i = 2 -> Preset C = 4
122+
// ^ i = 3 -> Preset F = 32
123+
uint val = 0;
124+
while (index > 0 && presetBitmask > 0)
125+
{
126+
if ((presetBitmask & 1) != 0)
127+
--index;
128+
presetBitmask >>= 1;
129+
val = val == 0 ? 1 : (val << 1);
130+
}
131+
if (index != 0)
132+
{
133+
Debug.LogWarningFormat("DLSSPreset (index={0}) not found in the supported preset list (mask={1}), setting to default value.", index, presetBitmask);
134+
return 0;
135+
}
136+
// Debug.LogFormat("Setting preset {0} : {1}", ((DLSSPreset)val).ToString(), val);
137+
return val;
138+
}
139+
140+
int presetIndex = FindPresetGUIIndex(presetBitmask, presetProp.uintValue);
141+
int iNew = EditorGUILayout.Popup(DLSSPerfQualityLabels[(int)perfQuality], presetIndex, DLSSPresetOptionsForEachPerfQuality[(int)perfQuality]);
142+
if (iNew != presetIndex)
143+
presetProp.uintValue = GUIIndexToPresetValue(presetBitmask, (uint)iNew);
144+
}
145+
public override void OnInspectorGUI()
146+
{
147+
serializedObject.Update();
148+
149+
EditorGUILayout.PropertyField(m_QualityMode);
150+
EditorGUILayout.PropertyField(m_FixedResolution);
151+
152+
EditorGUILayout.LabelField(renderPresetsLabel, EditorStyles.boldLabel);
153+
++EditorGUI.indentLevel;
154+
155+
DrawPresetDropdown(ref m_PresetQuality, DLSSQuality.MaximumQuality);
156+
DrawPresetDropdown(ref m_PresetBalanced, DLSSQuality.Balanced);
157+
DrawPresetDropdown(ref m_PresetPerformance, DLSSQuality.MaximumPerformance);
158+
DrawPresetDropdown(ref m_PresetUltraPerformance, DLSSQuality.UltraPerformance);
159+
DrawPresetDropdown(ref m_PresetDLAA, DLSSQuality.DLAA);
160+
161+
--EditorGUI.indentLevel;
162+
163+
serializedObject.ApplyModifiedProperties();
164+
}
165+
}
166+
#endif
167+
#endif

Packages/com.unity.render-pipelines.core/Editor/Upscaling/DLSSOptionsEditor.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#if ENABLE_UPSCALER_FRAMEWORK
2+
#if UNITY_EDITOR
3+
using UnityEditor;
4+
5+
/// <summary>
6+
/// This custom editor ensures that when drawing any UpscalerOptions object,
7+
/// the default "Script" field is not shown. Applies to all derived options.
8+
/// </summary>
9+
[CustomEditor(typeof(UnityEngine.Rendering.UpscalerOptions), true)]
10+
public class UpscalerOptionsEditor : Editor
11+
{
12+
public override void OnInspectorGUI()
13+
{
14+
// DrawDefaultInspector renders all serialized fields except for the "Script" field
15+
// and any fields marked with [HideInInspector].
16+
DrawDefaultInspector();
17+
}
18+
}
19+
#endif
20+
#endif

0 commit comments

Comments
 (0)