Skip to content

Commit 184d30e

Browse files
Internal/6000.0/staging
Internal/6000.0/staging
2 parents 8b50def + b484187 commit 184d30e

File tree

118 files changed

+6579
-1185
lines changed

Some content is hidden

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

118 files changed

+6579
-1185
lines changed

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
@@ -1420,7 +1420,7 @@ public void ExecuteGraph(InternalRenderGraphContext rgContext, RenderGraphResour
14201420
if (pass.waitOnGraphicsFencePassId != -1)
14211421
{
14221422
var fence = contextData.fences[pass.waitOnGraphicsFencePassId];
1423-
rgContext.cmd.WaitOnAsyncGraphicsFence(fence);
1423+
rgContext.cmd.WaitOnAsyncGraphicsFence(fence, SynchronisationStageFlags.PixelProcessing);
14241424
}
14251425

14261426
var nrpBegan = false;

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ 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 >= ctx.resources.MaxReaders)
149+
if (numReaders >= ctx.resources.MaxReaders[h.iType])
150150
{
151151
string passName = ctx.GetPassName(passId);
152152
string resourceName = ctx.GetResourceName(h);
@@ -194,8 +194,8 @@ internal class ResourcesData
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.
196196

197-
public int MaxVersions;
198-
public int MaxReaders;
197+
public int[] MaxVersions;
198+
public int[] MaxReaders;
199199

200200
public DynamicArray<Name>[] resourceNames;
201201

@@ -205,6 +205,8 @@ public ResourcesData()
205205
versionedData = new NativeList<ResourceVersionedData>[(int)RenderGraphResourceType.Count];
206206
readerData = new NativeList<ResourceReaderData>[(int)RenderGraphResourceType.Count];
207207
resourceNames = new DynamicArray<Name>[(int)RenderGraphResourceType.Count];
208+
MaxVersions = new int[(int)RenderGraphResourceType.Count];
209+
MaxReaders = new int[(int)RenderGraphResourceType.Count];
208210

209211
for (int t = 0; t < (int)RenderGraphResourceType.Count; t++)
210212
resourceNames[t] = new DynamicArray<Name>(0); // T in NativeList<T> cannot contain managed types, so the names are stored separately
@@ -241,14 +243,14 @@ void AllocateAndResizeNativeListIfNeeded<T>(ref NativeList<T> nativeList, int si
241243

242244
public void Initialize(RenderGraphResourceRegistry resources)
243245
{
244-
uint maxReaders = 0;
245-
uint maxWriters = 0;
246-
247246
for (int t = 0; t < (int)RenderGraphResourceType.Count; t++)
248247
{
249248
RenderGraphResourceType resourceType = (RenderGraphResourceType) t;
250249
var numResources = resources.GetResourceCount(resourceType);
251250

251+
uint maxReaders = 0;
252+
uint maxWriters = 0;
253+
252254
// We don't clear the list as we reinitialize it right after
253255
AllocateAndResizeNativeListIfNeeded(ref unversionedData[t], numResources, NativeArrayOptions.UninitializedMemory);
254256

@@ -308,12 +310,12 @@ public void Initialize(RenderGraphResourceRegistry resources)
308310
}
309311

310312
// The first resource is a null resource, so we need to add 1 to the count.
311-
MaxReaders = (int)maxReaders + 1;
312-
MaxVersions = (int)maxWriters + 1;
313+
MaxReaders[t] = (int)maxReaders + 1;
314+
MaxVersions[t] = (int)maxWriters + 1;
313315

314316
// Clear the other caching structures, they will be filled later
315-
AllocateAndResizeNativeListIfNeeded(ref versionedData[t], MaxVersions * numResources, NativeArrayOptions.ClearMemory);
316-
AllocateAndResizeNativeListIfNeeded(ref readerData[t], MaxVersions * MaxReaders * numResources, NativeArrayOptions.ClearMemory);
317+
AllocateAndResizeNativeListIfNeeded(ref versionedData[t], MaxVersions[t] * numResources, NativeArrayOptions.ClearMemory);
318+
AllocateAndResizeNativeListIfNeeded(ref readerData[t], MaxVersions[t] * MaxReaders[t] * numResources, NativeArrayOptions.ClearMemory);
317319
}
318320
}
319321

@@ -322,23 +324,23 @@ public void Initialize(RenderGraphResourceRegistry resources)
322324
public int Index(ResourceHandle h)
323325
{
324326
#if UNITY_EDITOR // Hot path
325-
if (h.version < 0 || h.version >= MaxVersions)
327+
if (h.version < 0 || h.version >= MaxVersions[h.iType])
326328
throw new Exception("Invalid version: " + h.version);
327329
#endif
328-
return h.index * MaxVersions + h.version;
330+
return h.index * MaxVersions[h.iType] + h.version;
329331
}
330332

331333
// Flatten array index
332334
[MethodImpl(MethodImplOptions.AggressiveInlining)]
333335
public int IndexReader(ResourceHandle h, int readerID)
334336
{
335337
#if UNITY_EDITOR // Hot path
336-
if (h.version < 0 || h.version >= MaxVersions)
338+
if (h.version < 0 || h.version >= MaxVersions[h.iType])
337339
throw new Exception("Invalid version");
338-
if (readerID < 0 || readerID >= MaxReaders)
340+
if (readerID < 0 || readerID >= MaxReaders[h.iType])
339341
throw new Exception("Invalid reader");
340342
#endif
341-
return (h.index * MaxVersions + h.version) * MaxReaders + readerID;
343+
return (h.index * MaxVersions[h.iType] + h.version) * MaxReaders[h.iType] + readerID;
342344
}
343345

344346
// Lookup data for a given handle

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ public void Cleanup()
524524

525525
nativeCompiler?.Cleanup();
526526

527-
m_CompilationCache?.Clear();
527+
m_CompilationCache?.Cleanup();
528528
}
529529

