Нема описа
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UniversalRenderPipelineDebugDisplayStats.cs 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace UnityEngine.Rendering.Universal
  5. {
  6. /// <summary>
  7. /// URP Rendering Debugger Display Stats.
  8. /// </summary>
  9. class UniversalRenderPipelineDebugDisplayStats : DebugDisplayStats<URPProfileId>
  10. {
  11. private DebugFrameTiming m_DebugFrameTiming = new();
  12. private List<URPProfileId> m_RecordedSamplers = new();
  13. /// <inheritdoc/>
  14. public override void EnableProfilingRecorders()
  15. {
  16. Debug.Assert(m_RecordedSamplers.Count == 0);
  17. m_RecordedSamplers = GetProfilerIdsToDisplay();
  18. }
  19. /// <inheritdoc/>
  20. public override void DisableProfilingRecorders()
  21. {
  22. foreach (var sampler in m_RecordedSamplers)
  23. ProfilingSampler.Get(sampler).enableRecording = false;
  24. m_RecordedSamplers.Clear();
  25. }
  26. /// <inheritdoc/>
  27. public override void RegisterDebugUI(List<DebugUI.Widget> list)
  28. {
  29. #if UNITY_ANDROID || UNITY_IPHONE || UNITY_TVOS
  30. list.Add(new DebugUI.MessageBox
  31. {
  32. displayName = "Warning: GPU timings may not be accurate on mobile devices that have tile-based architectures.",
  33. style = DebugUI.MessageBox.Style.Warning
  34. });
  35. #endif
  36. m_DebugFrameTiming.RegisterDebugUI(list);
  37. var detailedStatsFoldout = new DebugUI.Foldout
  38. {
  39. displayName = "Detailed Stats",
  40. isHeader = true,
  41. opened = false,
  42. children =
  43. {
  44. new DebugUI.BoolField
  45. {
  46. displayName = "Update every second with average",
  47. getter = () => averageProfilerTimingsOverASecond,
  48. setter = value => averageProfilerTimingsOverASecond = value
  49. },
  50. new DebugUI.BoolField
  51. {
  52. displayName = "Hide empty scopes",
  53. tooltip = "Hide profiling scopes where elapsed time in each category is zero",
  54. getter = () => hideEmptyScopes,
  55. setter = value => hideEmptyScopes = value
  56. }
  57. }
  58. };
  59. detailedStatsFoldout.children.Add(BuildDetailedStatsList("Profiling Scopes", m_RecordedSamplers));
  60. list.Add(detailedStatsFoldout);
  61. }
  62. /// <inheritdoc/>
  63. public override void Update()
  64. {
  65. m_DebugFrameTiming.UpdateFrameTiming();
  66. UpdateDetailedStats(m_RecordedSamplers);
  67. }
  68. }
  69. }