Browse Source

Set up pass classes and instances

fsr3framegen
Nico de Poel 2 years ago
parent
commit
e9c46dfdd7
  1. 16
      Runtime/FrameInterpolation/FrameInterpolationContext.cs
  2. 167
      Runtime/FrameInterpolation/FrameInterpolationPass.cs
  3. 1
      Shaders/ffx_frameinterpolation_reconstruct_and_dilate_pass.compute

16
Runtime/FrameInterpolation/FrameInterpolationContext.cs

@ -15,7 +15,7 @@ namespace FidelityFX.FrameGen
private FrameInterpolationPass _gameMotionVectorFieldPass;
private FrameInterpolationPass _opticalFlowVectorFieldPass;
private FrameInterpolationPass _disocclusionMaskPass;
private FrameInterpolationPass _scfiPass;
private FrameInterpolationPass _interpolationPass;
private FrameInterpolationPass _inpaintingPyramidPass;
private FrameInterpolationPass _inpaintingPass;
private FrameInterpolationPass _gameVectorFieldInpaintingPyramidPass;
@ -61,7 +61,17 @@ namespace FidelityFX.FrameGen
private void CreatePasses()
{
// TODO
_reconstructAndDilatePass = new FrameInterpolationReconstructAndDilatePass(_contextDescription, _resources, _frameInterpolationConstantsBuffer);
_setupPass = new FrameInterpolationSetupPass(_contextDescription, _resources, _frameInterpolationConstantsBuffer);
_reconstructPreviousDepthPass = new FrameInterpolationReconstructPreviousDepthPass(_contextDescription, _resources, _frameInterpolationConstantsBuffer);
_gameMotionVectorFieldPass = new FrameInterpolationGameMotionVectorFieldPass(_contextDescription, _resources, _frameInterpolationConstantsBuffer);
_opticalFlowVectorFieldPass = new FrameInterpolationOpticalFlowVectorFieldPass(_contextDescription, _resources, _frameInterpolationConstantsBuffer);
_disocclusionMaskPass = new FrameInterpolationDisocclusionMaskPass(_contextDescription, _resources, _frameInterpolationConstantsBuffer);
_interpolationPass = new FrameInterpolationInterpolationPass(_contextDescription, _resources, _frameInterpolationConstantsBuffer);
_inpaintingPyramidPass = new FrameInterpolationInpaintingPyramidPass(_contextDescription, _resources, _frameInterpolationConstantsBuffer);
_inpaintingPass = new FrameInterpolationInpaintingPass(_contextDescription, _resources, _frameInterpolationConstantsBuffer);
_gameVectorFieldInpaintingPyramidPass = new FrameInterpolationGameVectorFieldInpaintingPyramidPass(_contextDescription, _resources, _frameInterpolationConstantsBuffer);
_debugViewPass = new FrameInterpolationDebugViewPass(_contextDescription, _resources, _frameInterpolationConstantsBuffer);
}
public void Destroy()
@ -70,7 +80,7 @@ namespace FidelityFX.FrameGen
DestroyPass(ref _gameVectorFieldInpaintingPyramidPass);
DestroyPass(ref _inpaintingPass);
DestroyPass(ref _inpaintingPyramidPass);
DestroyPass(ref _scfiPass);
DestroyPass(ref _interpolationPass);
DestroyPass(ref _disocclusionMaskPass);
DestroyPass(ref _opticalFlowVectorFieldPass);
DestroyPass(ref _gameMotionVectorFieldPass);

167
Runtime/FrameInterpolation/FrameInterpolationPass.cs

