docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class PluginUpscalerContext<TNativeContext, TOptions>

    Base class for plugin-based upscaler contexts (DLSS, FSR, XeSS, etc.). Handles common patterns: resolution tracking, type-safe validation, and cleanup. Plugin upscalers extend this class and implement the abstract methods.

    Inheritance
    object
    PluginUpscalerContext<TNativeContext, TOptions>
    Implements
    IUpscalerContext
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Rendering
    Assembly: Unity.RenderPipelines.Core.Runtime.dll
    Syntax
    public abstract class PluginUpscalerContext<TNativeContext, TOptions> : IUpscalerContext where TNativeContext : class where TOptions : UpscalerOptions
    Type Parameters
    Name Description
    TNativeContext

    The native context type from the plugin (e.g., DLSSContext, FSR2Context).

    TOptions

    The options type for this upscaler (e.g., DLSSOptions, FSR2Options).

    Constructors

    PluginUpscalerContext(Vector2Int)

    Creates a new plugin upscaler context for the specified display resolution. Subclasses should extract and store context-creation settings (quality mode, presets) in their own fields for use in RecordRenderGraph. Per-frame settings (sharpness, etc.) should be read from io.options instead.

    Declaration
    protected PluginUpscalerContext(Vector2Int displayResolution)
    Parameters
    Type Name Description
    Vector2Int displayResolution

    The target display resolution.

    Fields

    m_NativeContext

    The native context from the plugin. Subclasses create it lazily on first use (creation needs a CommandBuffer, so it can't happen in the constructor) and assign it here; the base class destroys it via Cleanup(CommandBuffer) (calling DestroyNativeContext(CommandBuffer, TNativeContext)). The lazy-creation method is the subclass's own — e.g. DLSS's create-once GetOrCreateNativeContext, or FSR2's EnsureNativeContext which also recreates when its allocation size changes.

    Declaration
    protected TNativeContext m_NativeContext
    Field Value
    Type Description
    TNativeContext

    Properties

    createdForDisplayResolution

    The display resolution this context was created for. Upscaler authors set this at creation time. The context manager reads it to detect resolution and options changes that require context recreation.

    Declaration
    public Vector2Int createdForDisplayResolution { get; }
    Property Value
    Type Description
    Vector2Int

    hasNativeContext

    Returns true if the native context has been created. Use this to skip building initialization settings when the context already exists.

    Declaration
    public bool hasNativeContext { get; }
    Property Value
    Type Description
    bool

    lastUsedFrame

    The frame number when this context was last used. Set automatically by the context manager each frame to track when unused contexts should be cleaned up.

    Declaration
    public int lastUsedFrame { get; set; }
    Property Value
    Type Description
    int

    Methods

    Cleanup(CommandBuffer)

    Releases native resources associated with this context. Called automatically by the context manager when the context expires, needs recreation, or the upscaling system is disposed.

    Declaration
    public void Cleanup(CommandBuffer cmd)
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer used to record cleanup commands into. The caller executes it.

    Remarks

    A command buffer is taken rather than this being a plain managed Dispose because some upscalers own native resources that must be released on the render thread. Implementations may record a render-thread signal here instead of GPU work, and the release may complete asynchronously.

    DestroyNativeContext(CommandBuffer, TNativeContext)

    Destroys the native context using the plugin API. Called by the base class Cleanup() method.

    Declaration
    protected abstract void DestroyNativeContext(CommandBuffer cmd, TNativeContext context)
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer to record destruction commands into.

    TNativeContext context

    The native context to destroy.

    IsValidForOptions(UpscalerOptions)

    Checks if this context is still valid for the given options. Upscaler authors implement the validation logic. The context manager calls this each frame to determine if the context needs recreation.

    Declaration
    public bool IsValidForOptions(UpscalerOptions options)
    Parameters
    Type Name Description
    UpscalerOptions options

    The current upscaler options to validate against.

    Returns
    Type Description
    bool

    True if the context is still valid, false if it needs to be recreated.

    ValidateOptions(TOptions)

    Validates whether the current options match the options this context was created with. Subclasses compare tracked option values against the provided options.

    Declaration
    protected abstract bool ValidateOptions(TOptions options)
    Parameters
    Type Name Description
    TOptions options

    The current options to validate against.

    Returns
    Type Description
    bool

    True if the context is still valid for these options.

    Implements

    IUpscalerContext

    Extension Methods

    ReflectionUtils.GetField(object, string)
    ReflectionUtils.GetFields(object)
    ReflectionUtils.Invoke(object, string, params object[])
    ReflectionUtils.SetField(object, string, object)
    AnalyticsUtils.ToNestedColumnWithDefault<T>(T, T, bool)
    AnalyticsUtils.ToNestedColumn<T>(T, T)
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)