Skip to content

Commit dafc36b

Browse files
arttu-peltonenEvergreen
authored andcommitted
Fix Render Graph Viewer displaying incorrect store reasoning for MSAA textures
Fix https://jira.unity3d.com/browse/UUM-67987 Render Graph Viewer displays a "store reasoning message" for Raster Pass Attachments to help understand why the system selected a given store action (one of `Store`, `Resolve` , `StoreAndResolve` or `DontCare`). Because `StoreAndResolve` exists, it means that we can potentially keep both the resolved and non-resolved data from a MSAA texture, and the reasoning for both of is independently decided. Therefore for MSAA attachments, we need to display two separate store reason messages in Render Graph Viewer. This PR fixes a bug where the UI only picked the first, default store reason message. For MSAA textures, UI looks like this: - See separate store reason messages for "Resolved surface" and "MSAA surface" - For non-MSAA attachments, the MSAA-specific information is not displayed. ![image](https://media.github.cds.internal.unity3d.com/user/3380/files/e4009dfb-4c68-43c0-a246-986da1aa2d02) This PR also contains a separate UI fix for Render Graph Viewer that makes the highlight animation update smoothly. It's a simple workaround to [this issue](https://jira.unity3d.com/browse/UUM-68010) that has been flagged for UITK team.
1 parent 9ccd98c commit dafc36b

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

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

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using UnityEditor.UIElements;
4+
using UnityEditorInternal;
45
using UnityEngine;
56
using UnityEngine.Rendering.RenderGraphModule;
67
using UnityEngine.UIElements;
@@ -343,12 +344,22 @@ void CreateTextElement(VisualElement parent, string text, string className = nul
343344

344345
attachmentFoldout.Add(new TextElement
345346
{
346-
text = $"<b>Load action:</b> {attachmentInfo.loadAction} ({attachmentInfo.loadReason})"
347+
text = $"<b>Load action:</b> {attachmentInfo.loadAction}\n- {attachmentInfo.loadReason}"
347348
});
348-
attachmentFoldout.Add(new TextElement
349+
350+
bool addMsaaInfo = !string.IsNullOrEmpty(attachmentInfo.storeMsaaReason);
351+
string resolvedTexturePrefix = addMsaaInfo ? "Resolved surface: " : "";
352+
353+
string storeActionText = $"<b>Store action:</b> {attachmentInfo.storeAction}" +
354+
$"\n - {resolvedTexturePrefix}{attachmentInfo.storeReason}";
355+
356+
if (addMsaaInfo)
349357
{
350-
text = $"<b>Store action:</b> {attachmentInfo.storeAction} ({attachmentInfo.storeReason})"
351-
});
358+
string msaaTexturePrefix = "MSAA surface: ";
359+
storeActionText += $"\n - {msaaTexturePrefix}{attachmentInfo.storeMsaaReason}";
360+
}
361+
362+
attachmentFoldout.Add(new TextElement { text = storeActionText });
352363

353364
passItem.Add(attachmentFoldout);
354365
}
@@ -427,12 +438,26 @@ void ScrollToFoldout(VisualElement parent, int index)
427438
ScrollView scrollView = parent.Q<ScrollView>();
428439
scrollView.Query<Foldout>(classes: Classes.kPanelListItem).ForEach(foldout =>
429440
{
430-
if (index == (int)foldout.userData)
441+
if (index == (int) foldout.userData)
431442
{
432443
// Trigger animation
433444
foldout.AddToClassList(Classes.kPanelListItemSelectionAnimation);
445+
446+
// This repaint hack is needed because transition animations have poor framerate. So we are hooking to editor update
447+
// loop for the duration of the animation to force repaints and have a smooth highlight animation.
448+
// See https://jira.unity3d.com/browse/UIE-1326
449+
EditorApplication.update += Repaint;
450+
434451
foldout.RegisterCallbackOnce<TransitionEndEvent>(_ =>
435-
foldout.RemoveFromClassList(Classes.kPanelListItemSelectionAnimation));
452+
{
453+
// "Highlight in" animation finished
454+
foldout.RemoveFromClassList(Classes.kPanelListItemSelectionAnimation);
455+
foldout.RegisterCallbackOnce<TransitionEndEvent>(_ =>
456+
{
457+
// "Highlight out" animation finished
458+
EditorApplication.update -= Repaint;
459+
});
460+
});
436461

437462
// Open foldout
438463
foldout.value = true;

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,22 @@ static RenderGraph.DebugData.PassData.NRPInfo.NativeRenderPassInfo.AttachmentInf
2323
if (storeAudit.passId >= 0)
2424
storeReason = storeReason.Replace("{pass}", $"<b>{ctx.passNames[storeAudit.passId].name}</b>");
2525

26+
string storeMsaaReason = string.Empty;
27+
if (storeAudit.msaaReason != StoreReason.InvalidReason && storeAudit.msaaReason != StoreReason.NoMSAABuffer)
28+
{
29+
storeMsaaReason = StoreAudit.StoreReasonMessages[(int) storeAudit.msaaReason];
30+
if (storeAudit.msaaPassId >= 0)
31+
storeMsaaReason = storeMsaaReason.Replace("{pass}", $"<b>{ctx.passNames[storeAudit.msaaPassId].name}</b>");
32+
}
33+
2634
return new RenderGraph.DebugData.PassData.NRPInfo.NativeRenderPassInfo.AttachmentInfo
2735
{
2836
resourceName = pointTo.GetName(ctx, attachment.handle),
2937
loadAction = attachment.loadAction.ToString(),
3038
loadReason = loadReason,
3139
storeAction = attachment.storeAction.ToString(),
3240
storeReason = storeReason,
41+
storeMsaaReason = storeMsaaReason
3342
};
3443
}
3544

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ internal struct StoreAudit
430430
"The resource is imported but the import was with the 'discard on last use' option enabled. The data is discarded.",
431431
"The resource is written by this pass but no later passes are using the results. The data is discarded.",
432432
"The resource was created as MSAA only resource, the data can never be resolved.",
433-
"The resource is an single sample resource, there is no multi-sample data to handle.",
433+
"The resource is a single sample resource, there is no multi-sample data to handle.",
434434
};
435435

436436
public StoreReason reason;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public class AttachmentInfo
6969
public string loadReason;
7070
public string storeAction;
7171
public string storeReason;
72+
public string storeMsaaReason;
7273
}
7374

7475
public struct PassCompatibilityInfo

0 commit comments

Comments
 (0)