Skip to content

Commit a66eeaf

Browse files
authored
Merge pull request #8117 from Unity-Technologies/internal/6000.0/staging
Internal/6000.0/staging
2 parents a65be2c + ad407bb commit a66eeaf

112 files changed

Lines changed: 32849 additions & 359 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~/render-graph-writing-a-render-pipeline.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This page covers the process of how to use the RenderGraph API to write a render
77
To begin, your render pipeline needs to maintain at least one instance of [RenderGraph](../api/UnityEngine.Rendering.RenderGraphModule.RenderGraph.html). This is the main entry point for the API. You can use more than one instance of a render graph, but be aware that Unity does not share resources across `RenderGraph` instances so for optimal memory usage, only use one instance.
88

99
```c#
10+
using UnityEngine.Rendering;
1011
using UnityEngine.Rendering.RenderGraphModule;
1112

1213
public class MyRenderPipeline : RenderPipeline
@@ -21,8 +22,11 @@ public class MyRenderPipeline : RenderPipeline
2122
void CleanupRenderGraph()
2223
{
2324
m_RenderGraph.Cleanup();
24-
m_RenderGraph = null;
25+
m_RenderGraph = null;
2526
}
27+
28+
...
29+
2630
}
2731
```
2832

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,23 @@ protected void CreateDefaultVolumeProfileEditor()
8888
}
8989
m_EditorContainer.Add(s_DefaultVolumeProfileEditor.Create());
9090
m_EditorContainer.Q<HelpBox>("volume-override-info-box").text = volumeInfoBoxLabel.text;
91+
92+
if (m_DefaultVolumeProfileFoldoutExpanded.value)
93+
m_EditorContainer.style.display = DisplayStyle.Flex;
9194
}
9295

9396
/// <summary>
9497
/// Destroys the Default Volume Profile editor.
9598
/// </summary>
9699
protected void DestroyDefaultVolumeProfileEditor()
97100
{
101+
m_EditorContainer.style.display = DisplayStyle.None;
102+
m_EditorContainer?.Clear();
103+
98104
if (s_DefaultVolumeProfileEditor != null)
99105
s_DefaultVolumeProfileEditor.Destroy();
100106
s_DefaultVolumeProfileEditor = null;
101107
s_DefaultVolumeProfileSerializedProperty = null;
102-
m_EditorContainer?.Clear();
103108
}
104109

105110
/// <summary>
@@ -124,8 +129,6 @@ public abstract class DefaultVolumeProfileSettingsContextMenu<TSetting, TRenderP
124129

125130
void IRenderPipelineGraphicsSettingsContextMenu<TSetting>.PopulateContextMenu(TSetting setting, PropertyDrawer _, ref GenericMenu menu)
126131
{
127-
menu.AddSeparator("");
128-
129132
bool canCreateNewAsset = RenderPipelineManager.currentPipeline is TRenderPipeline;
130133
VolumeProfileUtils.AddVolumeProfileContextMenuItems(ref menu,
131134
setting.volumeProfile,

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,6 @@ public static void EnsureAllOverridesForDefaultProfile(VolumeProfile profile, Vo
240240
{
241241
VolumeManager.instance.OnVolumeProfileChanged(profile);
242242
EditorUtility.SetDirty(profile);
243-
AssetDatabase.SaveAssets();
244-
AssetDatabase.Refresh();
245243
}
246244
}
247245

Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.Debug.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,9 @@ CellInstancedDebugProbes CreateInstancedProbes(Cell cell)
10891089
if (cell.debugProbes != null)
10901090
return cell.debugProbes;
10911091

1092+
if (HasActiveStreamingRequest(cell))
1093+
return null;
1094+
10921095
int maxSubdiv = GetMaxSubdivision() - 1;
10931096

10941097
if (!cell.data.bricks.IsCreated || cell.data.bricks.Length == 0 || !cell.data.probePositions.IsCreated || !cell.loaded)

Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.Streaming.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,6 +1450,11 @@ void UpdateDiskStreaming(CommandBuffer cmd)
14501450
}
14511451
}
14521452

