-
Notifications
You must be signed in to change notification settings - Fork 871
Expand file tree
/
Copy pathDebugDisplayGPUResidentDrawer.cs
More file actions
558 lines (491 loc) · 28.7 KB
/
DebugDisplayGPUResidentDrawer.cs
File metadata and controls
558 lines (491 loc) · 28.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
using System;
using System.Collections.Generic;
using Unity.Collections;
#if UNITY_EDITOR
using UnityEditor;
#endif
using static UnityEngine.Rendering.DebugUI;
using static UnityEngine.Rendering.DebugUI.Widget;
namespace UnityEngine.Rendering
{
/// <summary>
/// GPU Resident Drawer Rendering Debugger settings.
/// </summary>
public class DebugDisplayGPUResidentDrawer : IDebugDisplaySettingsData
{
const string k_FormatString = "{0}";
const float k_RefreshRate = 1f / 5f;
const int k_MaxViewCount = 32;
const int k_MaxOcclusionPassCount = 32;
const int k_MaxContextCount = 16;
private bool displayBatcherStats
{
get
{
return GPUResidentDrawer.GetDebugStats()?.enabled ?? false;
}
set
{
DebugRendererBatcherStats debugStats = GPUResidentDrawer.GetDebugStats();
if (debugStats != null)
debugStats.enabled = value;
}
}
/// <summary>Returns the view instances id for the selected occluder debug view index, or 0 if not valid.</summary>
internal bool GetOccluderViewInstanceID(out int viewInstanceID)
{
DebugRendererBatcherStats debugStats = GPUResidentDrawer.GetDebugStats();
if (debugStats != null)
{
if (occluderDebugViewIndex >= 0 && occluderDebugViewIndex < debugStats.occluderStats.Length)
{
viewInstanceID = debugStats.occluderStats[occluderDebugViewIndex].viewInstanceID;
return true;
}
}
viewInstanceID = 0;
return false;
}
/// <summary>Returns if the occlusion test heatmap debug overlay is enabled.</summary>
internal bool occlusionTestOverlayEnable
{
get { return GPUResidentDrawer.GetDebugStats()?.occlusionOverlayEnabled ?? false; }
set
{
DebugRendererBatcherStats debugStats = GPUResidentDrawer.GetDebugStats();
if (debugStats != null)
debugStats.occlusionOverlayEnabled = value;
}
}
private bool occlusionTestOverlayCountVisible
{
get { return GPUResidentDrawer.GetDebugStats()?.occlusionOverlayCountVisible ?? false; }
set
{
DebugRendererBatcherStats debugStats = GPUResidentDrawer.GetDebugStats();
if (debugStats != null)
debugStats.occlusionOverlayCountVisible = value;
}
}
private bool overrideOcclusionTestToAlwaysPass
{
get { return GPUResidentDrawer.GetDebugStats()?.overrideOcclusionTestToAlwaysPass ?? false; }
set
{
DebugRendererBatcherStats debugStats = GPUResidentDrawer.GetDebugStats();
if (debugStats != null)
debugStats.overrideOcclusionTestToAlwaysPass = value;
}
}
/// <summary>Returns true if the occluder debug overlay is enabled.</summary>
public bool occluderDebugViewEnable = false;
internal bool occluderContextStats = false;
internal Vector2 occluderDebugViewRange = new Vector2(0.0f, 1.0f);
internal int occluderDebugViewIndex = 0;
private static InstanceCullerViewStats GetInstanceCullerViewStats(int viewIndex)
{
DebugRendererBatcherStats debugStats = GPUResidentDrawer.GetDebugStats();
if (debugStats != null && viewIndex < debugStats.instanceCullerStats.Length)
return debugStats.instanceCullerStats[viewIndex];
else
return new InstanceCullerViewStats();
}
private static InstanceOcclusionEventStats GetInstanceOcclusionEventStats(int passIndex)
{
DebugRendererBatcherStats debugStats = GPUResidentDrawer.GetDebugStats();
if (debugStats != null && passIndex < debugStats.instanceOcclusionEventStats.Length)
return debugStats.instanceOcclusionEventStats[passIndex];
else
return new InstanceOcclusionEventStats();
}
static class Strings
{
public const string drawerSettingsContainerName = "GPU Resident Drawer Settings";
public static readonly NameAndTooltip displayBatcherStats = new() { name = "Display Culling Stats", tooltip = "Enable the checkbox to display stats for instance culling." };
public const string occlusionCullingTitle = "Occlusion Culling";
public static readonly NameAndTooltip occlusionTestOverlayEnable = new() { name = "Occlusion Test Overlay", tooltip = "Occlusion test visualisation." };
public static readonly NameAndTooltip occlusionTestOverlayCountVisible = new() { name = "Occlusion Test Overlay Count Visible", tooltip = "Occlusion test visualisation should count visible instances instead of occluded instances." };
public static readonly NameAndTooltip overrideOcclusionTestToAlwaysPass = new() { name = "Override Occlusion Test To Always Pass", tooltip = "Occlusion test always passes." };
public static readonly NameAndTooltip occluderContextStats = new() { name = "Occluder Context Stats", tooltip = "Show all the active occluder context textures." };
public static readonly NameAndTooltip occluderDebugViewEnable = new() { name = "Occluder Debug View", tooltip = "Debug view of occluder texture." };
public static readonly NameAndTooltip occluderDebugViewIndex = new() { name = "Occluder Debug View Index", tooltip = "Index of the view for which the occluder texture is displayed. Use the Occlusion Test Context Stats for a list of the views." };
public static readonly NameAndTooltip occluderDebugViewRangeMin = new() { name = "Occluder Debug View Range Min", tooltip = "Range in which the occluder debug texture are displayed." };
public static readonly NameAndTooltip occluderDebugViewRangeMax = new() { name = "Occluder Debug View Range Max", tooltip = "Range in which the occluder debug texture are displayed." };
}
private static DebugOccluderStats GetOccluderStats(int occluderIndex)
{
DebugRendererBatcherStats debugStats = GPUResidentDrawer.GetDebugStats();
if (debugStats != null && occluderIndex < debugStats.occluderStats.Length)
return debugStats.occluderStats[occluderIndex];
else
return new DebugOccluderStats();
}
private static int GetOcclusionContextsCounts()
{
return GPUResidentDrawer.GetDebugStats()?.occluderStats.Length ?? 0;
}
private static int GetInstanceCullerViewCount()
{
return GPUResidentDrawer.GetDebugStats()?.instanceCullerStats.Length ?? 0;
}
private static int GetInstanceOcclusionEventCount()
{
return GPUResidentDrawer.GetDebugStats()?.instanceOcclusionEventStats.Length ?? 0;
}
private static DebugUI.Table.Row AddInstanceCullerViewDataRow(int viewIndex)
{
return new DebugUI.Table.Row
{
displayName = "",
opened = true,
isHiddenCallback = () => { return viewIndex >= GetInstanceCullerViewCount(); },
children =
{
new DebugUI.Value { displayName = "View Type", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => GetInstanceCullerViewStats(viewIndex).viewType },
new DebugUI.Value { displayName = "View Instance ID", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () =>
{
var viewStats = GetInstanceCullerViewStats(viewIndex);
#if UNITY_EDITOR
Object view = EditorUtility.InstanceIDToObject(viewStats.viewInstanceID);
if (view)
{
return $"{viewStats.viewInstanceID} ({view.name})";
}
#endif
return viewStats.viewInstanceID;
}
},
new DebugUI.Value { displayName = "Split Index", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => GetInstanceCullerViewStats(viewIndex).splitIndex },
new DebugUI.Value { displayName = "Visible Instances CPU | GPU", tooltip = "Visible instances after CPU culling and after GPU culling.", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () =>
{
var viewStats = GetInstanceCullerViewStats(viewIndex);
return $"{viewStats.visibleInstancesOnCPU} | {viewStats.visibleInstancesOnGPU}";
}
},
new DebugUI.Value { displayName = "Visible Primitives CPU | GPU", tooltip = "Visible primitives after CPU culling and after GPU culling.", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () =>
{
var viewStats = GetInstanceCullerViewStats(viewIndex);
return $"{viewStats.visiblePrimitivesOnCPU} | {viewStats.visiblePrimitivesOnGPU}";
}
},
new DebugUI.Value { displayName = "Draw Commands", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => GetInstanceCullerViewStats(viewIndex).drawCommands },
}
};
}
private static object OccluderVersionString(in InstanceOcclusionEventStats stats)
{
return (stats.eventType == InstanceOcclusionEventType.OccluderUpdate || stats.occlusionTest != OcclusionTest.None) ? stats.occluderVersion : "-";
}
private static object OcclusionTestString(in InstanceOcclusionEventStats stats)
{
return (stats.eventType == InstanceOcclusionEventType.OcclusionTest) ? stats.occlusionTest : "-";
}
private static object VisibleInstancesString(in InstanceOcclusionEventStats stats)
{
return (stats.eventType == InstanceOcclusionEventType.OcclusionTest) ? stats.visibleInstances : "-";
}
private static object CulledInstancesString(in InstanceOcclusionEventStats stats)
{
return (stats.eventType == InstanceOcclusionEventType.OcclusionTest) ? stats.culledInstances : "-";
}
private static object VisiblePrimitivesString(in InstanceOcclusionEventStats stats)
{
return (stats.eventType == InstanceOcclusionEventType.OcclusionTest) ? stats.visiblePrimitives : "-";
}
private static object CulledPrimitivesString(in InstanceOcclusionEventStats stats)
{
return (stats.eventType == InstanceOcclusionEventType.OcclusionTest) ? stats.culledPrimitives : "-";
}
private static DebugUI.Table.Row AddInstanceOcclusionPassDataRow(int eventIndex)
{
return new DebugUI.Table.Row
{
displayName = "",
opened = true,
isHiddenCallback = () => { return eventIndex >= GetInstanceOcclusionEventCount(); },
children =
{
new DebugUI.Value { displayName = "View Instance ID", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () =>
{
var eventStats = GetInstanceOcclusionEventStats(eventIndex);
#if UNITY_EDITOR
Object view = EditorUtility.InstanceIDToObject(eventStats.viewInstanceID);
if (view)
{
return $"{eventStats.viewInstanceID} ({view.name})";
}
#endif
return eventStats.viewInstanceID;
}
},
new DebugUI.Value { displayName = "Event Type", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => $"{GetInstanceOcclusionEventStats(eventIndex).eventType}" },
new DebugUI.Value { displayName = "Occluder Version", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => OccluderVersionString(GetInstanceOcclusionEventStats(eventIndex)) },
new DebugUI.Value { displayName = "Subview Mask", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => $"0x{GetInstanceOcclusionEventStats(eventIndex).subviewMask:X}" },
new DebugUI.Value { displayName = "Occlusion Test", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => $"{OcclusionTestString(GetInstanceOcclusionEventStats(eventIndex))}" },
new DebugUI.Value { displayName = "Visible Instances", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => VisibleInstancesString(GetInstanceOcclusionEventStats(eventIndex)) },
new DebugUI.Value { displayName = "Culled Instances", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => CulledInstancesString(GetInstanceOcclusionEventStats(eventIndex)) },
new DebugUI.Value { displayName = "Visible Primitives", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => VisiblePrimitivesString(GetInstanceOcclusionEventStats(eventIndex)) },
new DebugUI.Value { displayName = "Culled Primitives", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => CulledPrimitivesString(GetInstanceOcclusionEventStats(eventIndex)) },
}
};
}
private static DebugUI.Table.Row AddOcclusionContextDataRow(int index)
{
return new DebugUI.Table.Row
{
displayName = "",
opened = true,
isHiddenCallback = () => index >= GetOcclusionContextsCounts(),
children =
{
new DebugUI.Value { displayName = "View Instance ID", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => GetOccluderStats(index).viewInstanceID },
new DebugUI.Value { displayName = "Subview Count", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => GetOccluderStats(index).subviewCount },
new DebugUI.Value { displayName = "Size Per Subview", refreshRate = k_RefreshRate, formatString = k_FormatString, getter =
() =>
{
Vector2Int size = GetOccluderStats(index).occluderMipLayoutSize;
return $"{size.x}x{size.y}";
}},
}
};
}
[DisplayInfo(name = "GPU Resident Drawer", order = 5)]
[CurrentPipelineHelpURL("gpu-resident-drawer")]
private class SettingsPanel : DebugDisplaySettingsPanel
{
public override string PanelName => "GPU Resident Drawer";
public override DebugUI.Flags Flags => DebugUI.Flags.EditorForceUpdate;
public SettingsPanel(DebugDisplayGPUResidentDrawer data)
{
var helpBox = new DebugUI.MessageBox()
{
displayName = "Not Supported",
style = MessageBox.Style.Warning,
messageCallback = () =>
{
var settings = GPUResidentDrawer.GetGlobalSettingsFromRPAsset();
return GPUResidentDrawer.IsGPUResidentDrawerSupportedBySRP(settings, out var msg, out var _) ? string.Empty : msg;
},
isHiddenCallback = () => GPUResidentDrawer.IsEnabled()
};
AddWidget(helpBox);
AddWidget(new Container()
{
displayName = Strings.occlusionCullingTitle,
isHiddenCallback = () => !GPUResidentDrawer.IsEnabled(),
children =
{
new DebugUI.BoolField { nameAndTooltip = Strings.occlusionTestOverlayEnable, getter = () => data.occlusionTestOverlayEnable, setter = value => data.occlusionTestOverlayEnable = value},
new DebugUI.BoolField { nameAndTooltip = Strings.occlusionTestOverlayCountVisible, getter = () => data.occlusionTestOverlayCountVisible, setter = value => data.occlusionTestOverlayCountVisible = value},
new DebugUI.BoolField { nameAndTooltip = Strings.overrideOcclusionTestToAlwaysPass, getter = () => data.overrideOcclusionTestToAlwaysPass, setter = value => data.overrideOcclusionTestToAlwaysPass = value},
new DebugUI.BoolField { nameAndTooltip = Strings.occluderContextStats, getter = () => data.occluderContextStats, setter = value => data.occluderContextStats = value},
new DebugUI.BoolField { nameAndTooltip = Strings.occluderDebugViewEnable, getter = () => data.occluderDebugViewEnable, setter = value => data.occluderDebugViewEnable = value},
new DebugUI.IntField { nameAndTooltip = Strings.occluderDebugViewIndex, getter = () => data.occluderDebugViewIndex, setter = value => data.occluderDebugViewIndex = value, isHiddenCallback = () => !data.occluderDebugViewEnable, min = () => 0, max = () => Math.Max(GetOcclusionContextsCounts() - 1, 0) },
new DebugUI.FloatField {nameAndTooltip = Strings.occluderDebugViewRangeMin, getter = () => data.occluderDebugViewRange.x, setter = value => data.occluderDebugViewRange.x = value, isHiddenCallback = () => !data.occluderDebugViewEnable},
new DebugUI.FloatField {nameAndTooltip = Strings.occluderDebugViewRangeMax, getter = () => data.occluderDebugViewRange.y, setter = value => data.occluderDebugViewRange.y = value, isHiddenCallback = () => !data.occluderDebugViewEnable}
}
});
AddOcclusionContextStatsWidget(data);
AddWidget(new DebugUI.Container()
{
displayName = Strings.drawerSettingsContainerName,
isHiddenCallback = () => !GPUResidentDrawer.IsEnabled(),
children =
{
new DebugUI.BoolField { nameAndTooltip = Strings.displayBatcherStats, getter = () => data.displayBatcherStats, setter = value => data.displayBatcherStats = value},
}
});
AddInstanceCullingStatsWidget(data);
}
private void AddInstanceCullingStatsWidget(DebugDisplayGPUResidentDrawer data)
{
var instanceCullerStats = new DebugUI.Foldout
{
displayName = "Instance Culler Stats",
isHeader = true,
opened = true,
isHiddenCallback = () => !data.displayBatcherStats
};
instanceCullerStats.children.Add(new DebugUI.ValueTuple()
{
displayName = "View Count",
values = new[]
{
new DebugUI.Value { refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => GetInstanceCullerViewCount() }
}
});
instanceCullerStats.children.Add(new DebugUI.ValueTuple()
{
displayName = "Total Visible Instances (Cameras | Lights | Both)",
values = new[]
{
new DebugUI.Value { refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () =>
{
int totalGRDInstances = 0;
for (int viewIndex = 0; viewIndex < GetInstanceCullerViewCount(); viewIndex++)
{
var viewStats = GetInstanceCullerViewStats(viewIndex);
if (viewStats.viewType == BatchCullingViewType.Camera)
totalGRDInstances += viewStats.visibleInstancesOnGPU;
}
return totalGRDInstances;
}
},
new DebugUI.Value { refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () =>
{
int totalGRDInstances = 0;
for (int viewIndex = 0; viewIndex < GetInstanceCullerViewCount(); viewIndex++)
{
var viewStats = GetInstanceCullerViewStats(viewIndex);
if (viewStats.viewType == BatchCullingViewType.Light)
totalGRDInstances += viewStats.visibleInstancesOnGPU;
}
return totalGRDInstances;
}
},
new DebugUI.Value { refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () =>
{
int totalGRDInstances = 0;
for (int viewIndex = 0; viewIndex < GetInstanceCullerViewCount(); viewIndex++)
{
var viewStats = GetInstanceCullerViewStats(viewIndex);
if (viewStats.viewType != BatchCullingViewType.Filtering
&& viewStats.viewType != BatchCullingViewType.Picking
&& viewStats.viewType != BatchCullingViewType.SelectionOutline)
totalGRDInstances += viewStats.visibleInstancesOnGPU;
}
return totalGRDInstances;
}
},
}
});
instanceCullerStats.children.Add(new DebugUI.ValueTuple()
{
displayName = "Total Visible Primitives (Cameras | Lights | Both)",
values = new[]
{
new DebugUI.Value { refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () =>
{
int totalGRDPrimitives = 0;
for (int viewIndex = 0; viewIndex < GetInstanceCullerViewCount(); viewIndex++)
{
var viewStats = GetInstanceCullerViewStats(viewIndex);
if (viewStats.viewType == BatchCullingViewType.Camera)
totalGRDPrimitives += viewStats.visiblePrimitivesOnGPU;
}
return totalGRDPrimitives;
}
},
new DebugUI.Value { refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () =>
{
int totalGRDPrimitives = 0;
for (int viewIndex = 0; viewIndex < GetInstanceCullerViewCount(); viewIndex++)
{
var viewStats = GetInstanceCullerViewStats(viewIndex);
if (viewStats.viewType == BatchCullingViewType.Light)
totalGRDPrimitives += viewStats.visiblePrimitivesOnGPU;
}
return totalGRDPrimitives;
}
},
new DebugUI.Value { refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () =>
{
int totalGRDPrimitives = 0;
for (int viewIndex = 0; viewIndex < GetInstanceCullerViewCount(); viewIndex++)
{
var viewStats = GetInstanceCullerViewStats(viewIndex);
if (viewStats.viewType != BatchCullingViewType.Filtering
&& viewStats.viewType != BatchCullingViewType.Picking
&& viewStats.viewType != BatchCullingViewType.SelectionOutline)
totalGRDPrimitives += viewStats.visiblePrimitivesOnGPU;
}
return totalGRDPrimitives;
}
},
}
});
DebugUI.Table viewTable = new DebugUI.Table
{
displayName = "",
isReadOnly = true
};
// Always add all possible rows, they are dynamically hidden based on actual data
for (int i = 0; i < k_MaxViewCount; i++)
viewTable.children.Add(AddInstanceCullerViewDataRow(i));
var perViewStats = new DebugUI.Foldout
{
displayName = "Per View Stats",
isHeader = true,
opened = false,
isHiddenCallback = () => !data.displayBatcherStats
};
perViewStats.children.Add(viewTable);
instanceCullerStats.children.Add(perViewStats);
DebugUI.Table eventTable = new DebugUI.Table
{
displayName = "", // First column is empty because its content needs to change dynamically
isReadOnly = true
};
// Always add all possible rows, they are dynamically hidden based on actual data
for (int i = 0; i < k_MaxOcclusionPassCount; i++)
eventTable.children.Add(AddInstanceOcclusionPassDataRow(i));
var perEventStats = new DebugUI.Foldout
{
displayName = "Occlusion Culling Events",
isHeader = true,
opened = false,
isHiddenCallback = () => !data.displayBatcherStats
};
perEventStats.children.Add(eventTable);
instanceCullerStats.children.Add(perEventStats);
AddWidget(instanceCullerStats);
}
private void AddOcclusionContextStatsWidget(DebugDisplayGPUResidentDrawer data)
{
var visibilityStats = new DebugUI.Foldout
{
displayName = "Occlusion Context Stats",
isHeader = true,
opened = true,
isHiddenCallback = () => !data.occluderContextStats
};
visibilityStats.children.Add(new DebugUI.ValueTuple()
{
displayName = "Active Occlusion Contexts",
values = new[]
{
new DebugUI.Value { refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => GetOcclusionContextsCounts() }
}
});
DebugUI.Table viewTable = new DebugUI.Table
{
displayName = "", // First column is empty because its content needs to change dynamically
isReadOnly = true
};
// Always add all possible rows, they are dynamically hidden based on actual data
for (int i = 0; i < k_MaxContextCount; i++)
viewTable.children.Add(AddOcclusionContextDataRow(i));
visibilityStats.children.Add(viewTable);
AddWidget(visibilityStats);
}
}
#region IDebugDisplaySettingsQuery
/// <inheritdoc/>
public bool AreAnySettingsActive => displayBatcherStats;
/// <inheritdoc/>
public bool IsPostProcessingAllowed => true;
/// <inheritdoc/>
public bool IsLightingActive => true;
/// <inheritdoc/>
public bool TryGetScreenClearColor(ref Color color)
{
return false;
}
/// <inheritdoc/>
IDebugDisplaySettingsPanelDisposable IDebugDisplaySettingsData.CreatePanel()
{
return new SettingsPanel(this);
}
#endregion
}
}