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.
136 lines
4.0 KiB
136 lines
4.0 KiB
using System;
|
|
|
|
namespace UnityEngine.Rendering.HighDefinition.AMD
|
|
{
|
|
public static class AMDUnityPlugin
|
|
{
|
|
// TODO: allow dynamic switching between plugins (including shutdown of previous plugin)
|
|
// internal static readonly UpscalerPlugin ActivePlugin = new FSR2Wrapper.FSR2WrapperUpscaler();
|
|
internal static readonly UpscalerPlugin ActivePlugin = new FSR3.FSR3UpscalerPlugin();
|
|
|
|
public static bool Load() => ActivePlugin.Load();
|
|
|
|
public static bool IsLoaded() => ActivePlugin.IsLoaded();
|
|
}
|
|
|
|
public abstract class UpscalerPlugin
|
|
{
|
|
public abstract bool Load();
|
|
|
|
public abstract bool IsLoaded();
|
|
|
|
public abstract GraphicsDevice CreateGraphicsDevice();
|
|
|
|
public abstract GraphicsDevice device { get; }
|
|
|
|
public virtual uint version => 0x00;
|
|
}
|
|
|
|
public abstract class GraphicsDevice
|
|
{
|
|
public static GraphicsDevice device => AMDUnityPlugin.ActivePlugin.device;
|
|
|
|
public static uint version => AMDUnityPlugin.ActivePlugin.version;
|
|
|
|
public static GraphicsDevice CreateGraphicsDevice()
|
|
{
|
|
return AMDUnityPlugin.ActivePlugin.CreateGraphicsDevice();
|
|
}
|
|
|
|
public abstract FSR2Context CreateFeature(CommandBuffer cmd, in FSR2CommandInitializationData initSettings);
|
|
|
|
public abstract void DestroyFeature(CommandBuffer cmd, FSR2Context fsrContext);
|
|
|
|
public abstract void ExecuteFSR2(CommandBuffer cmd, FSR2Context fsrContext, in FSR2TextureTable textures);
|
|
|
|
public abstract bool GetRenderResolutionFromQualityMode(FSR2Quality qualityMode, uint displayWidth, uint displayHeight, out uint renderWidth, out uint renderHeight);
|
|
|
|
public abstract float GetUpscaleRatioFromQualityMode(FSR2Quality qualityMode);
|
|
}
|
|
|
|
public abstract class FSR2Context
|
|
{
|
|
public abstract ref FSR2CommandInitializationData initData { get; }
|
|
|
|
public abstract ref FSR2CommandExecutionData executeData { get; }
|
|
}
|
|
|
|
public struct FSR2CommandInitializationData
|
|
{
|
|
public uint displaySizeHeight;
|
|
|
|
public uint displaySizeWidth;
|
|
|
|
public FfxFsr2InitializationFlags ffxFsrFlags;
|
|
|
|
public uint maxRenderSizeHeight;
|
|
|
|
public uint maxRenderSizeWidth;
|
|
|
|
public readonly bool GetFlag(FfxFsr2InitializationFlags flag)
|
|
{
|
|
return (ffxFsrFlags & flag) == flag;
|
|
}
|
|
|
|
public void SetFlag(FfxFsr2InitializationFlags flag, bool value)
|
|
{
|
|
if (value)
|
|
ffxFsrFlags |= flag;
|
|
else
|
|
ffxFsrFlags &= ~flag;
|
|
}
|
|
}
|
|
|
|
[Flags]
|
|
public enum FfxFsr2InitializationFlags
|
|
{
|
|
EnableHighDynamicRange = 1,
|
|
EnableDisplayResolutionMotionVectors = 2,
|
|
EnableMotionVectorsJitterCancellation = 4,
|
|
DepthInverted = 8,
|
|
EnableDepthInfinite = 16, // 0x00000010
|
|
EnableAutoExposure = 32, // 0x00000020
|
|
EnableDynamicResolution = 64, // 0x00000040
|
|
EnableTexture1DUsage = 128, // 0x00000080
|
|
}
|
|
|
|
public struct FSR2TextureTable
|
|
{
|
|
public Texture biasColorMask;
|
|
public Texture colorInput;
|
|
public Texture colorOutput;
|
|
public Texture depth;
|
|
public Texture exposureTexture;
|
|
public Texture motionVectors;
|
|
public Texture reactiveMask;
|
|
public Texture transparencyMask;
|
|
}
|
|
|
|
public enum FSR2Quality
|
|
{
|
|
NativeAA,
|
|
UltraQuality,
|
|
Quality,
|
|
Balanced,
|
|
Performance,
|
|
UltraPerformance,
|
|
}
|
|
|
|
public struct FSR2CommandExecutionData
|
|
{
|
|
public float jitterOffsetX;
|
|
public float jitterOffsetY;
|
|
public float MVScaleX;
|
|
public float MVScaleY;
|
|
public uint renderSizeWidth;
|
|
public uint renderSizeHeight;
|
|
public int enableSharpening;
|
|
public float sharpness;
|
|
public float frameTimeDelta;
|
|
public float preExposure;
|
|
public int reset;
|
|
public float cameraNear;
|
|
public float cameraFar;
|
|
public float cameraFovAngleVertical;
|
|
}
|
|
}
|