|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.Profiling; |
|
|
|
using UnityEngine.Rendering; |
|
|
|
@ -15,6 +16,8 @@ namespace FidelityFX.FrameGen |
|
|
|
protected int KernelIndex; |
|
|
|
|
|
|
|
protected CustomSampler Sampler; |
|
|
|
|
|
|
|
protected bool AsyncSupported => (ContextDescription.flags & FrameInterpolation.InitializationFlags.EnableAsyncSupport) == FrameInterpolation.InitializationFlags.EnableAsyncSupport; |
|
|
|
|
|
|
|
protected FrameInterpolationPass(FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants) |
|
|
|
{ |
|
|
|
@ -72,7 +75,22 @@ namespace FidelityFX.FrameGen |
|
|
|
|
|
|
|
public void ScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.PrepareDescription prepareParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
|
{ |
|
|
|
int doubleBufferId = AsyncSupported ? frameIndex : 0; |
|
|
|
|
|
|
|
commandBuffer.BeginSample(Sampler); |
|
|
|
|
|
|
|
ref var mvs = ref prepareParams.motionVectors; |
|
|
|
ref var depth = ref prepareParams.depth; |
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInputMotionVectors, mvs.RenderTarget, mvs.MipLevel, mvs.SubElement); |
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInputDepth, depth.RenderTarget, depth.MipLevel, depth.SubElement); |
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavReconstructedDepthPreviousFrame, Resources.ReconstructedDepth[doubleBufferId]); |
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavDilatedMotionVectors, Resources.DilatedMotionVectors[doubleBufferId]); |
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavDilatedDepth, Resources.DilatedDepth[doubleBufferId]); |
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants, 0, Marshal.SizeOf<FrameInterpolation.Constants>()); |
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
|
|
|
|
|
|
|
commandBuffer.EndSample(Sampler); |
|
|
|
} |
|
|
|
|