#if ENABLE_UPSCALER_FRAMEWORK
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine.Scripting;
using static UnityEngine.Rendering.DynamicResolutionHandler;
namespace UnityEngine.Rendering
{
#nullable enable
///
/// Base ScriptableObject for holding configuration data for a specific upscaler.
/// Concrete implementations (e.g., DLSSOptions, FSR2Options) should inherit from this.
///
[Serializable]
public class UpscalerOptions : ScriptableObject
{
///
/// The unique identifier or display name of the upscaler associated with these options.
///
public string upscalerName
{
get => m_UpscalerName;
set => m_UpscalerName = value;
}
///
/// Determines at which stage in the render pipeline the upscaling pass is injected.
///
public UpsamplerScheduleType injectionPoint
{
get => m_InjectionPoint;
set => m_InjectionPoint = value;
}
///
/// Selects how the render resolution is determined for this upscaler. Only meaningful for upscalers that
/// expose a quality mode (); for the others it is dormant and the
/// upscaler always behaves as .
///
public UpscalerResolutionMode resolutionMode
{
get => m_ResolutionMode;
set => m_ResolutionMode = value;
}
[SerializeField, HideInInspector]
private string m_UpscalerName = "";
[SerializeField, HideInInspector] // hide in inspector for URP, HDRP manually renders it
private UpsamplerScheduleType m_InjectionPoint = UpsamplerScheduleType.BeforePost;
[SerializeField]
[Tooltip("Determines how the render resolution is selected: from the upscaler's quality preset (Quality " +
"Mode), or driven by the pipeline's own render scaling / dynamic resolution (Custom Scaling). " +
"Ignored by upscalers without a quality mode.")]
private UpscalerResolutionMode m_ResolutionMode = UpscalerResolutionMode.QualityMode;
#if UNITY_EDITOR
///
/// Validates and auto-populates the upscaler options list within a Render Pipeline Asset.
/// It ensures that for every registered upscaler, a corresponding Options sub-asset exists.
///
/// The Render Pipeline Asset that will contain these options as sub-assets.
/// The SerializedProperty representing the list/array of UpscalerOptions.
/// True if the property was modified (cleaned up or populated), false otherwise.
public static bool ValidateSerializedUpscalerOptionReferencesWithinRPAsset(ScriptableObject parentRPAsset, SerializedProperty optionsListProp)
{
if (parentRPAsset == null)
{
Debug.LogError("[Auto-Populate] Parent asset is null.");
return false;
}
if (optionsListProp == null || !optionsListProp.isArray)
{
Debug.LogError($"[Auto-Populate] Provided SerializedProperty '{optionsListProp?.name ?? "null"}' is not a valid list for upscaler options.");
return false;
}
bool propertyModified = false;
// Track valid objects to identify orphans later
HashSet