Browse Source

Implemented a bunch more FI passes

fsr3framegen
Nico de Poel 2 years ago
parent
commit
4cd63e62a8
  1. 112
      Runtime/FrameInterpolation/FrameInterpolationPass.cs
  2. 3
      Runtime/FrameInterpolation/FrameInterpolationShaderIDs.cs

112
Runtime/FrameInterpolation/FrameInterpolationPass.cs

@ -106,7 +106,19 @@ namespace FidelityFX.FrameGen
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
ref var scd = ref dispatchParams.opticalFlowSceneChangeDetection;
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowSceneChangeDetection, scd.RenderTarget, scd.MipLevel, scd.SubElement);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavGameMotionVectorFieldX, Resources.GameMotionVectorFieldX);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavGameMotionVectorFieldY, Resources.GameMotionVectorFieldY);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOpticalFlowMotionVectorFieldX, Resources.OpticalFlowMotionVectorFieldX);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOpticalFlowMotionVectorFieldY, Resources.OpticalFlowMotionVectorFieldY);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavDisocclusionMask, Resources.DisocclusionMask);
commandBuffer.SetComputeBufferParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavCounters, Resources.Counters);
commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants, 0, Marshal.SizeOf<FrameInterpolation.Constants>());
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
}
}
@ -120,7 +132,23 @@ namespace FidelityFX.FrameGen
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
int doubleBufferId = AsyncSupported ? frameIndex : 0;
ref var backBuf = ref dispatchParams.currentBackBuffer;
ref var bbNoHud = ref dispatchParams.currentBackBuffer_HUDLess;
// TODO: verify that we need the buffers from *this* frame (probably yes)
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[doubleBufferId]);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedDepth, Resources.DilatedDepth[doubleBufferId]);
if (bbNoHud.IsValid)
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, bbNoHud.RenderTarget, bbNoHud.MipLevel, bbNoHud.SubElement);
else
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, backBuf.RenderTarget, backBuf.MipLevel, backBuf.SubElement);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavReconstructedDepthInterpolatedFrame, Resources.ReconstructedDepthInterpolatedFrame);
commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants, 0, Marshal.SizeOf<FrameInterpolation.Constants>());
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
}
}
@ -134,7 +162,24 @@ namespace FidelityFX.FrameGen
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
int doubleBufferId = AsyncSupported ? frameIndex : 0;
ref var backBuf = ref dispatchParams.currentBackBuffer;
ref var bbNoHud = ref dispatchParams.currentBackBuffer_HUDLess;
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[doubleBufferId]);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedDepth, Resources.DilatedDepth[doubleBufferId]);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvPreviousInterpolationSource, Resources.PreviousInterpolationSource);
if (bbNoHud.IsValid)
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, bbNoHud.RenderTarget, bbNoHud.MipLevel, bbNoHud.SubElement);
else
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, backBuf.RenderTarget, backBuf.MipLevel, backBuf.SubElement);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavGameMotionVectorFieldX, Resources.GameMotionVectorFieldX);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavGameMotionVectorFieldY, Resources.GameMotionVectorFieldY);
commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants, 0, Marshal.SizeOf<FrameInterpolation.Constants>());
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
}
}
@ -148,7 +193,31 @@ namespace FidelityFX.FrameGen
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
int doubleBufferId = AsyncSupported ? frameIndex : 0;
ref var ofVector = ref dispatchParams.opticalFlowVector;
ref var backBuf = ref dispatchParams.currentBackBuffer;
ref var bbNoHud = ref dispatchParams.currentBackBuffer_HUDLess;
if (dispatchParams.opticalFlowScale.x > 0f)
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowVector, ofVector.RenderTarget, ofVector.MipLevel, ofVector.SubElement);
else
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowVector, BuiltinRenderTextureType.None);
// TODO this might error... if so, bind an empty placeholder resource
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowConfidence, BuiltinRenderTextureType.None);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedDepth, Resources.DilatedDepth[doubleBufferId]);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvPreviousInterpolationSource, Resources.PreviousInterpolationSource);
if (bbNoHud.IsValid)
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, bbNoHud.RenderTarget, bbNoHud.MipLevel, bbNoHud.SubElement);
else
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, backBuf.RenderTarget, backBuf.MipLevel, backBuf.SubElement);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOpticalFlowMotionVectorFieldX, Resources.OpticalFlowMotionVectorFieldX);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOpticalFlowMotionVectorFieldY, Resources.OpticalFlowMotionVectorFieldY);
commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants, 0, Marshal.SizeOf<FrameInterpolation.Constants>());
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
}
}
@ -162,7 +231,20 @@ namespace FidelityFX.FrameGen
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
int doubleBufferId = AsyncSupported ? frameIndex : 0;
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldX, Resources.GameMotionVectorFieldX);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvReconstructedDepthPreviousFrame, Resources.ReconstructedDepth[doubleBufferId]);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedDepth, Resources.DilatedDepth[doubleBufferId]);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvReconstructedDepthInterpolatedFrame, Resources.ReconstructedDepthInterpolatedFrame);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInpaintingPyramid, Resources.InpaintingPyramid);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavDisocclusionMask, Resources.DisocclusionMask);
commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants, 0, Marshal.SizeOf<FrameInterpolation.Constants>());
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
}
}
@ -177,6 +259,10 @@ namespace FidelityFX.FrameGen
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants, 0, Marshal.SizeOf<FrameInterpolation.Constants>());
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
}
}
@ -191,6 +277,10 @@ namespace FidelityFX.FrameGen
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants, 0, Marshal.SizeOf<FrameInterpolation.Constants>());
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
}
}
@ -205,6 +295,10 @@ namespace FidelityFX.FrameGen
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants, 0, Marshal.SizeOf<FrameInterpolation.Constants>());
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
}
}
@ -219,6 +313,10 @@ namespace FidelityFX.FrameGen
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants, 0, Marshal.SizeOf<FrameInterpolation.Constants>());
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
}
}
@ -233,6 +331,10 @@ namespace FidelityFX.FrameGen
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
{
throw new NotImplementedException();
commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants, 0, Marshal.SizeOf<FrameInterpolation.Constants>());
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
}
}
}