530530
internal RenderGraphDebugParams debugParams => m_DebugParameters;
@@ -1119,7 +1119,7 @@ public RenderGraphBuilder AddRenderPass<PassData>(string passName, out PassData
11191119
[CallerLineNumber] int line = 0) where PassData : class, new()
11201120
#endif
11211121
{
1122-
var renderPass = m_RenderGraphPool.Get<RenderGraphPass<PassData>>();
1122+
var renderPass = m_RenderGraphPool.Get<RenderGraphPass<PassData>>();
11231123
renderPass.Initialize(m_RenderPasses.Count, m_RenderGraphPool.Get<PassData>(), passName, RenderGraphPassType.Legacy, sampler);
11241124
renderPass.AllowGlobalState(true);// Old pass types allow global state by default as HDRP relies on it
11251125

@@ -2263,14 +2263,14 @@ void PreRenderPassExecute(in CompiledPassInfo passInfo, RenderGraphPass pass, In
22632263

22642264
if (executedWorkDuringResourceCreation)
22652265
{
2266-
rgContext.cmd.WaitOnAsyncGraphicsFence(previousFence);
2266+
rgContext.cmd.WaitOnAsyncGraphicsFence(previousFence, SynchronisationStageFlags.PixelProcessing);
22672267
}
22682268
}
22692269

22702270
// Synchronize with graphics or compute pipe if needed.
22712271
if (passInfo.syncToPassIndex != -1)
22722272
{
2273-
rgContext.cmd.WaitOnAsyncGraphicsFence(m_CurrentCompiledGraph.compiledPassInfos[passInfo.syncToPassIndex].fence);
2273+
rgContext.cmd.WaitOnAsyncGraphicsFence(m_CurrentCompiledGraph.compiledPassInfos[passInfo.syncToPassIndex].fence, SynchronisationStageFlags.PixelProcessing);
22742274
}
22752275
}
22762276

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

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,41 @@ public bool GetCompilationCache(int hash, int frameIndex, out CompilerContextDat
9696
return GetCompilationCache(hash, frameIndex, out outGraph, m_NativeHashEntries, m_NativeCompiledGraphPool, s_NativeEntryComparer);
9797
}
9898

