Skip to content

Commit 177c2b6

Browse files
arttu-peltonenEvergreen
authored andcommitted
Fix Render Graph Viewer warnings on HDRP due to duplicate pass names
Fix https://jira.unity3d.com/browse/UUM-65820 When capturing data for Render Graph Viewer, we use the RG pass name as key in the dictionary that stores the script file name and line information required for "jump to pass source in IDE" feature. If duplicate pass names are found, a warning is printed to let user know that this mapping will be ambiguous. In the case of this bug, the helper functions `BeginProfilingSampler` and `EndProfilingSampler` enqueue render passes with a fixed name, leading to multiple duplicate entries and therefore warnings. However, as these passes also call `builder.GenerateDebugData(false)`, they are not visible in RG Viewer in the first place and we can safely ignore them. Note that the new code added is only ever active during the frame where RG Viewer is opened or the refresh button is clicked, so there is no performance impact.
1 parent 8275544 commit 177c2b6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,19 @@ public class PassScriptInfo
194194
}
195195
}
196196

197+
readonly string[] k_PassNameDebugIgnoreList = new string[] { k_BeginProfilingSamplerPassName, k_EndProfilingSamplerPassName };
198+
197199
[Conditional("UNITY_EDITOR")]
198200
void AddPassDebugMetadata(string passName, string file, int line)
199201
{
200202
// Does nothing unless debug data capture is requested
201203
if (m_CaptureDebugDataForExecution == null)
202204
return;
203205

206+
for (int i = 0; i < k_PassNameDebugIgnoreList.Length; ++i)
207+
if (passName == k_PassNameDebugIgnoreList[i])
208+
return;
209+
204210
if (!DebugData.s_PassScriptMetadata.TryAdd(passName, new DebugData.PassScriptInfo { filePath = file, line = line }))
205211
{
206212
var existingFile = DebugData.s_PassScriptMetadata[passName].filePath;

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,9 @@ class ProfilingScopePassData
12471247
public ProfilingSampler sampler;
12481248
}
12491249

1250+
const string k_BeginProfilingSamplerPassName = "BeginProfile";
1251+
const string k_EndProfilingSamplerPassName = "EndProfile";
1252+
12501253
/// <summary>
12511254
/// Begin a profiling scope.
12521255
/// </summary>
@@ -1260,7 +1263,7 @@ public void BeginProfilingSampler(ProfilingSampler sampler,
12601263
if (sampler == null)
12611264
return;
12621265

1263-
using (var builder = AddRenderPass<ProfilingScopePassData>("BeginProfile", out var passData, (ProfilingSampler)null, file, line))
1266+
using (var builder = AddRenderPass<ProfilingScopePassData>(k_BeginProfilingSamplerPassName, out var passData, (ProfilingSampler)null, file, line))
12641267
{
12651268
passData.sampler = sampler;
12661269
builder.AllowPassCulling(false);
@@ -1285,7 +1288,7 @@ public void EndProfilingSampler(ProfilingSampler sampler,
12851288
if (sampler == null)
12861289
return;
12871290

1288-
using (var builder = AddRenderPass<ProfilingScopePassData>("EndProfile", out var passData, (ProfilingSampler)null, file, line))
1291+
using (var builder = AddRenderPass<ProfilingScopePassData>(k_EndProfilingSamplerPassName, out var passData, (ProfilingSampler)null, file, line))
12891292
{
12901293
passData.sampler = sampler;
12911294
builder.AllowPassCulling(false);

0 commit comments

Comments
 (0)