1453+
bool HasActiveStreamingRequest(Cell cell)
1454+
{
1455+
return diskStreamingEnabled && m_ActiveStreamingRequests.Exists(x => x.cell == cell);
1456+
}
1457+
14531458
[Conditional("UNITY_EDITOR")]
14541459
[Conditional("DEVELOPMENT_BUILD")]
14551460
void LogStreaming(string log)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public ref ResourceVersionedData VersionedResourceData(ResourceHandle h)
9898
[MethodImpl(MethodImplOptions.AggressiveInlining)]
9999
public ReadOnlySpan<ResourceReaderData> Readers(ResourceHandle h)
100100
{
101-
int firstReader = ResourcesData.IndexReader(h, 0);
101+
int firstReader = resources.IndexReader(h, 0);
102102
int numReaders = resources[h].numReaders;
103103
return resources.readerData[h.iType].MakeReadOnlySpan(firstReader, numReaders);
104104
}
@@ -114,7 +114,7 @@ public ref ResourceReaderData ResourceReader(ResourceHandle h, int i)
114114
throw new Exception("Invalid reader id");
115115
}
116116
#endif
117-
return ref resources.readerData[h.iType].ElementAt(ResourcesData.IndexReader(h, 0) + i);
117+
return ref resources.readerData[h.iType].ElementAt(resources.IndexReader(h, 0) + i);
118118
}
119119

