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.
107 lines
3.4 KiB
107 lines
3.4 KiB
using System.Collections.Generic;
|
|
|
|
namespace UnityEngine.Rendering.HighDefinition.AMD.FSR3
|
|
{
|
|
public class FSR3Upscaler: UpscalerPlugin
|
|
{
|
|
private static FSR3GraphicsDevice sGraphicsDeviceInstance;
|
|
|
|
public override bool Load() => true;
|
|
|
|
public override bool IsLoaded() => true;
|
|
|
|
public override GraphicsDevice CreateGraphicsDevice()
|
|
{
|
|
if (sGraphicsDeviceInstance != null)
|
|
{
|
|
sGraphicsDeviceInstance.Shutdown();
|
|
sGraphicsDeviceInstance.Initialize();
|
|
return sGraphicsDeviceInstance;
|
|
}
|
|
|
|
var graphicsDevice = new FSR3GraphicsDevice();
|
|
if (graphicsDevice.Initialize())
|
|
{
|
|
sGraphicsDeviceInstance = graphicsDevice;
|
|
return graphicsDevice;
|
|
}
|
|
|
|
Debug.LogWarning("Failed to initialize FSR3 Graphics Device");
|
|
return null;
|
|
}
|
|
|
|
public override GraphicsDevice device => sGraphicsDeviceInstance;
|
|
}
|
|
|
|
public class FSR3GraphicsDevice : GraphicsDevice
|
|
{
|
|
private static readonly Stack<FSR3Context> sContextPool = new();
|
|
|
|
internal bool Initialize()
|
|
{
|
|
// TODO
|
|
return false;
|
|
}
|
|
|
|
internal void Shutdown()
|
|
{
|
|
// TODO
|
|
}
|
|
|
|
public override FSR2Context CreateFeature(CommandBuffer cmd, in FSR2CommandInitializationData initSettings)
|
|
{
|
|
var context = sContextPool.Count != 0 ? sContextPool.Pop() : new FSR3Context();
|
|
context.Init(initSettings); // TODO might need some way to distinguish between contexts (see featureSlot)
|
|
return context;
|
|
}
|
|
|
|
public override void DestroyFeature(CommandBuffer cmd, FSR2Context fsrContext)
|
|
{
|
|
var context = (FSR3Context)fsrContext;
|
|
context.Reset();
|
|
sContextPool.Push(context);
|
|
}
|
|
|
|
public override void ExecuteFSR2(CommandBuffer cmd, FSR2Context fsrContext, in FSR2TextureTable textures)
|
|
{
|
|
((FSR3Context)fsrContext).Draw(cmd, in textures);
|
|
}
|
|
|
|
public override bool GetRenderResolutionFromQualityMode(FSR2Quality qualityMode, uint displayWidth, uint displayHeight, out uint renderWidth, out uint renderHeight)
|
|
{
|
|
throw new System.NotImplementedException();
|
|
}
|
|
|
|
public override float GetUpscaleRatioFromQualityMode(FSR2Quality qualityMode)
|
|
{
|
|
throw new System.NotImplementedException();
|
|
}
|
|
}
|
|
|
|
public class FSR3Context : FSR2Context
|
|
{
|
|
private FSR2CommandInitializationData _initData;
|
|
public override ref FSR2CommandInitializationData initData => ref _initData;
|
|
|
|
private FSR2CommandExecutionData _executeData;
|
|
public override ref FSR2CommandExecutionData executeData => ref _executeData;
|
|
|
|
internal void Init(in FSR2CommandInitializationData initSettings)
|
|
{
|
|
// TODO: create internal context data
|
|
_initData = initSettings;
|
|
}
|
|
|
|
internal void Reset()
|
|
{
|
|
// TODO: destroy internal context data
|
|
_initData = new FSR2CommandInitializationData();
|
|
_executeData = new FSR2CommandExecutionData();
|
|
}
|
|
|
|
internal void Draw(CommandBuffer cmd, in FSR2TextureTable textures)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|