99-
public void Clear()
99+
public void Cleanup()
100100
{
101+
// We clear the contents of the pools but not the pool themselves, because they are only
102+
// filled at the beginning of the renderer pipeline and never after. This means when we call
103+
// Cleanup() after an error, if we were clearing the pools, the render graph could not gracefully start
104+
// back up because the cache would have a size of 0 (so no room to cache anything).
105+
106+
// Cleanup compiled graphs currently in the cache
101107
for (int i = 0; i < m_HashEntries.size; ++i)
102-
m_CompiledGraphPool.Push(m_HashEntries[i].compiledGraph);
108+
{
109+
var compiledGraph = m_HashEntries[i].compiledGraph;
110+
compiledGraph.Clear();
111+
}
103112
m_HashEntries.Clear();
104113

114+
// Cleanup compiled graphs that might be left in the pool
115+
var compiledGraphs = m_CompiledGraphPool.ToArray();
116+
for (int i = 0; i < compiledGraphs.Length; ++i)
117+
{
118+
compiledGraphs[i].Clear();
119+
}
120+
121+
// Dispose of CompilerContextData currently in the cache
105122
for (int i = 0; i < m_NativeHashEntries.size; ++i)
106-
m_NativeCompiledGraphPool.Push(m_NativeHashEntries[i].compiledGraph);
123+
{
124+
var compiledGraph = m_NativeHashEntries[i].compiledGraph;
125+
compiledGraph.Dispose();
126+
}
107127
m_NativeHashEntries.Clear();
128+
129+
// Dispose of CompilerContextData that might be left in the pool
130+
var nativeCompiledGraphs = m_NativeCompiledGraphPool.ToArray();
131+
for (int i = 0; i < nativeCompiledGraphs.Length; ++i)
132+
{
133+
nativeCompiledGraphs[i].Dispose();
134+
}
108135
}
109136
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private void InitDefaultResourcesIfNeeded()
4848
m_WhiteTexture2D = RTHandles.Alloc(Texture2D.whiteTexture);
4949

5050
if (m_ShadowTexture2D == null)
51-
m_ShadowTexture2D = RTHandles.Alloc(1, 1, Experimental.Rendering.GraphicsFormat.D32_SFloat, isShadowMap: true, name: "DefaultShadowTexture");
51+
m_ShadowTexture2D = RTHandles.Alloc(1, 1, CoreUtils.GetDefaultDepthOnlyFormat(), isShadowMap: true, name: "DefaultShadowTexture");
5252
}
5353

5454
internal void Cleanup()

Packages/com.unity.render-pipelines.core/Tests/Editor/NativePassCompilerRenderGraphTests.cs

Lines changed: 85 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -876,11 +876,11 @@ public void MaxReadersAndMaxVersionsAreCorrectForBuffers()
876876

877877
// The resource with the biggest MaxReaders is buffer2:
878878
// 1 implicit read (TestPass0) + 1 explicit read (TestPass1) + 1 for the offset.
879-
Assert.AreEqual(result.contextData.resources.MaxReaders, 3);
879+
Assert.AreEqual(result.contextData.resources.MaxReaders[(int)RenderGraphResourceType.Buffer], 3);
880880

881881
// The resource with the biggest MaxVersion is buffer2:
882882
// 1 explicit write (TestPass0) + 1 explicit readwrite (TestPass1) + 1 for the offset
883-
Assert.AreEqual(result.contextData.resources.MaxVersions, 3);
883+
Assert.AreEqual(result.contextData.resources.MaxVersions[(int)RenderGraphResourceType.Buffer], 3);
884884
}
885885

886886
[Test]
@@ -917,11 +917,11 @@ public void MaxReadersAndMaxVersionsAreCorrectForTextures()
917917

918918
// Resources with the biggest MaxReaders are extraBuffers[0] and depthBuffer (both being equal):
919919
// 1 implicit read (TestPass0) + 2 explicit read (TestPass1 & TestPass2) + 1 for the offset
920-
Assert.AreEqual(result.contextData.resources.MaxReaders, 4);
920+
Assert.AreEqual(result.contextData.resources.MaxReaders[(int)RenderGraphResourceType.Texture], 4);
921921

922922
// The resource with the biggest MaxVersion is extraBuffers[0]:
923923
// 1 explicit write (TestPass0) + 1 explicit read-write (TestPass1) + 1 for the offset
924-
Assert.AreEqual(result.contextData.resources.MaxVersions, 3);
924+
Assert.AreEqual(result.contextData.resources.MaxVersions[(int)RenderGraphResourceType.Texture], 3);
925925
}
926926

927927
[Test]
@@ -959,11 +959,88 @@ public void MaxReadersAndMaxVersionsAreCorrectForBuffersMultiplePasses()
959959

960960
// The resource with the biggest MaxReaders is buffer2:
961961
// 5 implicit read (TestPass0-2-4-6-8) + 5 explicit read (TestPass1-3-5-7-9) + 1 for the offset.
962-
Assert.AreEqual(result.contextData.resources.MaxReaders, 11);
962+
Assert.AreEqual(result.contextData.resources.MaxReaders[(int)RenderGraphResourceType.Buffer], 11);
963963