@ -27,16 +27,21 @@ namespace FidelityFX.FrameGen
{
}
public void ScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ = 1)
public void ScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ = 1)
{
commandBuffer.BeginSample(_sampler);
DoScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchX, dispatchY, dispatchZ);
commandBuffer.EndSample(_sampler);
}
protected abstract void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ);
protected abstract void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ);
protected void InitComputeShader(string passName, ComputeShader shader)
{
InitComputeShader(passName, shader, ContextDescription.flags);
}
private void InitComputeShader(string passName, ComputeShader shader, FrameInterpolation.InitializationFlags flags)
{
if (shader == null)
{
@ -47,7 +52,163 @@ namespace FidelityFX.FrameGen
KernelIndex = ComputeShader.FindKernel("CS");
_sampler = CustomSampler.Create(passName);
// TODO: shader variants
if ((flags & FrameInterpolation.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) ComputeShader.EnableKeyword("FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS");
if ((flags & FrameInterpolation.InitializationFlags.EnableJitterMotionVectors) != 0) ComputeShader.EnableKeyword("FFX_FRAMEINTERPOLATION_OPTION_JITTERED_MOTION_VECTORS");
if ((flags & FrameInterpolation.InitializationFlags.EnableDepthInverted) != 0) ComputeShader.EnableKeyword("FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH");
}
}
internal class FrameInterpolationReconstructAndDilatePass : FrameInterpolationPass
{
public FrameInterpolationReconstructAndDilatePass(FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants)
{
InitComputeShader("Reconstruct and Dilate", contextDescription.shaders.reconstructAndDilate);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
}
}
internal class FrameInterpolationSetupPass : FrameInterpolationPass
{
public FrameInterpolationSetupPass(FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants)
{
InitComputeShader("Setup", contextDescription.shaders.setup);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
}
}
internal class FrameInterpolationReconstructPreviousDepthPass : FrameInterpolationPass
{
public FrameInterpolationReconstructPreviousDepthPass(FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants)
{
InitComputeShader("Reconstruct Previous Depth", contextDescription.shaders.reconstructPreviousDepth);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
}
}
internal class FrameInterpolationGameMotionVectorFieldPass : FrameInterpolationPass
{
public FrameInterpolationGameMotionVectorFieldPass(FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants)
{
InitComputeShader("Game Motion Vector Field", contextDescription.shaders.gameMotionVectorField);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
}
}
internal class FrameInterpolationOpticalFlowVectorFieldPass : FrameInterpolationPass
{
public FrameInterpolationOpticalFlowVectorFieldPass(FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants)
{
InitComputeShader("Optical Flow Vector Field", contextDescription.shaders.opticalFlowVectorField);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
}
}
internal class FrameInterpolationDisocclusionMaskPass : FrameInterpolationPass
{
public FrameInterpolationDisocclusionMaskPass(FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants)
{
InitComputeShader("Disocclusion Mask", contextDescription.shaders.disocclusionMask);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
}
}
internal class FrameInterpolationInterpolationPass : FrameInterpolationPass
{
public FrameInterpolationInterpolationPass(FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants)
{
InitComputeShader("Interpolation", contextDescription.shaders.interpolation);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
}
}
internal class FrameInterpolationInpaintingPyramidPass : FrameInterpolationPass
{
public FrameInterpolationInpaintingPyramidPass(FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants)
{
InitComputeShader("Inpainting Pyramid", contextDescription.shaders.inpaintingPyramid);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
}
}
internal class FrameInterpolationInpaintingPass : FrameInterpolationPass
{
public FrameInterpolationInpaintingPass(FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants)
{
InitComputeShader("Inpainting", contextDescription.shaders.inpainting);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
}
}
internal class FrameInterpolationGameVectorFieldInpaintingPyramidPass : FrameInterpolationPass
{
public FrameInterpolationGameVectorFieldInpaintingPyramidPass(FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants)
{
InitComputeShader("Game Vector Field Inpainting Pyramid", contextDescription.shaders.gameVectorFieldInpaintingPyramid);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
}
}
internal class FrameInterpolationDebugViewPass : FrameInterpolationPass
{
public FrameInterpolationDebugViewPass(FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants)
{
InitComputeShader("Debug View", contextDescription.shaders.debugView);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
}
}
}

1
Shaders/ffx_frameinterpolation_reconstruct_and_dilate_pass.compute

@ -23,6 +23,7 @@
#pragma kernel CS
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_JITTERED_MOTION_VECTORS
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH
#pragma use_dxc

Loading…
Cancel
Save