Skip to content

Commit

Permalink
Merge pull request #8111 from Unity-Technologies/internal/6000.0/staging
Browse files Browse the repository at this point in the history
Internal/6000.0/staging
  • Loading branch information
UnityAljosha authored Dec 18, 2024
2 parents 6a723ff + bff5f11 commit a65be2c
Show file tree
Hide file tree
Showing 105 changed files with 4,382 additions and 441 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Custom Material Inspectors enable you to define how Unity displays properties in

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:

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

## Assigning a custom Material Inspector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class MyRenderPipeline : RenderPipeline

void InitializeRenderGraph()
{
m_RenderGraph = new RenderGraph(MyRenderGraph);
m_RenderGraph = new RenderGraph("MyRenderGraph");
}

void CleanupRenderGraph()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,15 @@ public HeaderFoldout() : base()
m_HelpButton.SetEnabled(!string.IsNullOrEmpty(m_DocumentationURL));
line.Add(m_HelpButton);

m_ContextMenuButton = new Button(Background.FromTexture2D(CoreEditorStyles.paneOptionsIcon), () => ShowMenu());
m_ContextMenuButton =
new Button(Background.FromTexture2D(CoreEditorStyles.paneOptionsIcon), () => ShowMenu())
{
style =
{
paddingRight = 2
}
};

m_ContextMenuButton.SetEnabled(m_ContextMenuGenerator != null);
line.Add(m_ContextMenuButton);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal webgpu
#define UNIFIED_RT_GROUP_SIZE_X 64
#define UNIFIED_RT_GROUP_SIZE_Y 1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma kernel DilateCell

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

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#pragma kernel VoxelizeProbeVolumeData
#pragma kernel Subdivide

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

// #pragma enable_d3d11_debug_symbols

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal webgpu switch
#define UNIFIED_RT_GROUP_SIZE_X 64
#define UNIFIED_RT_GROUP_SIZE_Y 1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using UnityEditor.UIElements;
using UnityEditorInternal;
Expand Down Expand Up @@ -122,7 +122,37 @@ bool IsSearchFilterMatch(string str, string searchString, out int startIndex, ou
return true;
}

private IVisualElementScheduledItem m_PreviousSearch;
private string m_PendingSearchString = string.Empty;
private const int k_SearchStringLimit = 15;
void OnSearchFilterChanged(Dictionary<VisualElement, List<TextElement>> elementCache, string searchString)
{
// Ensure the search string is within the allowed length limit (15 chars max)
if (searchString.Length > k_SearchStringLimit)
{
searchString = searchString[..k_SearchStringLimit]; // Trim to max 15 chars
Debug.LogWarning("[Render Graph Viewer] Search string limit exceeded: " + k_SearchStringLimit);
}

// If the search string hasn't changed, avoid repeating the same search
if (m_PendingSearchString == searchString)
return;

m_PendingSearchString = searchString;

if (m_PreviousSearch != null && m_PreviousSearch.isActive)
m_PreviousSearch.Pause();

m_PreviousSearch = rootVisualElement
.schedule
.Execute(() =>
{
PerformSearchAsync(elementCache, searchString);
})
.StartingIn(5); // Avoid spamming multiple search if the user types really fast
}

