Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal/6000.0/staging #8117

Merged
merged 21 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6abd789
[Port] [6000.0] Fix the RenderGraphPass clear function not working c…
svc-reach-platform-support Nov 28, 2024
b1c5f69
[Port] [6000.0] RenderGraph - Improve maximum number of resources all…
svc-reach-platform-support Nov 28, 2024
a3f2a42
[Port] [6000.0] [UUM-83862] Fix sorting the Reflection Probe by resol…
svc-reach-platform-support Nov 29, 2024
9b4f488
[Port] [6000.0] [UUM-73635] Fix debug rendering error when rebaking A…
svc-reach-platform-support Dec 3, 2024
15f15e7
Backports (56114 & 56734)
venkify Dec 3, 2024
3af9ddd
[Port] [6000.0] Fix for avoid warnings when using the NormalFromTextu…
svc-reach-platform-support Dec 3, 2024
5991afb
[Port] [6000.0] Fix STP on GLCore Rendering Target
svc-reach-platform-support Dec 3, 2024
4074ae1
[Port] [6000.0] Add clamp to HairAngleWorld to prevent nan from FastASin
svc-reach-platform-support Dec 4, 2024
ebec57a
[Port] [6000.0] Fixed layer index out of range in LayeredLitGUI
svc-reach-platform-support Dec 5, 2024
53257d5
[Backport 6000.0][UUM-86922][UUM-83351] Fix clear flags when post pro…
kennytann Dec 5, 2024
2adf9bf
[VFX][Backport][6000.0] In some specific circumstances, an exception …
julienamsellem Dec 5, 2024
ba276f9
Disable unstable test
ericksson Dec 5, 2024
1bcdd7f
[Port] [6000.0] [UUM-73947] Added SS Shadow coord transform to Transf…
svc-reach-platform-support Dec 6, 2024
1452a04
Backports.
venkify Dec 6, 2024
57ee1a5
[Port] [6000.0] [VFX] Added support for CustomRenderTexture in our ob…
svc-reach-platform-support Dec 6, 2024
bd8787c
[Port] [6000.0] [VFX] Add a button to install learning templates
svc-reach-platform-support Dec 7, 2024
09fff90
[Port] [6000.0] [HDRP] Adding cave scene in water samples
svc-reach-platform-support Dec 10, 2024
5e74e3d
[Port] [6000.0] Fix Implicit RandomWrite Requirement for Compute Shaders
svc-reach-platform-support Dec 16, 2024
90c8d90
[Port] [6000.0] [SRP][Volume]Multiple fixes for being able to properl…
svc-reach-platform-support Dec 16, 2024
28a60a1
[Port] [6000.0] HDRP Wizard FixAll button hide when no fix available
svc-reach-platform-support Dec 16, 2024
ad407bb
[Backport] [6000.0] Backport Nov 2024 graphics feedback fixes to 6000.0
markg-unity Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This page covers the process of how to use the RenderGraph API to write a render
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.

