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.
324 lines
26 KiB
324 lines
26 KiB
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
|
|
namespace FidelityFX.FrameGen
|
|
{
|
|
internal abstract class FrameInterpolationPass: FfxPassWithFlags<FrameInterpolation.DispatchDescription, FrameInterpolation.InitializationFlags>
|
|
{
|
|
protected readonly FrameInterpolationResources Resources;
|
|
protected readonly ComputeBuffer Constants;
|
|
|
|
protected FrameInterpolationPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
|
|
: base("Frame Interpolation", contextDescription.flags)
|
|
{
|
|
Resources = resources;
|
|
Constants = constants;
|
|
}
|
|
|
|
protected override void SetupShaderKeywords()
|
|
{
|
|
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(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
|
|
: base(contextDescription, resources, constants)
|
|
{
|
|
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)
|
|
{
|
|
}
|
|
|
|
public void ScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.PrepareDescription prepareParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ = 1)
|
|
{
|
|
commandBuffer.BeginSample(Sampler);
|
|
|
|
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.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants);
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
|
|
|
|
commandBuffer.EndSample(Sampler);
|
|
}
|
|
}
|
|
|
|
internal class FrameInterpolationSetupPass : FrameInterpolationPass
|
|
{
|
|
public FrameInterpolationSetupPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
|
|
: base(contextDescription, resources, constants)
|
|
{
|
|
InitComputeShader("Setup", contextDescription.shaders.setup);
|
|
}
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
|
|
{
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowSceneChangeDetection, dispatchParams.opticalFlowSceneChangeDetection);
|
|
|
|
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<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants);
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
|
|
}
|
|
}
|
|
|
|
internal class FrameInterpolationReconstructPreviousDepthPass : FrameInterpolationPass
|
|
{
|
|
public FrameInterpolationReconstructPreviousDepthPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
|
|
: base(contextDescription, resources, constants)
|
|
{
|
|
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)
|
|
{
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedDepth, Resources.DilatedDepth[frameIndex]);
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, dispatchParams.InterpolationSource);
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavReconstructedDepthInterpolatedFrame, Resources.ReconstructedDepthInterpolatedFrame);
|
|
|
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants);
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
|
|
}
|
|
}
|
|
|
|
internal class FrameInterpolationGameMotionVectorFieldPass : FrameInterpolationPass
|
|
{
|
|
public FrameInterpolationGameMotionVectorFieldPass(in 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, 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.SrvDilatedDepth, Resources.DilatedDepth[frameIndex]);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvPreviousInterpolationSource, Resources.PreviousInterpolationSource);
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, dispatchParams.InterpolationSource);
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavGameMotionVectorFieldX, Resources.GameMotionVectorFieldX);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavGameMotionVectorFieldY, Resources.GameMotionVectorFieldY);
|
|
|
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants);
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
|
|
}
|
|
}
|
|
|
|
internal class FrameInterpolationOpticalFlowVectorFieldPass : FrameInterpolationPass
|
|
{
|
|
public FrameInterpolationOpticalFlowVectorFieldPass(in 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, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
|
|
{
|
|
if (dispatchParams.opticalFlowScale.x > 0f)
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowVector, dispatchParams.opticalFlowVector);
|
|
else
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowVector, BuiltinRenderTextureType.None);
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowConfidence, BuiltinRenderTextureType.None);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedDepth, Resources.DilatedDepth[frameIndex]);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvPreviousInterpolationSource, Resources.PreviousInterpolationSource);
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, dispatchParams.InterpolationSource);
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOpticalFlowMotionVectorFieldX, Resources.OpticalFlowMotionVectorFieldX);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOpticalFlowMotionVectorFieldY, Resources.OpticalFlowMotionVectorFieldY);
|
|
|
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants);
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
|
|
}
|
|
}
|
|
|
|
internal class FrameInterpolationDisocclusionMaskPass : FrameInterpolationPass
|
|
{
|
|
public FrameInterpolationDisocclusionMaskPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
|
|
: base(contextDescription, resources, constants)
|
|
{
|
|
InitComputeShader("Disocclusion Mask", contextDescription.shaders.disocclusionMask);
|
|
}
|
|
|
|
protected override void DoScheduleDispatch(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.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvReconstructedDepthPreviousFrame, Resources.ReconstructedDepth[frameIndex]);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedDepth, Resources.DilatedDepth[frameIndex]);
|
|
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<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants);
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
|
|
}
|
|
}
|
|
|
|
internal class FrameInterpolationInterpolationPass : FrameInterpolationPass
|
|
{
|
|
public FrameInterpolationInterpolationPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
|
|
: base(contextDescription, resources, constants)
|
|
{
|
|
InitComputeShader("Interpolation", contextDescription.shaders.interpolation);
|
|
}
|
|
|
|
protected override void DoScheduleDispatch(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.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowMotionVectorFieldX, Resources.OpticalFlowMotionVectorFieldX);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowMotionVectorFieldY, Resources.OpticalFlowMotionVectorFieldY);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvPreviousInterpolationSource, Resources.PreviousInterpolationSource);
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, dispatchParams.InterpolationSource);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDisocclusionMask, Resources.DisocclusionMask);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInpaintingPyramid, Resources.InpaintingPyramid);
|
|
commandBuffer.SetComputeBufferParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCounters, Resources.Counters);
|
|
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOutput, dispatchParams.output);
|
|
|
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants);
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
|
|
}
|
|
}
|
|
|
|
internal class FrameInterpolationInpaintingPyramidPass : FrameInterpolationPass
|
|
{
|
|
private readonly ComputeBuffer _spdConstants;
|
|
|
|
public FrameInterpolationInpaintingPyramidPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants, ComputeBuffer spdConstants)
|
|
: base(contextDescription, resources, constants)
|
|
{
|
|
_spdConstants = spdConstants;
|
|
|
|
InitComputeShader("Inpainting Pyramid", contextDescription.shaders.inpaintingPyramid);
|
|
}
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
|
|
{
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOutput, dispatchParams.output);
|
|
|
|
commandBuffer.SetComputeBufferParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavCounters, Resources.Counters);
|
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap0, Resources.InpaintingPyramid, 0);
|
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap1, Resources.InpaintingPyramid, 1);
|
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap2, Resources.InpaintingPyramid, 2);
|
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap3, Resources.InpaintingPyramid, 3);
|
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap4, Resources.InpaintingPyramid, 4);
|
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap5, Resources.InpaintingPyramid, 5);
|
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap6, Resources.InpaintingPyramid, 6);
|
|
|
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants);
|
|
commandBuffer.SetComputeConstantBufferParam<FfxSpd.SpdConstants>(ComputeShader, FrameInterpolationShaderIDs.CbInpaintingPyramid, _spdConstants);
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
|
|
}
|
|
}
|
|
|
|
internal class FrameInterpolationInpaintingPass : FrameInterpolationPass
|
|
{
|
|
public FrameInterpolationInpaintingPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
|
|
: base(contextDescription, resources, constants)
|
|
{
|
|
InitComputeShader("Inpainting", contextDescription.shaders.inpainting);
|
|
}
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ)
|
|
{
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowSceneChangeDetection, dispatchParams.opticalFlowSceneChangeDetection);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInpaintingPyramid, Resources.InpaintingPyramid);
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvPresentBackbuffer, dispatchParams.currentBackBuffer);
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, dispatchParams.InterpolationSource);
|
|
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOutput, dispatchParams.output);
|
|
|
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants);
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
|
|
}
|
|
}
|
|
|
|
internal class FrameInterpolationGameVectorFieldInpaintingPyramidPass : FrameInterpolationPass
|
|
{
|
|
private readonly ComputeBuffer _spdConstants;
|
|
|
|
public FrameInterpolationGameVectorFieldInpaintingPyramidPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants, ComputeBuffer spdConstants)
|
|
: base(contextDescription, resources, constants)
|
|
{
|
|
_spdConstants = spdConstants;
|
|
|
|
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)
|
|
{
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldX, Resources.GameMotionVectorFieldX);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY);
|
|
|
|
commandBuffer.SetComputeBufferParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavCounters, Resources.Counters);
|
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap0, Resources.InpaintingPyramid, 0);
|
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap1, Resources.InpaintingPyramid, 1);
|
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap2, Resources.InpaintingPyramid, 2);
|
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap3, Resources.InpaintingPyramid, 3);
|
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap4, Resources.InpaintingPyramid, 4);
|
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap5, Resources.InpaintingPyramid, 5);
|
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap6, Resources.InpaintingPyramid, 6);
|
|
|
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants);
|
|
commandBuffer.SetComputeConstantBufferParam<FfxSpd.SpdConstants>(ComputeShader, FrameInterpolationShaderIDs.CbInpaintingPyramid, _spdConstants);
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
|
|
}
|
|
}
|
|
|
|
internal class FrameInterpolationDebugViewPass : FrameInterpolationPass
|
|
{
|
|
public FrameInterpolationDebugViewPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants)
|
|
: base(contextDescription, resources, constants)
|
|
{
|
|
InitComputeShader("Debug View", contextDescription.shaders.debugView);
|
|
}
|
|
|
|
protected override void DoScheduleDispatch(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.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowMotionVectorFieldX, Resources.OpticalFlowMotionVectorFieldX);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowMotionVectorFieldY, Resources.OpticalFlowMotionVectorFieldY);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDisocclusionMask, Resources.DisocclusionMask);
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvPresentBackbuffer, dispatchParams.currentBackBuffer);
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInpaintingPyramid, Resources.InpaintingPyramid);
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, dispatchParams.InterpolationSource);
|
|
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOutput, dispatchParams.output);
|
|
|
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants);
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ);
|
|
}
|
|
}
|
|
}
|