Browse Source

Couple of tweaks to facilitate integration

fsr3framegen
Nico de Poel 2 years ago
parent
commit
910621b019
  1. 23
      Runtime/FrameInterpolation/FrameInterpolation.cs
  2. 1
      Runtime/FrameInterpolation/FrameInterpolationContext.cs
  3. 2
      Runtime/OpticalFlow/OpticalFlow.cs
  4. 2
      Runtime/OpticalFlow/OpticalFlowContext.cs
  5. 2
      Runtime/OpticalFlow/OpticalFlowResources.cs

23
Runtime/FrameInterpolation/FrameInterpolation.cs

@ -7,6 +7,29 @@ namespace FidelityFX.FrameGen
{
public static class FrameInterpolation
{
public static FrameInterpolationContext CreateContext(Vector2Int displaySize, Vector2Int maxRenderSize, FrameInterpolationShaders shaders, GraphicsFormat backBufferFormat, InitializationFlags flags = 0)
{
if (SystemInfo.usesReversedZBuffer)
flags |= InitializationFlags.EnableDepthInverted;
else
flags &= ~InitializationFlags.EnableDepthInverted;
var contextDescription = new ContextDescription
{
flags = flags,
maxRenderSize = maxRenderSize,
displaySize = displaySize,
backBufferFormat = backBufferFormat,
shaders = shaders,
};
Debug.Log($"Setting up Frame Interpolation with render size: {maxRenderSize.x}x{maxRenderSize.y}, display size: {displaySize.x}x{displaySize.y}, backbuffer format: {backBufferFormat}, flags: {flags}");
var context = new FrameInterpolationContext();
context.Create(contextDescription);
return context;
}
public struct ContextDescription
{
public InitializationFlags flags;

1
Runtime/FrameInterpolation/FrameInterpolationContext.cs

@ -198,6 +198,7 @@ namespace FidelityFX.FrameGen
// Schedule work for the interpolation command list
_setupPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, renderDispatchSizeX, renderDispatchSizeY);
// TODO delegates are reference types, i.e. this allocates some memory every frame
Action dispatchGameVectorFieldInpaintingPyramid = () =>
{
SetupSpdConstants(dispatchDescription.renderSize, out var dispatchThreadGroupCount);

2
Runtime/OpticalFlow/OpticalFlow.cs

@ -6,7 +6,7 @@ namespace FidelityFX.FrameGen
{
public static class OpticalFlow
{
internal const int MinBlockSize = 8;
public static readonly int MinBlockSize = 8;
internal const int OpticalFlowMaxPyramidLevels = 7;
internal const int HistogramBins = 256;
internal const int HistogramsPerDim = 3;

2
Runtime/OpticalFlow/OpticalFlowContext.cs

@ -36,7 +36,7 @@ namespace FidelityFX.FrameGen
private readonly Vector2Int[] _opticalFlowTextureSizes = new Vector2Int[OpticalFlow.OpticalFlowMaxPyramidLevels];
private readonly CustomSampler _sampler = CustomSampler.Create("Optical Flow");
public void Create(OpticalFlow.ContextDescription contextDescription)
public void Create(in OpticalFlow.ContextDescription contextDescription)
{
_contextDescription = contextDescription;

2
Runtime/OpticalFlow/OpticalFlowResources.cs

@ -31,7 +31,7 @@ namespace FidelityFX.FrameGen
public RenderTexture OpticalFlowSCDPreviousHistogram;
public RenderTexture OpticalFlowSCDTemp;
public void Create(OpticalFlow.ContextDescription contextDescription)
public void Create(in OpticalFlow.ContextDescription contextDescription)
{
Vector2Int opticalFlowInputTextureSize = contextDescription.resolution;
Vector2Int opticalFlowTextureSize = OpticalFlow.GetOpticalFlowTextureSize(contextDescription.resolution, OpticalFlow.MinBlockSize);

Loading…
Cancel
Save