```c#
using UnityEngine.Rendering;
using UnityEngine.Rendering.RenderGraphModule;

public class MyRenderPipeline : RenderPipeline
Expand All @@ -21,8 +22,11 @@ public class MyRenderPipeline : RenderPipeline
void CleanupRenderGraph()
{
m_RenderGraph.Cleanup();
m_RenderGraph = null;
m_RenderGraph = null;
}

...

}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,23 @@ protected void CreateDefaultVolumeProfileEditor()
}
m_EditorContainer.Add(s_DefaultVolumeProfileEditor.Create());
m_EditorContainer.Q<HelpBox>("volume-override-info-box").text = volumeInfoBoxLabel.text;

if (m_DefaultVolumeProfileFoldoutExpanded.value)
m_EditorContainer.style.display = DisplayStyle.Flex;
}

/// <summary>
/// Destroys the Default Volume Profile editor.
/// </summary>
protected void DestroyDefaultVolumeProfileEditor()
{
m_EditorContainer.style.display = DisplayStyle.None;
m_EditorContainer?.Clear();

if (s_DefaultVolumeProfileEditor != null)
s_DefaultVolumeProfileEditor.Destroy();
s_DefaultVolumeProfileEditor = null;
s_DefaultVolumeProfileSerializedProperty = null;
m_EditorContainer?.Clear();
}

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

void IRenderPipelineGraphicsSettingsContextMenu<TSetting>.PopulateContextMenu(TSetting setting, PropertyDrawer _, ref GenericMenu menu)
{
menu.AddSeparator("");

bool canCreateNewAsset = RenderPipelineManager.currentPipeline is TRenderPipeline;
VolumeProfileUtils.AddVolumeProfileContextMenuItems(ref menu,
setting.volumeProfile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ public static void EnsureAllOverridesForDefaultProfile(VolumeProfile profile, Vo
{
VolumeManager.instance.OnVolumeProfileChanged(profile);
EditorUtility.SetDirty(profile);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,9 @@ CellInstancedDebugProbes CreateInstancedProbes(Cell cell)
if (cell.debugProbes != null)
return cell.debugProbes;

if (HasActiveStreamingRequest(cell))
return null;

int maxSubdiv = GetMaxSubdivision() - 1;

if (!cell.data.bricks.IsCreated || cell.data.bricks.Length == 0 || !cell.data.probePositions.IsCreated || !cell.loaded)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,11 @@ void UpdateDiskStreaming(CommandBuffer cmd)
}
}

bool HasActiveStreamingRequest(Cell cell)
{
return diskStreamingEnabled && m_ActiveStreamingRequests.Exists(x => x.cell == cell);
}

[Conditional("UNITY_EDITOR")]
[Conditional("DEVELOPMENT_BUILD")]
void LogStreaming(string log)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public ref ResourceVersionedData VersionedResourceData(ResourceHandle h)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ReadOnlySpan<ResourceReaderData> Readers(ResourceHandle h)
{
int firstReader = ResourcesData.IndexReader(h, 0);
int firstReader = resources.IndexReader(h, 0);
int numReaders = resources[h].numReaders;
return resources.readerData[h.iType].MakeReadOnlySpan(firstReader, numReaders);
}
Expand All @@ -114,7 +114,7 @@ public ref ResourceReaderData ResourceReader(ResourceHandle h, int i)
throw new Exception("Invalid reader id");
}
#endif
return ref resources.readerData[h.iType].ElementAt(ResourcesData.IndexReader(h, 0) + i);
return ref resources.readerData[h.iType].ElementAt(resources.IndexReader(h, 0) + i);
}

// Data per graph level renderpass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ internal void GenerateNativeCompilerDebugData(ref RenderGraph.DebugData debugDat
var numReaders = outputDataVersioned.numReaders;
for (var i = 0; i < numReaders; ++i)
{
var depIdx = ResourcesData.IndexReader(output.resource, i);
var depIdx = ctx.resources.IndexReader(output.resource, i);
ref var dep = ref ctx.resources.readerData[output.resource.iType].ElementAt(depIdx);

var outputDependencyPass = ctx.passData[dep.passId];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ void FindResourceUsageRanges()
var numReaders = pointToVer.numReaders;
for (var i = 0; i < numReaders; ++i)
{
var depIdx = ResourcesData.IndexReader(outputResource, i);
var depIdx = ctx.resources.IndexReader(outputResource, i);
ref var dep = ref ctx.resources.readerData[outputResource.iType].ElementAt(depIdx);
ref var depPass = ref ctx.passData.ElementAt(dep.passId);
if (pass.asyncCompute != depPass.asyncCompute)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ public void SetWritingPass(CompilerContextData ctx, ResourceHandle h, int passId
public void RegisterReadingPass(CompilerContextData ctx, ResourceHandle h, int passId, int index)
{
#if DEVELOPMENT_BUILD || UNITY_EDITOR
if (numReaders >= ResourcesData.MaxReaders)
if (numReaders >= ctx.resources.MaxReaders)
{
string passName = ctx.GetPassName(passId);
string resourceName = ctx.GetResourceName(h);
throw new Exception($"Maximum '{ResourcesData.MaxReaders}' passes can use a single graph output as input. Pass {passName} is trying to read {resourceName}.");
throw new Exception($"Maximum '{ctx.resources.MaxReaders}' passes can use a single graph output as input. Pass {passName} is trying to read {resourceName}.");
}
#endif
ctx.resources.readerData[h.iType][ResourcesData.IndexReader(h, numReaders)] = new ResourceReaderData
ctx.resources.readerData[h.iType][ctx.resources.IndexReader(h, numReaders)] = new ResourceReaderData
{
passId = passId,
inputSlot = index
Expand All @@ -167,13 +167,13 @@ public void RemoveReadingPass(CompilerContextData ctx, ResourceHandle h, int pas
{
for (int r = 0; r < numReaders;)
{
ref var reader = ref ctx.resources.readerData[h.iType].ElementAt(ResourcesData.IndexReader(h, r));
ref var reader = ref ctx.resources.readerData[h.iType].ElementAt(ctx.resources.IndexReader(h, r));
if (reader.passId == passId)
{
// It should be removed, switch with the end of the list if we're not already at the end of it
if (r < numReaders - 1)
{
reader = ctx.resources.readerData[h.iType][ResourcesData.IndexReader(h, numReaders - 1)];
reader = ctx.resources.readerData[h.iType][ctx.resources.IndexReader(h, numReaders - 1)];
}

numReaders--;
Expand All @@ -193,8 +193,9 @@ internal class ResourcesData
public NativeList<ResourceUnversionedData>[] unversionedData; // Flattened fixed size array storing info per resource id shared between all versions.
public NativeList<ResourceVersionedData>[] versionedData; // Flattened fixed size array storing up to MaxVersions versions per resource id.
public NativeList<ResourceReaderData>[] readerData; // Flattened fixed size array storing up to MaxReaders per resource id per version.
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.
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.

public int MaxVersions;
public int MaxReaders;

public DynamicArray<Name>[] resourceNames;

Expand Down Expand Up @@ -229,6 +230,9 @@ public void Clear()

public void Initialize(RenderGraphResourceRegistry resources)
{
uint maxReaders = 0;
uint maxWriters = 0;

for (int t = 0; t < (int)RenderGraphResourceType.Count; t++)
{
RenderGraphResourceType resourceType = (RenderGraphResourceType) t;
Expand Down Expand Up @@ -287,8 +291,15 @@ public void Initialize(RenderGraphResourceRegistry resources)
default:
throw new Exception("Unsupported resource type: " + t);
}

maxReaders = Math.Max(maxReaders, rll.readCount);
maxWriters = Math.Max(maxWriters, rll.writeCount);
}

// The first resource is a null resource, so we need to add 1 to the count.
MaxReaders = (int)maxReaders + 1;
MaxVersions = (int)maxWriters + 1;

// Clear the other caching structures, they will be filled later
versionedData[t].Resize(MaxVersions * numResources, NativeArrayOptions.ClearMemory);
readerData[t].Resize(MaxVersions * MaxReaders * numResources, NativeArrayOptions.ClearMemory);
Expand All @@ -297,7 +308,7 @@ public void Initialize(RenderGraphResourceRegistry resources)

// Flatten array index
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int Index(ResourceHandle h)
public int Index(ResourceHandle h)
{
#if UNITY_EDITOR // Hot path
if (h.version < 0 || h.version >= MaxVersions)
Expand All @@ -308,7 +319,7 @@ public static int Index(ResourceHandle h)

// Flatten array index
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int IndexReader(ResourceHandle h, int readerID)
public int IndexReader(ResourceHandle h, int readerID)
{
#if UNITY_EDITOR // Hot path
if (h.version < 0 || h.version >= MaxVersions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ private ResourceHandle UseResource(in ResourceHandle handle, AccessFlags flags,
}

m_RenderPass.AddResourceRead(versioned);
m_Resources.IncrementReadCount(handle);

if ((flags & AccessFlags.Read) == 0)
{
Expand All @@ -232,6 +233,7 @@ private ResourceHandle UseResource(in ResourceHandle handle, AccessFlags flags,
if ((flags & AccessFlags.Read) != 0)
{
m_RenderPass.AddResourceRead(m_Resources.GetZeroVersionedHandle(handle));
m_Resources.IncrementReadCount(handle);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ public void Clear()
colorBufferMaxIndex = -1;
fragmentInputMaxIndex = -1;
randomAccessResourceMaxIndex = -1;

// We do not need to clear colorBufferAccess and fragmentInputAccess as we have the colorBufferMaxIndex and fragmentInputMaxIndex
// which are reset above so we only clear depthAccess here.
depthAccess = default(TextureAccess);
}

// Check if the pass has any render targets set-up
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ internal void IncrementWriteCount(in ResourceHandle res)
m_RenderGraphResources[res.iType].resourceArray[res.index].IncrementWriteCount();
}

internal void IncrementReadCount(in ResourceHandle res)
{
CheckHandleValidity(res);
m_RenderGraphResources[res.iType].resourceArray[res.index].IncrementReadCount();
}

internal void NewVersion(in ResourceHandle res)
{
CheckHandleValidity(res);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class IRenderGraphResource
public bool requestFallBack;
public bool forceRelease;
public uint writeCount;
public uint readCount;
public int cachedHash;
public int transientPassIndex;
public int sharedResourceLastFrameUsed;
Expand All @@ -145,6 +146,7 @@ public virtual void Reset(IRenderGraphResourcePool _ = null)
requestFallBack = false;
forceRelease = false;
writeCount = 0;
readCount = 0;
version = 0;
}

Expand All @@ -166,6 +168,13 @@ public virtual void IncrementWriteCount()
writeCount++;
}

// readCount is currently not used in the HDRP Compiler.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public virtual void IncrementReadCount()
{
readCount++;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public virtual int NewVersion()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#pragma multi_compile _ DISABLE_TEXTURE2D_X_ARRAY

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch glcore

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#pragma multi_compile _ DISABLE_TEXTURE2D_X_ARRAY

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch glcore

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
Expand Down Expand Up @@ -395,7 +395,14 @@ StpF2 StpPatDatMotH(StpW2 o) { return LOAD_TEXTURE2D_X_LOD(_StpInputMotion, o, 0
StpH3 StpPatDatColH(StpW2 o) { return (StpH3)LOAD_TEXTURE2D_X_LOD(_StpInputColor, o, 0).rgb; }
StpF1 StpPatDatZH(StpW2 o) { return LOAD_TEXTURE2D_X_LOD(_StpInputDepth, o, 0).x; }
// This provides a place to convert Z from depth to linear if not inlined and actually loaded.
StpF1 StpPatFixZH(StpF1 z) { return 1.0 / (STP_ZBUFFER_PARAMS_Z * z + STP_ZBUFFER_PARAMS_W); }
StpF1 StpPatFixZH(StpF1 z)
{
#if !UNITY_REVERSED_Z
// Reverse Z if necessary as STP expects reversed Z input
z = 1.0 - z;
#endif
return 1.0 / (STP_ZBUFFER_PARAMS_Z * z + STP_ZBUFFER_PARAMS_W);
}
StpU1 StpPatDatRH(StpW2 o) {
#if defined(ENABLE_STENCIL_RESPONSIVE)
return GetStencilValue(LOAD_TEXTURE2D_X_LOD(_StpInputStencil, o, 0).xy);
Expand Down Expand Up @@ -432,7 +439,14 @@ StpF2 StpPatDatMotF(StpMU2 o) { return LOAD_TEXTURE2D_X_LOD(_StpInputMotion, o,
StpMF3 StpPatDatColF(StpMU2 o) { return (StpMF3)LOAD_TEXTURE2D_X_LOD(_StpInputColor, o, 0).rgb; }
StpF1 StpPatDatZF(StpMU2 o) { return LOAD_TEXTURE2D_X_LOD(_StpInputDepth, o, 0).x; }
// This provides a place to convert Z from depth to linear if not inlined and actually loaded.
StpF1 StpPatFixZF(StpF1 z) { return 1.0 / (STP_ZBUFFER_PARAMS_Z * z + STP_ZBUFFER_PARAMS_W); }
StpF1 StpPatFixZF(StpF1 z)
{
#if !UNITY_REVERSED_Z
// Reverse Z if necessary as STP expects reversed Z input
z = 1.0 - z;
#endif
return 1.0 / (STP_ZBUFFER_PARAMS_Z * z + STP_ZBUFFER_PARAMS_W);
}
StpU1 StpPatDatRF(StpMU2 o) {
#if defined(ENABLE_STENCIL_RESPONSIVE)
return GetStencilValue(LOAD_TEXTURE2D_X_LOD(_StpInputStencil, o, 0).xy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#pragma multi_compile _ DISABLE_TEXTURE2D_X_ARRAY

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch glcore

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
Expand Down
Loading
Loading