Skip to content

Commit a65be2c

Browse files
authored
Merge pull request #8111 from Unity-Technologies/internal/6000.0/staging
Internal/6000.0/staging
2 parents 6a723ff + bff5f11 commit a65be2c

File tree

105 files changed

+4382
-441
lines changed

Some content is hidden

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

105 files changed

+4382
-441
lines changed

Packages/com.unity.render-pipelines.core/Documentation~/custom-material-inspector.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Custom Material Inspectors enable you to define how Unity displays properties in
66

77
The implementation for custom Material Inspectors differs between URP and HDRP. For example, for compatibility purposes, every custom Material Inspector in HDRP must inherit from `HDShaderGUI` which does not exist in URP. For information on how to create custom Material Inspectors for the respective render pipelines, see:
88

9-
- **HDRP**: [HDRP custom Material Inspectors](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest?subfolder=/manual/hdrp-custom-material-inspector.html).
9+
- **HDRP**: [HDRP custom Material Inspectors](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest?subfolder=/manual/custom-material-inspectors.html).
1010
- **URP**: [Unity Custom Shader GUI](https://docs.unity3d.com/Manual/SL-CustomShaderGUI.html).
1111

1212
## Assigning a custom Material Inspector

Packages/com.unity.render-pipelines.core/Documentation~/render-graph-writing-a-render-pipeline.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class MyRenderPipeline : RenderPipeline
1515

1616
void InitializeRenderGraph()
1717
{
18-
m_RenderGraph = new RenderGraph(MyRenderGraph);
18+
m_RenderGraph = new RenderGraph("MyRenderGraph");
1919
}
2020

2121
void CleanupRenderGraph()

Packages/com.unity.render-pipelines.core/Editor/HeaderFoldout.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,15 @@ public HeaderFoldout() : base()
7777
m_HelpButton.SetEnabled(!string.IsNullOrEmpty(m_DocumentationURL));
7878
line.Add(m_HelpButton);
7979

80-
m_ContextMenuButton = new Button(Background.FromTexture2D(CoreEditorStyles.paneOptionsIcon), () => ShowMenu());
80+
m_ContextMenuButton =
81+
new Button(Background.FromTexture2D(CoreEditorStyles.paneOptionsIcon), () => ShowMenu())
82+
{
83+
style =
84+
{
85+
paddingRight = 2
86+
}
87+
};
88+
8189
m_ContextMenuButton.SetEnabled(m_ContextMenuGenerator != null);
8290
line.Add(m_ContextMenuButton);
8391

Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/DynamicGI/DynamicGISkyOcclusion.urtshader

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal
1+
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal webgpu
22
#define UNIFIED_RT_GROUP_SIZE_X 64
33
#define UNIFIED_RT_GROUP_SIZE_Y 1
44

Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeCellDilation.compute

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma kernel DilateCell
22

3-
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
3+
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch webgpu
44

55
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
66
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl"

Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeSubdivide.compute

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#pragma kernel VoxelizeProbeVolumeData
77
#pragma kernel Subdivide
88

9-
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
9+
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch webgpu
1010

1111
// #pragma enable_d3d11_debug_symbols
1212

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal
1+
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal webgpu switch
22
#define UNIFIED_RT_GROUP_SIZE_X 64
33
#define UNIFIED_RT_GROUP_SIZE_Y 1
44

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

+38-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using UnityEditor.UIElements;
44
using UnityEditorInternal;
@@ -122,7 +122,37 @@ bool IsSearchFilterMatch(string str, string searchString, out int startIndex, ou
122122
return true;
123123
}
124124

125+
private IVisualElementScheduledItem m_PreviousSearch;
126+
private string m_PendingSearchString = string.Empty;
127+
private const int k_SearchStringLimit = 15;
125128
void OnSearchFilterChanged(Dictionary<VisualElement, List<TextElement>> elementCache, string searchString)
129+
{
130+
// Ensure the search string is within the allowed length limit (15 chars max)
131+
if (searchString.Length > k_SearchStringLimit)
132+
{
133+
searchString = searchString[..k_SearchStringLimit]; // Trim to max 15 chars
134+
Debug.LogWarning("[Render Graph Viewer] Search string limit exceeded: " + k_SearchStringLimit);
135+
}
136+
137+
// If the search string hasn't changed, avoid repeating the same search
138+
if (m_PendingSearchString == searchString)
139+
return;
140+
141+
m_PendingSearchString = searchString;
142+
143+
if (m_PreviousSearch != null && m_PreviousSearch.isActive)
144+
m_PreviousSearch.Pause();
145+
146+
m_PreviousSearch = rootVisualElement
147+
.schedule
148+
.Execute(() =>
149+
{
150+
PerformSearchAsync(elementCache, searchString);
151+
})
152+
.StartingIn(5); // Avoid spamming multiple search if the user types really fast
153+
}
154+
155+
private void PerformSearchAsync(Dictionary<VisualElement, List<TextElement>> elementCache, string searchString)
126156
{
127157
// Display filter
128158
foreach (var (foldout, descendants) in elementCache)
@@ -362,8 +392,12 @@ void CreateTextElement(VisualElement parent, string text, string className = nul
362392
{
363393
var attachmentFoldout = new Foldout();
364394

395+
string subResourceText = string.Empty;
396+
if (attachmentInfo.attachment.mipLevel > 0) subResourceText += $" Mip:{attachmentInfo.attachment.mipLevel}";
397+
if (attachmentInfo.attachment.depthSlice > 0) subResourceText += $" Slice:{attachmentInfo.attachment.depthSlice}";
398+
365399
// Abuse Foldout to allow two-line header (same as above)
366-
attachmentFoldout.text = $"<b>{attachmentInfo.resourceName}</b><br>";
400+
attachmentFoldout.text = $"<b>{attachmentInfo.resourceName + subResourceText}</b><br>";
367401
Label attachmentIndexLabel = new Label($"<br>Attachment #{attachmentInfo.attachmentIndex}");
368402
attachmentIndexLabel.AddToClassList(Classes.kInfoFoldoutSecondaryText);
369403

@@ -384,13 +418,13 @@ void CreateTextElement(VisualElement parent, string text, string className = nul
384418

385419
attachmentFoldout.Add(new TextElement
386420
{
387-
text = $"<b>Load action:</b> {attachmentInfo.loadAction}\n- {attachmentInfo.loadReason}"
421+
text = $"<b>Load action:</b> {attachmentInfo.attachment.loadAction}\n- {attachmentInfo.loadReason}"
388422
});
389423

390424
bool addMsaaInfo = !string.IsNullOrEmpty(attachmentInfo.storeMsaaReason);
391425
string resolvedTexturePrefix = addMsaaInfo ? "Resolved surface: " : "";
392426

393-
string storeActionText = $"<b>Store action:</b> {attachmentInfo.storeAction}" +
427+
string storeActionText = $"<b>Store action:</b> {attachmentInfo.attachment.storeAction}" +
394428
$"\n - {resolvedTexturePrefix}{attachmentInfo.storeReason}";
395429

396430
if (addMsaaInfo)

Packages/com.unity.render-pipelines.core/Runtime/Debug/ProbeVolumeDebugBase.hlsl

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ float GetCurrentExposureMultiplier()
3535
return LOAD_TEXTURE2D(_ExposureTexture, int2(0, 0)).x;
3636
}
3737

38+
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureXR.hlsl"
3839
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl"
3940
#include "Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/DecodeSH.hlsl"
4041
#include "Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.hlsl"
@@ -267,6 +268,7 @@ bool ShouldCull(inout v2f o)
267268
bool shouldCull = false;
268269
if (distance(position.xyz + _APVWorldOffset, GetCurrentViewPosition()) > _CullDistance || brickSize > _MaxAllowedSubdiv || brickSize < _MinAllowedSubdiv)
269270
{
271+
ZERO_INITIALIZE(v2f, o);
270272
DoCull(o);
271273
shouldCull = true;
272274
}

Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceData/InstanceDataSystem.Jobs.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ private unsafe struct ProbesUpdateJob : IJobParallelForBatch
379379
{
380380
public const int k_BatchSize = 64;
381381

382-
[ReadOnly] public bool initialize;
383382
[NativeDisableContainerSafetyRestriction, NoAlias][ReadOnly] public NativeArray<InstanceHandle> instances;
384383
[NativeDisableParallelForRestriction][NativeDisableContainerSafetyRestriction, NoAlias] public CPUInstanceData instanceData;
385384
[ReadOnly] public CPUSharedInstanceData sharedInstanceData;
@@ -403,11 +402,6 @@ public void Execute(int startIndex, int count)
403402

404403
int sharedInstanceIndex = sharedInstanceData.InstanceToIndex(instanceData, instance);
405404
TransformUpdateFlags flags = sharedInstanceData.flags[sharedInstanceIndex].transformUpdateFlags;
406-
bool isStaticObject = (flags & TransformUpdateFlags.IsPartOfStaticBatch) != 0;
407-
408-
if (!initialize && isStaticObject)
409-
continue;
410-
411405
bool hasLightProbe = (flags & TransformUpdateFlags.HasLightProbeCombined) != 0;
412406

413407
if (!hasLightProbe)
@@ -976,7 +970,7 @@ public void Execute(int index)
976970
instanceData.editorData.selectedBits.Set(instanceData.InstanceToIndex(instance), true);
977971
}
978972
}
979-
973+
980974
#endif
981975
}
982976
}

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

-2
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ private unsafe void UpdateInstanceTransformsData(bool initialize, NativeArray<In
351351

352352
var probesJob = new ProbesUpdateJob()
353353
{
354-
initialize = initialize,
355354
instances = instances,
356355
instanceData = m_InstanceData,
357356
sharedInstanceData = m_SharedInstanceData,
@@ -402,7 +401,6 @@ private unsafe void UpdateInstanceProbesData(NativeArray<InstanceHandle> instanc
402401

403402
new ProbesUpdateJob()
404403
{
405-
initialize = false,
406404
instances = instances,
407405
instanceData = m_InstanceData,
408406
sharedInstanceData = m_SharedInstanceData,

Packages/com.unity.render-pipelines.core/Runtime/PostProcessing/LensFlareCommonSRP.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1707,7 +1707,7 @@ static public void DoLensFlareDataDrivenCommon(Material lensFlareShader, Camera
17071707
Vector2 occlusionRadiusEdgeScreenPos1 = (Vector2)WorldToViewport(cam, !isDirLight, isCameraRelative, viewProjMatrix, positionWS + cam.transform.up * adjustedOcclusionRadius);
17081708
float occlusionRadius = (occlusionRadiusEdgeScreenPos1 - occlusionRadiusEdgeScreenPos0).magnitude;
17091709

1710-
if (comp.useOcclusion)
1710+
if (comp.useOcclusion && occlusionRT != null)
17111711
{
17121712
cmd.SetGlobalTexture(_FlareOcclusionTex, occlusionRT);
17131713
cmd.EnableShaderKeyword("FLARE_HAS_OCCLUSION");

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ static RenderGraph.DebugData.PassData.NRPInfo.NativeRenderPassInfo.AttachmentInf
3636
{
3737
resourceName = pointTo.GetName(ctx, attachment.handle),
3838
attachmentIndex = attachmentIndex,
39-
loadAction = attachment.loadAction.ToString(),
4039
loadReason = loadReason,
41-
storeAction = attachment.storeAction.ToString(),
4240
storeReason = storeReason,
43-
storeMsaaReason = storeMsaaReason
41+
storeMsaaReason = storeMsaaReason,
42+
attachment = attachment
4443
};
4544
}
4645

@@ -207,6 +206,8 @@ internal void GenerateNativeCompilerDebugData(ref RenderGraph.DebugData debugDat
207206
debugResource.textureData.depth = resourceUnversioned.volumeDepth;
208207
debugResource.textureData.samples = resourceUnversioned.msaaSamples;
209208
debugResource.textureData.format = info.format;
209+
debugResource.textureData.bindMS = resourceUnversioned.bindMS;
210+
debugResource.textureData.clearBuffer = resourceUnversioned.clear;
210211
debugResource.memoryless = resourceUnversioned.memoryLess;
211212

212213
debugResource.consumerList = new List<int>();
@@ -240,7 +241,7 @@ internal void GenerateNativeCompilerDebugData(ref RenderGraph.DebugData debugDat
240241
debugPass.resourceReadLists = new List<int>[(int)RenderGraphResourceType.Count];
241242
debugPass.resourceWriteLists = new List<int>[(int)RenderGraphResourceType.Count];
242243

243-
RenderGraph.DebugData.s_PassScriptMetadata.TryGetValue(passName, out debugPass.scriptInfo);
244+
RenderGraph.DebugData.s_PassScriptMetadata.TryGetValue(graphPass, out debugPass.scriptInfo);
244245

245246
debugPass.syncFromPassIndex = -1; // TODO async compute support
246247
debugPass.syncToPassIndex = -1; // TODO async compute support

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

+14-10
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@ public override int GetHashCode()
4040
return hash;
4141
}
4242

43-
public static bool EqualForMerge(PassFragmentData x, PassFragmentData y)
43+
// If you modify this, check if struct RenderPassSetup::Attachment in "GfxDevice\RenderPassSetup.h" also needs changes
44+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
45+
public static bool SameSubResource(in PassFragmentData x, in PassFragmentData y)
4446
{
4547
// We ignore the version for now we assume if one pass writes version x and the next y they can
4648
// be merged in the same native render pass
47-
return x.resource.index == y.resource.index && x.accessFlags == y.accessFlags && x.mipLevel == y.mipLevel && x.depthSlice == y.depthSlice;
49+
// We also do not look at the access flags as they get OR-ed together when adding subpasses to the native pass so the access flags
50+
// will always cover the required access (and thus possibly more if required by other passes)
51+
return x.resource.index == y.resource.index && x.mipLevel == y.mipLevel && x.depthSlice == y.depthSlice;
4852
}
4953
}
5054

@@ -693,7 +697,7 @@ public static PassBreakAudit CanMerge(CompilerContextData contextData, int activ
693697

694698
for (int i = 0; i < nativePass.fragments.size; ++i)
695699
{
696-
if (nativePass.fragments[i].resource.index == fragment.resource.index)
700+
if (PassFragmentData.SameSubResource(nativePass.fragments[i], fragment))
697701
{
698702
alreadyAttached = true;
699703
break;
@@ -723,7 +727,7 @@ public static PassBreakAudit CanMerge(CompilerContextData contextData, int activ
723727

724728
for (int i = 0; i < nativePass.fragments.size; ++i)
725729
{
726-
if (nativePass.fragments[i].resource.index == fragmentInput.resource.index)
730+
if (PassFragmentData.SameSubResource(nativePass.fragments[i], fragmentInput))
727731
{
728732
alreadyAttached = true;
729733
break;
@@ -816,7 +820,7 @@ static bool CanMergeNativeSubPass(CompilerContextData contextData, NativePassDat
816820
int colorAttachmentIdx = -1;
817821
for (int fragmentId = 0; fragmentId < fragmentList.size; ++fragmentId)
818822
{
819-
if (fragmentList[fragmentId].resource.index == graphPassFragment.resource.index)
823+
if (PassFragmentData.SameSubResource(fragmentList[fragmentId], graphPassFragment))
820824
{
821825
colorAttachmentIdx = fragmentId;
822826
break;
@@ -849,7 +853,7 @@ static bool CanMergeNativeSubPass(CompilerContextData contextData, NativePassDat
849853
int inputAttachmentIdx = -1;
850854
for (int fragmentId = 0; fragmentId < fragmentList.size; ++fragmentId)
851855
{
852-
if (fragmentList[fragmentId].resource.index == graphFragmentInput.resource.index)
856+
if (PassFragmentData.SameSubResource(fragmentList[fragmentId], graphFragmentInput))
853857
{
854858
inputAttachmentIdx = fragmentId;
855859
break;
@@ -928,7 +932,7 @@ public static void TryMergeNativeSubPass(CompilerContextData contextData, ref Na
928932
int colorAttachmentIdx = -1;
929933
for (int fragmentId = 0; fragmentId < fragmentList.size; ++fragmentId)
930934
{
931-
if (fragmentList[fragmentId].resource.index == graphPassFragment.resource.index)
935+
if (PassFragmentData.SameSubResource(fragmentList[fragmentId], graphPassFragment))
932936
{
933937
colorAttachmentIdx = fragmentId;
934938
break;
@@ -955,7 +959,7 @@ public static void TryMergeNativeSubPass(CompilerContextData contextData, ref Na
955959
int inputAttachmentIdx = -1;
956960
for (int fragmentId = 0; fragmentId < fragmentList.size; ++fragmentId)
957961
{
958-
if (fragmentList[fragmentId].resource.index == fragmentInput.resource.index)
962+
if (PassFragmentData.SameSubResource(fragmentList[fragmentId], fragmentInput))
959963
{
960964
inputAttachmentIdx = fragmentId;
961965
break;
@@ -1118,7 +1122,7 @@ public static PassBreakAudit TryMerge(CompilerContextData contextData, int activ
11181122
for (int i = 0; i < nativePass.fragments.size; ++i)
11191123
{
11201124
ref var existingAttach = ref nativePass.fragments[i];
1121-
if (existingAttach.resource.index == newAttach.resource.index)
1125+
if (PassFragmentData.SameSubResource(existingAttach, newAttach))
11221126
{
11231127
// Update the attached version access flags and version
11241128
existingAttach.accessFlags |= newAttach.accessFlags;
@@ -1145,7 +1149,7 @@ public static PassBreakAudit TryMerge(CompilerContextData contextData, int activ
11451149
for (int i = 0; i < nativePass.fragments.size; ++i)
11461150
{
11471151
ref var existingAttach = ref nativePass.fragments[i];
1148-
if (existingAttach.resource.index == newAttach.resource.index)
1152+
if (PassFragmentData.SameSubResource(existingAttach, newAttach))
11491153
{
11501154
// Update the attached version access flags and version
11511155
existingAttach.accessFlags |= newAttach.accessFlags;

0 commit comments

Comments
 (0)