3
Runtime/FrameInterpolation/FrameInterpolationShaderIDs.cs

@ -12,6 +12,7 @@ namespace FidelityFX.FrameGen
public static readonly int SrvReconstructedDepthPreviousFrame = Shader.PropertyToID("r_reconstructed_depth_previous_frame");
public static readonly int SrvReconstructedDepthInterpolatedFrame = Shader.PropertyToID("r_reconstructed_depth_interpolated_frame");
public static readonly int SrvPreviousInterpolationSource = Shader.PropertyToID("r_previous_interpolation_source");
public static readonly int SrvCurrentInterpolationSource = Shader.PropertyToID("r_current_interpolation_source");
public static readonly int SrvDisocclusionMask = Shader.PropertyToID("r_disocclusion_mask");
public static readonly int SrvGameMotionVectorFieldX = Shader.PropertyToID("r_game_motion_vector_field_x");
public static readonly int SrvGameMotionVectorFieldY = Shader.PropertyToID("r_game_motion_vector_field_y");
@ -35,7 +36,7 @@ namespace FidelityFX.FrameGen
public static readonly int UavGameMotionVectorFieldY = Shader.PropertyToID("rw_game_motion_vector_field_y");
public static readonly int UavOpticalFlowMotionVectorFieldX = Shader.PropertyToID("rw_optical_flow_motion_vector_field_x");
public static readonly int UavOpticalFlowMotionVectorFieldY = Shader.PropertyToID("rw_optical_flow_motion_vector_field_y");
public static readonly int UavCounter = Shader.PropertyToID("rw_counters");
public static readonly int UavCounters = Shader.PropertyToID("rw_counters");
public static readonly int UavInpaintingPyramidMipmap0 = Shader.PropertyToID("rw_inpainting_pyramid0");
public static readonly int UavInpaintingPyramidMipmap1 = Shader.PropertyToID("rw_inpainting_pyramid1");
public static readonly int UavInpaintingPyramidMipmap2 = Shader.PropertyToID("rw_inpainting_pyramid2");

Loading…
Cancel
Save