|
|
@ -3,7 +3,7 @@ using UnityEngine.Rendering; |
|
|
|
|
|
|
|
|
namespace FidelityFX.FrameGen |
|
|
namespace FidelityFX.FrameGen |
|
|
{ |
|
|
{ |
|
|
internal abstract class FrameInterpolationPass: FfxPassWithFlags<FrameInterpolation.DispatchDescription, FrameInterpolation.InitializationFlags> |
|
|
|
|
|
|
|
|
internal abstract class FrameInterpolationPass: FfxPassWithFlags<FrameInterpolation.InitializationFlags> |
|
|
{ |
|
|
{ |
|
|
protected readonly FrameInterpolationResources Resources; |
|
|
protected readonly FrameInterpolationResources Resources; |
|
|
protected readonly ComputeBuffer Constants; |
|
|
protected readonly ComputeBuffer Constants; |
|
|
@ -15,6 +15,16 @@ namespace FidelityFX.FrameGen |
|
|
Constants = constants; |
|
|
Constants = constants; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void ScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ = 1) |
|
|
|
|
|
{ |
|
|
|
|
|
using (ProfilerSample(commandBuffer)) |
|
|
|
|
|
{ |
|
|
|
|
|
Dispatch(commandBuffer, dispatchParams, frameIndex, dispatchX, dispatchY, dispatchZ); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected abstract void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ); |
|
|
|
|
|
|
|
|
protected override void SetupShaderKeywords() |
|
|
protected override void SetupShaderKeywords() |
|
|
{ |
|
|
{ |
|
|
if ((Flags & FrameInterpolation.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) ComputeShader.EnableKeyword("FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS"); |
|
|
if ((Flags & FrameInterpolation.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) ComputeShader.EnableKeyword("FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS"); |
|
|
@ -31,26 +41,25 @@ namespace FidelityFX.FrameGen |
|
|
InitComputeShader("Reconstruct and Dilate", contextDescription.shaders.reconstructAndDilate); |
|
|
InitComputeShader("Reconstruct and Dilate", contextDescription.shaders.reconstructAndDilate); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
|
|
|
|
|
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void ScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.PrepareDescription prepareParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ = 1) |
|
|
public void ScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.PrepareDescription prepareParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ = 1) |
|
|
{ |
|
|
{ |
|
|
commandBuffer.BeginSample(Sampler); |
|
|
|
|
|
|
|
|
using (ProfilerSample(commandBuffer)) |
|
|
|
|
|
{ |
|
|
|
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInputMotionVectors, prepareParams.motionVectors); |
|
|
|
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInputDepth, prepareParams.depth); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInputMotionVectors, prepareParams.motionVectors); |
|
|
|
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInputDepth, prepareParams.depth); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavReconstructedDepthPreviousFrame, Resources.ReconstructedDepth[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavDilatedDepth, Resources.DilatedDepth[frameIndex]); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavReconstructedDepthPreviousFrame, Resources.ReconstructedDepth[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavDilatedDepth, Resources.DilatedDepth[frameIndex]); |
|
|
|
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants); |
|
|
|
|
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
|
|
|
|
|
|
|
|
|
|
|
commandBuffer.EndSample(Sampler); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants); |
|
|
|
|
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -62,7 +71,7 @@ namespace FidelityFX.FrameGen |
|
|
InitComputeShader("Setup", contextDescription.shaders.setup); |
|
|
InitComputeShader("Setup", contextDescription.shaders.setup); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
|
|
|
|
|
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowSceneChangeDetection, dispatchParams.opticalFlowSceneChangeDetection); |
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowSceneChangeDetection, dispatchParams.opticalFlowSceneChangeDetection); |
|
|
|
|
|
|
|
|
@ -87,7 +96,7 @@ namespace FidelityFX.FrameGen |
|
|
InitComputeShader("Reconstruct Previous Depth", contextDescription.shaders.reconstructPreviousDepth); |
|
|
InitComputeShader("Reconstruct Previous Depth", contextDescription.shaders.reconstructPreviousDepth); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
|
|
|
|
|
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedDepth, Resources.DilatedDepth[frameIndex]); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedDepth, Resources.DilatedDepth[frameIndex]); |
|
|
@ -109,7 +118,7 @@ namespace FidelityFX.FrameGen |
|
|
InitComputeShader("Game Motion Vector Field", contextDescription.shaders.gameMotionVectorField); |
|
|
InitComputeShader("Game Motion Vector Field", contextDescription.shaders.gameMotionVectorField); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
|
|
|
|
|
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedDepth, Resources.DilatedDepth[frameIndex]); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedDepth, Resources.DilatedDepth[frameIndex]); |
|
|
@ -133,7 +142,7 @@ namespace FidelityFX.FrameGen |
|
|
InitComputeShader("Optical Flow Vector Field", contextDescription.shaders.opticalFlowVectorField); |
|
|
InitComputeShader("Optical Flow Vector Field", contextDescription.shaders.opticalFlowVectorField); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
|
|
|
|
|
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
if (dispatchParams.opticalFlowScale.x > 0f) |
|
|
if (dispatchParams.opticalFlowScale.x > 0f) |
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowVector, dispatchParams.opticalFlowVector); |
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowVector, dispatchParams.opticalFlowVector); |
|
|
@ -162,7 +171,7 @@ namespace FidelityFX.FrameGen |
|
|
InitComputeShader("Disocclusion Mask", contextDescription.shaders.disocclusionMask); |
|
|
InitComputeShader("Disocclusion Mask", contextDescription.shaders.disocclusionMask); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
|
|
|
|
|
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldX, Resources.GameMotionVectorFieldX); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldX, Resources.GameMotionVectorFieldX); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY); |
|
|
@ -187,7 +196,7 @@ namespace FidelityFX.FrameGen |
|
|
InitComputeShader("Interpolation", contextDescription.shaders.interpolation); |
|
|
InitComputeShader("Interpolation", contextDescription.shaders.interpolation); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
|
|
|
|
|
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldX, Resources.GameMotionVectorFieldX); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldX, Resources.GameMotionVectorFieldX); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY); |
|
|
@ -219,7 +228,7 @@ namespace FidelityFX.FrameGen |
|
|
InitComputeShader("Inpainting Pyramid", contextDescription.shaders.inpaintingPyramid); |
|
|
InitComputeShader("Inpainting Pyramid", contextDescription.shaders.inpaintingPyramid); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
|
|
|
|
|
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOutput, dispatchParams.output); |
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOutput, dispatchParams.output); |
|
|
|
|
|
|
|
|
@ -247,7 +256,7 @@ namespace FidelityFX.FrameGen |
|
|
InitComputeShader("Inpainting", contextDescription.shaders.inpainting); |
|
|
InitComputeShader("Inpainting", contextDescription.shaders.inpainting); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
|
|
|
|
|
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowSceneChangeDetection, dispatchParams.opticalFlowSceneChangeDetection); |
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowSceneChangeDetection, dispatchParams.opticalFlowSceneChangeDetection); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInpaintingPyramid, Resources.InpaintingPyramid); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInpaintingPyramid, Resources.InpaintingPyramid); |
|
|
@ -274,7 +283,7 @@ namespace FidelityFX.FrameGen |
|
|
InitComputeShader("Game Vector Field Inpainting Pyramid", contextDescription.shaders.gameVectorFieldInpaintingPyramid); |
|
|
InitComputeShader("Game Vector Field Inpainting Pyramid", contextDescription.shaders.gameVectorFieldInpaintingPyramid); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
|
|
|
|
|
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldX, Resources.GameMotionVectorFieldX); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldX, Resources.GameMotionVectorFieldX); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY); |
|
|
@ -303,7 +312,7 @@ namespace FidelityFX.FrameGen |
|
|
InitComputeShader("Debug View", contextDescription.shaders.debugView); |
|
|
InitComputeShader("Debug View", contextDescription.shaders.debugView); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
|
|
|
|
|
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldX, Resources.GameMotionVectorFieldX); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldX, Resources.GameMotionVectorFieldX); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY); |
|
|
|