private void PerformSearchAsync(Dictionary<VisualElement, List<TextElement>> elementCache, string searchString)
{
// Display filter
foreach (var (foldout, descendants) in elementCache)
Expand Down Expand Up @@ -362,8 +392,12 @@ void CreateTextElement(VisualElement parent, string text, string className = nul
{
var attachmentFoldout = new Foldout();

string subResourceText = string.Empty;
if (attachmentInfo.attachment.mipLevel > 0) subResourceText += $" Mip:{attachmentInfo.attachment.mipLevel}";
if (attachmentInfo.attachment.depthSlice > 0) subResourceText += $" Slice:{attachmentInfo.attachment.depthSlice}";

// Abuse Foldout to allow two-line header (same as above)
attachmentFoldout.text = $"<b>{attachmentInfo.resourceName}</b><br>";
attachmentFoldout.text = $"<b>{attachmentInfo.resourceName + subResourceText}</b><br>";
Label attachmentIndexLabel = new Label($"<br>Attachment #{attachmentInfo.attachmentIndex}");
attachmentIndexLabel.AddToClassList(Classes.kInfoFoldoutSecondaryText);

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

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

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

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

if (addMsaaInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ float GetCurrentExposureMultiplier()
return LOAD_TEXTURE2D(_ExposureTexture, int2(0, 0)).x;
}

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureXR.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl"
#include "Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/DecodeSH.hlsl"
#include "Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.hlsl"
Expand Down Expand Up @@ -267,6 +268,7 @@ bool ShouldCull(inout v2f o)
bool shouldCull = false;
if (distance(position.xyz + _APVWorldOffset, GetCurrentViewPosition()) > _CullDistance || brickSize > _MaxAllowedSubdiv || brickSize < _MinAllowedSubdiv)
{
ZERO_INITIALIZE(v2f, o);
DoCull(o);
shouldCull = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ private unsafe struct ProbesUpdateJob : IJobParallelForBatch
{
public const int k_BatchSize = 64;

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

int sharedInstanceIndex = sharedInstanceData.InstanceToIndex(instanceData, instance);
TransformUpdateFlags flags = sharedInstanceData.flags[sharedInstanceIndex].transformUpdateFlags;
bool isStaticObject = (flags & TransformUpdateFlags.IsPartOfStaticBatch) != 0;

if (!initialize && isStaticObject)
continue;

bool hasLightProbe = (flags & TransformUpdateFlags.HasLightProbeCombined) != 0;

if (!hasLightProbe)
Expand Down Expand Up @@ -976,7 +970,7 @@ public void Execute(int index)
instanceData.editorData.selectedBits.Set(instanceData.InstanceToIndex(instance), true);
}
}

#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ private unsafe void UpdateInstanceTransformsData(bool initialize, NativeArray<In

var probesJob = new ProbesUpdateJob()
{
initialize = initialize,
instances = instances,
instanceData = m_InstanceData,
sharedInstanceData = m_SharedInstanceData,
Expand Down Expand Up @@ -402,7 +401,6 @@ private unsafe void UpdateInstanceProbesData(NativeArray<InstanceHandle> instanc

new ProbesUpdateJob()
{
initialize = false,
instances = instances,
instanceData = m_InstanceData,
sharedInstanceData = m_SharedInstanceData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,7 @@ static public void DoLensFlareDataDrivenCommon(Material lensFlareShader, Camera
Vector2 occlusionRadiusEdgeScreenPos1 = (Vector2)WorldToViewport(cam, !isDirLight, isCameraRelative, viewProjMatrix, positionWS + cam.transform.up * adjustedOcclusionRadius);
float occlusionRadius = (occlusionRadiusEdgeScreenPos1 - occlusionRadiusEdgeScreenPos0).magnitude;

if (comp.useOcclusion)
if (comp.useOcclusion && occlusionRT != null)
{
cmd.SetGlobalTexture(_FlareOcclusionTex, occlusionRT);
cmd.EnableShaderKeyword("FLARE_HAS_OCCLUSION");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ static RenderGraph.DebugData.PassData.NRPInfo.NativeRenderPassInfo.AttachmentInf
{
resourceName = pointTo.GetName(ctx, attachment.handle),
attachmentIndex = attachmentIndex,
loadAction = attachment.loadAction.ToString(),
loadReason = loadReason,
storeAction = attachment.storeAction.ToString(),
storeReason = storeReason,
storeMsaaReason = storeMsaaReason
storeMsaaReason = storeMsaaReason,
attachment = attachment
};
}

Expand Down Expand Up @@ -207,6 +206,8 @@ internal void GenerateNativeCompilerDebugData(ref RenderGraph.DebugData debugDat
debugResource.textureData.depth = resourceUnversioned.volumeDepth;
debugResource.textureData.samples = resourceUnversioned.msaaSamples;
debugResource.textureData.format = info.format;
debugResource.textureData.bindMS = resourceUnversioned.bindMS;
debugResource.textureData.clearBuffer = resourceUnversioned.clear;
debugResource.memoryless = resourceUnversioned.memoryLess;

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

RenderGraph.DebugData.s_PassScriptMetadata.TryGetValue(passName, out debugPass.scriptInfo);
RenderGraph.DebugData.s_PassScriptMetadata.TryGetValue(graphPass, out debugPass.scriptInfo);

debugPass.syncFromPassIndex = -1; // TODO async compute support
debugPass.syncToPassIndex = -1; // TODO async compute support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ public override int GetHashCode()
return hash;
}

public static bool EqualForMerge(PassFragmentData x, PassFragmentData y)
// If you modify this, check if struct RenderPassSetup::Attachment in "GfxDevice\RenderPassSetup.h" also needs changes
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool SameSubResource(in PassFragmentData x, in PassFragmentData y)
{
// We ignore the version for now we assume if one pass writes version x and the next y they can
// be merged in the same native render pass
return x.resource.index == y.resource.index && x.accessFlags == y.accessFlags && x.mipLevel == y.mipLevel && x.depthSlice == y.depthSlice;
// 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
// will always cover the required access (and thus possibly more if required by other passes)
return x.resource.index == y.resource.index && x.mipLevel == y.mipLevel && x.depthSlice == y.depthSlice;
}
}

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

for (int i = 0; i < nativePass.fragments.size; ++i)
{
if (nativePass.fragments[i].resource.index == fragment.resource.index)
if (PassFragmentData.SameSubResource(nativePass.fragments[i], fragment))
{
alreadyAttached = true;
break;
Expand Down Expand Up @@ -723,7 +727,7 @@ public static PassBreakAudit CanMerge(CompilerContextData contextData, int activ

for (int i = 0; i < nativePass.fragments.size; ++i)
{
if (nativePass.fragments[i].resource.index == fragmentInput.resource.index)
if (PassFragmentData.SameSubResource(nativePass.fragments[i], fragmentInput))
{
alreadyAttached = true;
break;
Expand Down Expand Up @@ -816,7 +820,7 @@ static bool CanMergeNativeSubPass(CompilerContextData contextData, NativePassDat
int colorAttachmentIdx = -1;
for (int fragmentId = 0; fragmentId < fragmentList.size; ++fragmentId)
{
if (fragmentList[fragmentId].resource.index == graphPassFragment.resource.index)
if (PassFragmentData.SameSubResource(fragmentList[fragmentId], graphPassFragment))
{
colorAttachmentIdx = fragmentId;
break;
Expand Down Expand Up @@ -849,7 +853,7 @@ static bool CanMergeNativeSubPass(CompilerContextData contextData, NativePassDat
int inputAttachmentIdx = -1;
for (int fragmentId = 0; fragmentId < fragmentList.size; ++fragmentId)
{
if (fragmentList[fragmentId].resource.index == graphFragmentInput.resource.index)
if (PassFragmentData.SameSubResource(fragmentList[fragmentId], graphFragmentInput))
{
inputAttachmentIdx = fragmentId;
break;
Expand Down Expand Up @@ -928,7 +932,7 @@ public static void TryMergeNativeSubPass(CompilerContextData contextData, ref Na
int colorAttachmentIdx = -1;
for (int fragmentId = 0; fragmentId < fragmentList.size; ++fragmentId)
{
if (fragmentList[fragmentId].resource.index == graphPassFragment.resource.index)
if (PassFragmentData.SameSubResource(fragmentList[fragmentId], graphPassFragment))
{
colorAttachmentIdx = fragmentId;
break;
Expand All @@ -955,7 +959,7 @@ public static void TryMergeNativeSubPass(CompilerContextData contextData, ref Na
int inputAttachmentIdx = -1;
for (int fragmentId = 0; fragmentId < fragmentList.size; ++fragmentId)
{
if (fragmentList[fragmentId].resource.index == fragmentInput.resource.index)
if (PassFragmentData.SameSubResource(fragmentList[fragmentId], fragmentInput))
{
inputAttachmentIdx = fragmentId;
break;
Expand Down Expand Up @@ -1118,7 +1122,7 @@ public static PassBreakAudit TryMerge(CompilerContextData contextData, int activ
for (int i = 0; i < nativePass.fragments.size; ++i)
{
ref var existingAttach = ref nativePass.fragments[i];
if (existingAttach.resource.index == newAttach.resource.index)
if (PassFragmentData.SameSubResource(existingAttach, newAttach))
{
// Update the attached version access flags and version
existingAttach.accessFlags |= newAttach.accessFlags;
Expand All @@ -1145,7 +1149,7 @@ public static PassBreakAudit TryMerge(CompilerContextData contextData, int activ
for (int i = 0; i < nativePass.fragments.size; ++i)
{
ref var existingAttach = ref nativePass.fragments[i];
if (existingAttach.resource.index == newAttach.resource.index)
if (PassFragmentData.SameSubResource(existingAttach, newAttach))
{
// Update the attached version access flags and version
existingAttach.accessFlags |= newAttach.accessFlags;
Expand Down
Loading

0 comments on commit a65be2c

Please sign in to comment.