Açıklama Yok
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.

UniversalRenderPipelineDebugDisplaySettings.cs 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using System;
  2. namespace UnityEngine.Rendering.Universal
  3. {
  4. /// <summary>
  5. /// Class for the rendering debugger settings.
  6. /// </summary>
  7. public class UniversalRenderPipelineDebugDisplaySettings : DebugDisplaySettings<UniversalRenderPipelineDebugDisplaySettings>
  8. {
  9. DebugDisplaySettingsCommon commonSettings { get; set; }
  10. /// <summary>
  11. /// Material-related rendering debugger settings.
  12. /// </summary>
  13. public DebugDisplaySettingsMaterial materialSettings { get; private set; }
  14. /// <summary>
  15. /// Rendering-related rendering debugger settings.
  16. /// </summary>
  17. public DebugDisplaySettingsRendering renderingSettings { get; private set; }
  18. /// <summary>
  19. /// Lighting-related rendering debugger settings.
  20. /// </summary>
  21. public DebugDisplaySettingsLighting lightingSettings { get; private set; }
  22. /// <summary>
  23. /// Volume-related rendering debugger settings.
  24. /// </summary>
  25. public DebugDisplaySettingsVolume volumeSettings { get; private set; }
  26. /// <summary>
  27. /// Display stats.
  28. /// </summary>
  29. internal DebugDisplaySettingsStats<URPProfileId> displayStats { get; private set; }
  30. /// <summary>
  31. /// GPU Resident Drawer Rendering Debugger settings and statistics.
  32. /// </summary>
  33. internal DebugDisplayGPUResidentDrawer gpuResidentDrawerSettings { get; private set; }
  34. #region IDebugDisplaySettingsQuery
  35. /// <summary>
  36. /// Returns true if the current state of debug settings allows post-processing.
  37. /// </summary>
  38. public override bool IsPostProcessingAllowed
  39. {
  40. get
  41. {
  42. DebugPostProcessingMode debugPostProcessingMode = renderingSettings.postProcessingDebugMode;
  43. switch (debugPostProcessingMode)
  44. {
  45. case DebugPostProcessingMode.Disabled:
  46. {
  47. return false;
  48. }
  49. case DebugPostProcessingMode.Auto:
  50. {
  51. // Only enable post-processing if we aren't using certain debug-views.
  52. bool postProcessingAllowed = true;
  53. foreach (IDebugDisplaySettingsData setting in m_Settings)
  54. postProcessingAllowed &= setting.IsPostProcessingAllowed;
  55. return postProcessingAllowed;
  56. }
  57. case DebugPostProcessingMode.Enabled:
  58. {
  59. return true;
  60. }
  61. default:
  62. {
  63. throw new ArgumentOutOfRangeException(nameof(debugPostProcessingMode), $"Invalid post-processing state {debugPostProcessingMode}");
  64. }
  65. }
  66. }
  67. }
  68. #endregion
  69. /// <summary>
  70. /// Creates a new <c>UniversalRenderPipelineDebugDisplaySettings</c> instance.
  71. /// </summary>
  72. public UniversalRenderPipelineDebugDisplaySettings()
  73. {
  74. Reset();
  75. }
  76. /// <inheritdoc/>
  77. public override void Reset()
  78. {
  79. base.Reset();
  80. displayStats = Add(new DebugDisplaySettingsStats<URPProfileId>(new UniversalRenderPipelineDebugDisplayStats()));
  81. materialSettings = Add(new DebugDisplaySettingsMaterial());
  82. lightingSettings = Add(new DebugDisplaySettingsLighting());
  83. renderingSettings = Add(new DebugDisplaySettingsRendering());
  84. volumeSettings = Add(new DebugDisplaySettingsVolume(new UniversalRenderPipelineVolumeDebugSettings()));
  85. commonSettings = Add(new DebugDisplaySettingsCommon());
  86. gpuResidentDrawerSettings = Add(new DebugDisplayGPUResidentDrawer());
  87. // This is not a debug property owned by any `IDebugDisplaySettingsData`, it is a static property on `Texture`.
  88. // When the user hits reset, we want to make sure texture mip caching is enabled again (regardless of whether the
  89. // user toggled this in the Rendering Debugger UI or changed it using the scripting API).
  90. Texture.streamingTextureDiscardUnusedMips = false;
  91. }
  92. internal void UpdateDisplayStats()
  93. {
  94. if (displayStats != null)
  95. displayStats.debugDisplayStats.Update();
  96. }
  97. internal void UpdateMaterials()
  98. {
  99. if (renderingSettings.mipInfoMode != DebugMipInfoMode.None)
  100. {
  101. int textureSlotImpl = (renderingSettings.canAggregateData && renderingSettings.showInfoForAllSlots)
  102. ? -1
  103. : renderingSettings.mipDebugMaterialTextureSlot;
  104. Texture.SetStreamingTextureMaterialDebugProperties(textureSlotImpl);
  105. }
  106. }
  107. }
  108. }