Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Version Updated
The version number for this package has increased due to a version update of a related graphics package.

### Added
- Debug Panels Framework See `IDebugDisplaySettingsQuery`.
- New `IVolumeDebugSettings` interface and `VolumeDebugSettings<T>` class that stores the information for the Volumes Debug Panel.
- Added AMD FidelityFX shaders which were originally in HDRP

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;

namespace UnityEngine.Rendering
{
/// <summary>
/// Templated class for <see cref="IDebugDisplaySettings"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment should describe how to use the class. Like: "Subclass this to benefit for commonly used features regarding IDebugDisplaySettings"

/// </summary>
/// <typeparam name="T"></typeparam>
public abstract class DebugDisplaySettings<T> : IDebugDisplaySettings
where T : IDebugDisplaySettings, new()
{
protected readonly HashSet<IDebugDisplaySettingsData> m_Settings = new HashSet<IDebugDisplaySettingsData>();

private static readonly Lazy<T> s_Instance = new Lazy<T>(() =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to clear the data when entering or exiting playmode?

Note: When domain reload is not performed, the C# statics are not cleared and can contain invalid values.

{
var instance = new T();
instance.Reset();
return instance;
});

/// <summary>
/// The singleton instance that contains the current settings of Rendering Debugger.
/// </summary>
public static T Instance => s_Instance.Value;

#region IDebugDisplaySettingsQuery

/// <summary>
/// Returns true if any of the debug settings are currently active.
/// </summary>
public virtual bool AreAnySettingsActive
{
get
{
foreach (IDebugDisplaySettingsData setting in m_Settings)
{
if (setting.AreAnySettingsActive)
return true;
}

return false;
}
}

/// <summary>
/// Checks whether the current state of these settings allows post-processing.
/// </summary>
public virtual bool IsPostProcessingAllowed { get; }

/// <summary>
/// Returns true if lighting is active for current state of debug settings.
/// </summary>
public virtual bool IsLightingActive
{
get
{
bool lightingActive = true;
foreach (IDebugDisplaySettingsData setting in m_Settings)
lightingActive &= setting.IsLightingActive;
return lightingActive;
}
}
#endregion

protected TData Add<TData>(TData newData) where TData : IDebugDisplaySettingsData
{
m_Settings.Add(newData);
return newData;
}

/// <summary>
/// Executes an action for each element
/// </summary>
/// <param name="onExecute"></param>
public void ForEach(Action<IDebugDisplaySettingsData> onExecute)
{
foreach (IDebugDisplaySettingsData setting in m_Settings)
{
onExecute(setting);
}
}

/// <summary>
/// Reset the stored debug settings
/// </summary>
public virtual void Reset()
{
m_Settings.Clear();
}

/// <summary>
/// Attempts to get the color that should be used to clear the screen according to current debug settings.
/// </summary>
/// <param name="color">A reference to the screen clear color to use.</param>
/// <returns>True if the color reference was updated, and false otherwise.</returns>
public virtual bool TryGetScreenClearColor(ref Color color)
{
foreach (IDebugDisplaySettingsData setting in m_Settings)
{
if (setting.TryGetScreenClearColor(ref color))
return true;
}

return false;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace UnityEngine.Rendering.Universal
namespace UnityEngine.Rendering
{
public abstract class DebugDisplaySettingsPanel : IDebugDisplaySettingsPanelDisposable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class is disposable, although it can still be used while disposed. Is it intended?

{
Expand All @@ -14,9 +14,14 @@ protected void AddWidget(DebugUI.Widget widget)
m_Widgets.Add(widget);
}

public void Dispose()
protected void Clear()
{
m_Widgets.Clear();
}

public void Dispose()
{
Clear();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;

namespace UnityEngine.Rendering.Universal
namespace UnityEngine.Rendering
{
public class DebugDisplaySettingsUI : IDebugData
{
private IEnumerable<IDebugDisplaySettingsPanelDisposable> m_DisposablePanels;
private DebugDisplaySettings m_Settings;
private IDebugDisplaySettings m_Settings;

private void Reset()
{
Expand All @@ -21,7 +21,7 @@ private void Reset()
}
}

public void RegisterDebug(DebugDisplaySettings settings)
public void RegisterDebug(IDebugDisplaySettings settings)
{
DebugManager debugManager = DebugManager.instance;
List<IDebugDisplaySettingsPanelDisposable> panels = new List<IDebugDisplaySettingsPanelDisposable>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using UnityEngine;

namespace UnityEngine.Rendering
{
/// <summary>
/// Interface for storing the debug settings
/// </summary>
public interface IDebugDisplaySettings : IDebugDisplaySettingsQuery
{
/// <summary>
/// Reset the stored debug settings
/// </summary>
void Reset();

/// <summary>
/// Executes an action for each element
/// </summary>
/// <param name="onExecute"></param>
void ForEach(Action<IDebugDisplaySettingsData> onExecute);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace UnityEngine.Rendering.Universal
namespace UnityEngine.Rendering
{
/// <summary>
/// Debug UI panel interface
/// </summary>
public interface IDebugDisplaySettingsData : IDebugDisplaySettingsQuery
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;

namespace UnityEngine.Rendering.Universal
namespace UnityEngine.Rendering
{
/// <summary>
/// Debug UI panel
/// </summary>
public interface IDebugDisplaySettingsPanel
{
/// <summary>
Expand All @@ -15,6 +18,9 @@ public interface IDebugDisplaySettingsPanel
DebugUI.Widget[] Widgets { get; }
}

/// <summary>
/// Debug UI panel disposable
/// </summary>
public interface IDebugDisplaySettingsPanelDisposable : IDebugDisplaySettingsPanel, IDisposable
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using UnityEngine;

namespace UnityEngine.Rendering.Universal
namespace UnityEngine.Rendering
{
/// <summary>
/// Interface for determining what kind of debug settings are currently active.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using UnityEngine;

namespace UnityEngine.Rendering.Universal
{
Expand Down Expand Up @@ -32,9 +31,10 @@ private class SettingsPanel : DebugDisplaySettingsPanel

public SettingsPanel()
{
AddWidget(DebugDisplaySettingsCommon.WidgetFactory.CreateMissingDebugShadersWarning());
AddWidget(WidgetFactory.CreateMissingDebugShadersWarning());

var materialSettingsData = DebugDisplaySettings.Instance.MaterialSettings;
var debugDisplaySettings = UniversalRenderPipelineDebugDisplaySettings.Instance;
var materialSettingsData = debugDisplaySettings.MaterialSettings;
AddWidget(new DebugUI.Foldout
{
displayName = "Material Filters",
Expand All @@ -54,7 +54,7 @@ public SettingsPanel()
}
});

var lightingSettingsData = DebugDisplaySettings.Instance.LightingSettings;
var lightingSettingsData = debugDisplaySettings.LightingSettings;
AddWidget(new DebugUI.Foldout
{
displayName = "Lighting Debug Modes",
Expand All @@ -75,7 +75,7 @@ public SettingsPanel()
}
});

var renderingSettingsData = DebugDisplaySettings.Instance.RenderingSettings;
var renderingSettingsData = debugDisplaySettings.RenderingSettings;
AddWidget(new DebugUI.Foldout
{
displayName = "Rendering Debug",
Expand Down Expand Up @@ -103,11 +103,11 @@ public SettingsPanel()
}

#region IDebugDisplaySettingsData

public bool AreAnySettingsActive => DebugDisplaySettings.Instance.AreAnySettingsActive;
public bool IsPostProcessingAllowed => DebugDisplaySettings.Instance.IsPostProcessingAllowed;
public bool IsLightingActive => DebugDisplaySettings.Instance.IsLightingActive;
public bool TryGetScreenClearColor(ref Color color) => DebugDisplaySettings.Instance.TryGetScreenClearColor(ref color);
UniversalRenderPipelineDebugDisplaySettings debugDisplaySettings => UniversalRenderPipelineDebugDisplaySettings.Instance;
public bool AreAnySettingsActive => debugDisplaySettings.AreAnySettingsActive;
public bool IsPostProcessingAllowed => debugDisplaySettings.IsPostProcessingAllowed;
public bool IsLightingActive => debugDisplaySettings.IsLightingActive;
public bool TryGetScreenClearColor(ref Color color) => debugDisplaySettings.TryGetScreenClearColor(ref color);

public IDebugDisplaySettingsPanelDisposable CreatePanel()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class DebugHandler : IDebugDisplaySettingsQuery
Vector4 m_DebugRenderTargetPixelRect;
RenderTargetIdentifier m_DebugRenderTargetIdentifier;

readonly DebugDisplaySettings m_DebugDisplaySettings;
readonly UniversalRenderPipelineDebugDisplaySettings m_DebugDisplaySettings;

DebugDisplaySettingsLighting LightingSettings => m_DebugDisplaySettings.LightingSettings;
DebugDisplaySettingsMaterial MaterialSettings => m_DebugDisplaySettings.MaterialSettings;
Expand Down Expand Up @@ -84,7 +84,7 @@ public bool TryGetScreenClearColor(ref Color color)
#endregion

internal Material ReplacementMaterial => m_ReplacementMaterial;
internal DebugDisplaySettings DebugDisplaySettings => m_DebugDisplaySettings;
internal UniversalRenderPipelineDebugDisplaySettings DebugDisplaySettings => m_DebugDisplaySettings;

internal bool IsScreenClearNeeded
{
Expand All @@ -108,7 +108,7 @@ internal DebugHandler(ScriptableRendererData scriptableRendererData)
{
Shader debugReplacementShader = scriptableRendererData.debugShaders.debugReplacementPS;

m_DebugDisplaySettings = DebugDisplaySettings.Instance;
m_DebugDisplaySettings = UniversalRenderPipelineDebugDisplaySettings.Instance;

m_ReplacementMaterial = (debugReplacementShader == null) ? null : CoreUtils.CreateEngineMaterial(debugReplacementShader);
}
Expand Down
Loading