964964
// The resource with the biggest MaxVersion is buffer2:
965965
// 5 explicit write (TestPass0-2-4-6-8) + 5 explicit readwrite (TestPass1-3-5-7-9) + 1 for the offset
966-
Assert.AreEqual(result.contextData.resources.MaxVersions, 11);
966+
Assert.AreEqual(result.contextData.resources.MaxVersions[(int)RenderGraphResourceType.Buffer], 11);
967+
}
968+
969+
[Test]
970+
public void ResourcesData_MaxReadersAndVersionsPerResourceType()
971+
{
972+
var g = AllocateRenderGraph();
973+
var renderTargets = ImportAndCreateBuffers(g);
974+
975+
var desc = new BufferDesc(1024, 16);
976+
var buffer = g.CreateBuffer(desc);
977+
978+
int indexName = 0;
979+
980+
// TEXTURE PASSES: Create 2 versions with different reader counts
981+
// Texture Pass 0: Create version 1 of extraBuffers[0] (ReadWrite = 1 write + 1 implicit read)
982+
using (var builder = g.AddRasterRenderPass<RenderGraphTestPassData>("TestPassTexture" + indexName++, out var passData))
983+
{
984+
builder.AllowPassCulling(false);
985+
builder.SetRenderAttachment(renderTargets.extraBuffers[0], 0, AccessFlags.ReadWrite);
986+
builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext context) => { });
987+
}
988+
// Texture Pass 1: Create version 2 of extraBuffers[0] (ReadWrite = 1 write + 1 explicit read of version 1)
989+
using (var builder = g.AddRasterRenderPass<RenderGraphTestPassData>("TestPassTexture" + indexName++, out var passData))
990+
{
991+
builder.AllowPassCulling(false);
992+
builder.SetRenderAttachment(renderTargets.extraBuffers[0], 0, AccessFlags.ReadWrite);
993+
builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext context) => { });
994+
}
995+
996+
// BUFFER PASSES: Create many versions to test higher reader/version counts
997+
indexName = 0;
998+
for (int i = 0; i < 5; ++i)
999+
{
1000+
// Buffer Pass (Write): Creates version N (1 write + 1 implicit read from previous version)
1001+
using (var builder = g.AddRasterRenderPass<RenderGraphTestPassData>("TestPassBuffer" + indexName++, out var passData))
1002+
{
1003+
builder.AllowPassCulling(false);
1004+
builder.UseBufferRandomAccess(buffer, 0, AccessFlags.Write);
1005+
builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext context) => { });
1006+
}
1007+
// Buffer Pass (ReadWrite): Creates version N+1 (1 write + 1 explicit read from version N)
1008+
using (var builder = g.AddRasterRenderPass<RenderGraphTestPassData>("TestPassBuffer" + indexName++, out var passData))
1009+
{
1010+
builder.AllowPassCulling(false);
1011+
builder.UseBufferRandomAccess(buffer, 0, AccessFlags.ReadWrite);
1012+
builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext context) => { });
1013+
}
1014+
}
1015+
1016+
var result = g.CompileNativeRenderGraph(g.ComputeGraphHash());
1017+
var passes = result.contextData.GetNativePasses();
1018+
1019+
// VERIFY: MaxReaders and MaxVersions are calculated PER RESOURCE TYPE
1020+
// TEXTURE TYPE:
1021+
// 2 readwrite operations = 2 versions + 1 offset = 3 versions/readers.
1022+
Assert.AreEqual(result.contextData.resources.MaxReaders[(int)RenderGraphResourceType.Texture], 3);
1023+
Assert.AreEqual(result.contextData.resources.MaxVersions[(int)RenderGraphResourceType.Texture], 3);
1024+
1025+
// BUFFER TYPE:
1026+
// 5 write operations + 5 readwrite operations = 10 versions + 1 offset = 11 versions/readers.
1027+
Assert.AreEqual(result.contextData.resources.MaxReaders[(int)RenderGraphResourceType.Buffer], 11);
1028+
Assert.AreEqual(result.contextData.resources.MaxVersions[(int)RenderGraphResourceType.Buffer], 11);
1029+
1030+
// VERIFY: Index calculations work correctly with per-type maximums
1031+
// Get the texture handle from the first native pass attachment
1032+
var textureHandle = passes[0].attachments[0].handle;
1033+
Assert.AreEqual(renderTargets.extraBuffers[0].handle.index, passes[0].attachments[0].handle.index);
1034+
1035+
// Test Index() calculation uses correct MaxVersions for texture type
1036+
int indexExpected = textureHandle.index * result.contextData.resources.MaxVersions[(int)RenderGraphResourceType.Texture] + textureHandle.version;
1037+
Assert.AreEqual(result.contextData.resources.Index(textureHandle), indexExpected);
1038+
Assert.IsTrue(indexExpected < result.contextData.resources.versionedData[(int)RenderGraphResourceType.Texture].Capacity);
1039+
1040+
// Test IndexReader() calculation uses correct MaxReaders for texture type
1041+
int indexReaderExpected = indexExpected * result.contextData.resources.MaxReaders[(int)RenderGraphResourceType.Texture] + 0;
1042+
Assert.AreEqual(result.contextData.resources.IndexReader(textureHandle, 0), indexReaderExpected);
1043+
Assert.IsTrue(indexExpected < result.contextData.resources.readerData[(int)RenderGraphResourceType.Texture].Capacity);
9671044
}
9681045