120120
// Data per graph level renderpass

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ internal void GenerateNativeCompilerDebugData(ref RenderGraph.DebugData debugDat
351351
var numReaders = outputDataVersioned.numReaders;
352352
for (var i = 0; i < numReaders; ++i)
353353
{
354-
var depIdx = ResourcesData.IndexReader(output.resource, i);
354+
var depIdx = ctx.resources.IndexReader(output.resource, i);
355355
ref var dep = ref ctx.resources.readerData[output.resource.iType].ElementAt(depIdx);
356356

357357
var outputDependencyPass = ctx.passData[dep.passId];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ void FindResourceUsageRanges()
594594
var numReaders = pointToVer.numReaders;
595595
for (var i = 0; i < numReaders; ++i)
596596
{
597-
var depIdx = ResourcesData.IndexReader(outputResource, i);
597+
var depIdx = ctx.resources.IndexReader(outputResource, i);
598598
ref var dep = ref ctx.resources.readerData[outputResource.iType].ElementAt(depIdx);
599599
ref var depPass = ref ctx.passData.ElementAt(dep.passId);
600600
if (pass.asyncCompute != depPass.asyncCompute)

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ public void SetWritingPass(CompilerContextData ctx, ResourceHandle h, int passId
146146
public void RegisterReadingPass(CompilerContextData ctx, ResourceHandle h, int passId, int index)
147147
{
148148
#if DEVELOPMENT_BUILD || UNITY_EDITOR
149-
if (numReaders >= ResourcesData.MaxReaders)
149+
if (numReaders >= ctx.resources.MaxReaders)
150150
{
151151
string passName = ctx.GetPassName(passId);
152152
string resourceName = ctx.GetResourceName(h);
153-
throw new Exception($"Maximum '{ResourcesData.MaxReaders}' passes can use a single graph output as input. Pass {passName} is trying to read {resourceName}.");
153+
throw new Exception($"Maximum '{ctx.resources.MaxReaders}' passes can use a single graph output as input. Pass {passName} is trying to read {resourceName}.");
154154
}
155155
#endif
156-
ctx.resources.readerData[h.iType][ResourcesData.IndexReader(h, numReaders)] = new ResourceReaderData
156+
ctx.resources.readerData[h.iType][ctx.resources.IndexReader(h, numReaders)] = new ResourceReaderData
157157
{
158158
passId = passId,
159159
inputSlot = index
@@ -167,13 +167,13 @@ public void RemoveReadingPass(CompilerContextData ctx, ResourceHandle h, int pas
167167
{
168168
for (int r = 0; r < numReaders;)
169169
{
170-
ref var reader = ref ctx.resources.readerData[h.iType].ElementAt(ResourcesData.IndexReader(h, r));
170+
ref var reader = ref ctx.resources.readerData[h.iType].ElementAt(ctx.resources.IndexReader(h, r));
171171
if (reader.passId == passId)
172172
{
173173
// It should be removed, switch with the end of the list if we're not already at the end of it
174174
if (r < numReaders - 1)
175175
{
176-
reader = ctx.resources.readerData[h.iType][ResourcesData.IndexReader(h, numReaders - 1)];
176+
reader = ctx.resources.readerData[h.iType][ctx.resources.IndexReader(h, numReaders - 1)];
177177
}
178178

179179
numReaders--;
@@ -193,8 +193,9 @@ internal class ResourcesData
193193
public NativeList<ResourceUnversionedData>[] unversionedData; // Flattened fixed size array storing info per resource id shared between all versions.
194194
public NativeList<ResourceVersionedData>[] versionedData; // Flattened fixed size array storing up to MaxVersions versions per resource id.
195195
public NativeList<ResourceReaderData>[] readerData; // Flattened fixed size array storing up to MaxReaders per resource id per version.
196-
public const int MaxVersions = 20; // A quite arbitrary limit should be enough for most graphs. Increasing it shouldn't be a problem but will use more memory as these lists use a fixed size upfront allocation.
197-
public const int MaxReaders = 100; // A quite arbitrary limit should be enough for most graphs. Increasing it shouldn't be a problem but will use more memory as these lists use a fixed size upfront allocation.
196+
197+
public int MaxVersions;
198+
public int MaxReaders;
198199

199200
public DynamicArray<Name>[] resourceNames;
200201

@@ -229,6 +230,9 @@ public void Clear()
229230

230231
public void Initialize(RenderGraphResourceRegistry resources)
231232
{
233+
uint maxReaders = 0;
234+
uint maxWriters = 0;
235+
232236
for (int t = 0; t < (int)RenderGraphResourceType.Count; t++)
233237
{
234238
RenderGraphResourceType resourceType = (RenderGraphResourceType) t;
@@ -287,8 +291,15 @@ public void Initialize(RenderGraphResourceRegistry resources)
287291
default:
288292
throw new Exception("Unsupported resource type: " + t);
289293
}
294+
295+
maxReaders = Math.Max(maxReaders, rll.readCount);
296+
maxWriters = Math.Max(maxWriters, rll.writeCount);
290297
}
291298

299+
// The first resource is a null resource, so we need to add 1 to the count.
300+
MaxReaders = (int)maxReaders + 1;
301+
MaxVersions = (int)maxWriters + 1;
302+
292303
// Clear the other caching structures, they will be filled later
293304
versionedData[t].Resize(MaxVersions * numResources, NativeArrayOptions.ClearMemory);
294305
readerData[t].Resize(MaxVersions * MaxReaders * numResources, NativeArrayOptions.ClearMemory);
@@ -297,7 +308,7 @@ public void Initialize(RenderGraphResourceRegistry resources)
297308

298309
// Flatten array index
299310
[MethodImpl(MethodImplOptions.AggressiveInlining)]
300-
public static int Index(ResourceHandle h)
311+
public int Index(ResourceHandle h)
301312
{
302313
#if UNITY_EDITOR // Hot path
303314
if (h.version < 0 || h.version >= MaxVersions)
@@ -308,7 +319,7 @@ public static int Index(ResourceHandle h)
308319

309320
// Flatten array index
310321
[MethodImpl(MethodImplOptions.AggressiveInlining)]
311-
public static int IndexReader(ResourceHandle h, int readerID)
322+
public int IndexReader(ResourceHandle h, int readerID)
312323
{
313324
#if UNITY_EDITOR // Hot path
314325
if (h.version < 0 || h.version >= MaxVersions)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ private ResourceHandle UseResource(in ResourceHandle handle, AccessFlags flags,
219219
}
220220

221221
m_RenderPass.AddResourceRead(versioned);
222+
m_Resources.IncrementReadCount(handle);
222223

223224
if ((flags & AccessFlags.Read) == 0)
224225
{
@@ -232,6 +233,7 @@ private ResourceHandle UseResource(in ResourceHandle handle, AccessFlags flags,
232233
if ((flags & AccessFlags.Read) != 0)
233234
{
234235
m_RenderPass.AddResourceRead(m_Resources.GetZeroVersionedHandle(handle));
236+
m_Resources.IncrementReadCount(handle);
235237
}
236238
}
237239

0 commit comments

Comments
 (0)