Version: Unity 6.1 (6000.1)
LanguageEnglish
  • C#

FSR2Quality

enumeration

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Options for FSR2 performance modes.

Each performance mode corresponds to a scaling ratio per dimension of the input texture:

  1. Quality: 1.5x
  2. Balanced: 1.7x
  3. Performance: 2.0x
  4. Ultra Performance: 3.0x

Refer to the Scaling modes section in FSR2 Documentation for more details.

using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.Experimental.Rendering;
using UnityEngine.AMD;

// Example HDRP custom pass public class CustomFSRPass : CustomPass { void InitializeAMDDevice() { // device initialization code } bool HasOutputResolutionChanged(CustomPassContext ctx) { return m_QualityBefore != m_Quality; } bool HasInputResolutionChanged(CustomPassContext ctx) { // detect resolution change }

protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd) { if (amdDevice == null) { InitializeAMDDevice(); }

float scalingRatio = fsr2Context == null ? 1.0f : amdDevice.GetUpscaleRatioFromQualityMode(m_Quality); fsr2OutputColorBuffer = RTHandles.Alloc( new Vector2(scalingRatio, scalingRatio), slices: 1, dimension: TextureDimension.Tex2D, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, name: "fsr2OutputColorBuffer", enableRandomWrite: true ); }

protected override void Execute(CustomPassContext ctx) { bool initializeFsr2Context = fsr2Context == null || HasInputResolutionChanged(ctx) || HasOutputResolutionChanged(ctx); if (initializeFsr2Context) { // fsr2Context initialization code }

fsr2Context.executeData.enableSharpening = m_EnableSharpening ? 1 : 0; // populate rest of the fsr2Context.executeData

FSR2TextureTable fsr2TextureTable = new FSR2TextureTable() { // set texture table };

amdDevice.ExecuteFSR2(ctx.cmd, fsr2Context, fsr2TextureTable); }

protected override void Cleanup() { // cleanup code }

private GraphicsDevice amdDevice = null; private FSR2Context fsr2Context = null; private RTHandle fsr2OutputColorBuffer;

[SerializeField] public float m_Sharpness = 0.92f; [SerializeField] public bool m_EnableSharpening = true; [SerializeField] public FSR2Quality m_Quality = FSR2Quality.Quality; FSR2Quality m_QualityBefore = FSR2Quality.Quality; Vector2Int m_InputTextureSize = new Vector2Int(0,0); }

Properties

Property Description
QualityHighest quality, lower performance.
BalancedBalances performance with quality.
PerformanceFast performance, lower quality.
UltraPerformanceFastest performance, lowest quality.