9691046
[Test]
@@ -1206,7 +1283,7 @@ public void ChangingGlobalStateDisablesCulling()
12061283

12071284
Assert.IsTrue(firstNativePass.numGraphPasses == 2);
12081285
}
1209-
1286+
12101287
[Test]
12111288
public void GraphPassesDoesNotAlloc()
12121289
{
@@ -1300,7 +1377,7 @@ public void UpdateSubpassAttachmentIndices_WhenDepthAttachmentIsAdded()
13001377
builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext context) => { });
13011378
builder.AllowPassCulling(false);
13021379
}
1303-
1380+
13041381
// Render Pass
13051382
// attachments: [extraBuffers[0], extraBuffers[1]]
13061383
// subpass 0: color outputs : [0]

Packages/com.unity.render-pipelines.high-definition/Documentation~/canvas-master-stack-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ The following table describes the Surface options:
6262

6363
[!include[](snippets/shader-properties/surface-options/material-type.md)]
6464
[!include[](snippets/shader-properties/surface-options/alpha-clipping.md)]
65-
65+
[!include[](snippets/shader-properties/surface-options/disable-color-tint.md)]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<tr>
2+
<td><strong>Disable Color Tint</strong></td>
3+
<td>N/A</td>
4+
<td>N/A</td>
5+
<td>Prevents Shader Graph tinting the texture with the color of the UI element. If you enable this setting, use a [Vertex Color Node](https://docs.unity3d.com/Packages/com.unity.shadergraph@latest/index.html?preview=1&subfolder=/manual/Vertex-Color-Node.html) to access the color of the UI element.</td>
6+
</tr>

Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ public class Styles
350350
public static readonly GUIContent volumeProfileLabel = EditorGUIUtility.TrTextContent("Volume Profile", "Settings that will override the values defined in the Default Volume Profile set in the Render Pipeline Global settings. Local Volumes inside scenes may override these settings further.");
351351
public static System.Lazy<GUIStyle> volumeProfileContextMenuStyle = new(() => new GUIStyle(CoreEditorStyles.contextMenuStyle) { margin = new RectOffset(0, 1, 3, 0) });
352352

353-
public static readonly GUIContent[] shadowBitDepthNames = { new GUIContent("32 bit"), new GUIContent("16 bit") };
354-
public static readonly int[] shadowBitDepthValues = { (int)DepthBits.Depth32, (int)DepthBits.Depth16 };
353+
public static readonly GUIContent[] shadowBitDepthNames = { new GUIContent("32 bit"), new GUIContent("16 bit"), new GUIContent("24 bit") };
354+
public static readonly int[] shadowBitDepthValues = { (int)DepthBits.Depth32, (int)DepthBits.Depth16, (int)DepthBits.Depth24 };
355355

356356
public static readonly GUIContent gpuResidentDrawerMode = EditorGUIUtility.TrTextContent("GPU Resident Drawer", "Enables draw submission through the GPU Resident Drawer, which can improve CPU performance");
357357
public static readonly GUIContent smallMeshScreenPercentage = EditorGUIUtility.TrTextContent("Small-Mesh Screen-Percentage", "Default minimum screen percentage (0-20%) gpu-driven Renderers can cover before getting culled. If a Renderer is part of a LODGroup, this will be ignored.");

0 commit comments

Comments
 (0)