|
|
@ -28,14 +28,14 @@ namespace FidelityFX.OpticalFlow |
|
|
{ |
|
|
{ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void ScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
|
|
|
|
|
|
public void ScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ = 1) |
|
|
{ |
|
|
{ |
|
|
commandBuffer.BeginSample(_sampler); |
|
|
commandBuffer.BeginSample(_sampler); |
|
|
DoScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchX, dispatchY); |
|
|
|
|
|
|
|
|
DoScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchX, dispatchY, dispatchZ); |
|
|
commandBuffer.EndSample(_sampler); |
|
|
commandBuffer.EndSample(_sampler); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected abstract void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY); |
|
|
|
|
|
|
|
|
protected abstract void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ); |
|
|
|
|
|
|
|
|
protected void InitComputeShader(string passName, ComputeShader shader) |
|
|
protected void InitComputeShader(string passName, ComputeShader shader) |
|
|
{ |
|
|
{ |
|
|
@ -58,7 +58,7 @@ namespace FidelityFX.OpticalFlow |
|
|
InitComputeShader("Prepare Luma", contextDescription.shaders.prepareLuma); |
|
|
InitComputeShader("Prepare Luma", contextDescription.shaders.prepareLuma); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
ref var color = ref dispatchParams.color; |
|
|
ref var color = ref dispatchParams.color; |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); |
|
|
@ -67,7 +67,7 @@ namespace FidelityFX.OpticalFlow |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, OpticalFlowShaderIDs.CbOpticalFlow, Constants, 0, Marshal.SizeOf<OpticalFlow.OpticalFlowConstants>()); |
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, OpticalFlowShaderIDs.CbOpticalFlow, Constants, 0, Marshal.SizeOf<OpticalFlow.OpticalFlowConstants>()); |
|
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -79,11 +79,23 @@ namespace FidelityFX.OpticalFlow |
|
|
: base(contextDescription, resources, constants) |
|
|
: base(contextDescription, resources, constants) |
|
|
{ |
|
|
{ |
|
|
_spdConstants = spdConstants; |
|
|
_spdConstants = spdConstants; |
|
|
|
|
|
InitComputeShader("Generate Optical Flow Input Pyramid", contextDescription.shaders.generateOpticalFlowInputPyramid); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
throw new NotImplementedException(); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowInput, Resources.OpticalFlowInput[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowInputLevel1, Resources.OpticalFlowInputLevel1[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowInputLevel2, Resources.OpticalFlowInputLevel2[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowInputLevel3, Resources.OpticalFlowInputLevel3[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowInputLevel4, Resources.OpticalFlowInputLevel4[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowInputLevel5, Resources.OpticalFlowInputLevel5[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowInputLevel6, Resources.OpticalFlowInputLevel6[frameIndex]); |
|
|
|
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, OpticalFlowShaderIDs.CbOpticalFlow, Constants, 0, Marshal.SizeOf<OpticalFlow.OpticalFlowConstants>()); |
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, OpticalFlowShaderIDs.CbSpd, _spdConstants, 0, Marshal.SizeOf<OpticalFlow.SpdConstants>()); |
|
|
|
|
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -92,11 +104,18 @@ namespace FidelityFX.OpticalFlow |
|
|
public OpticalFlowGenerateSCDHistogramPass(OpticalFlow.ContextDescription contextDescription, OpticalFlowResources resources, ComputeBuffer constants) |
|
|
public OpticalFlowGenerateSCDHistogramPass(OpticalFlow.ContextDescription contextDescription, OpticalFlowResources resources, ComputeBuffer constants) |
|
|
: base(contextDescription, resources, constants) |
|
|
: base(contextDescription, resources, constants) |
|
|
{ |
|
|
{ |
|
|
|
|
|
InitComputeShader("Generate SCD Histogram", contextDescription.shaders.generateScdHistogram); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
throw new NotImplementedException(); |
|
|
|
|
|
|
|
|
// TODO: probably needs to be input from this frame (result from pyramid pass), but double check to be sure
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.SrvOpticalFlowInput, Resources.OpticalFlowInput[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowScdHistogram, Resources.OpticalFlowSCDHistogram); |
|
|
|
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, OpticalFlowShaderIDs.CbOpticalFlow, Constants, 0, Marshal.SizeOf<OpticalFlow.OpticalFlowConstants>()); |
|
|
|
|
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -105,11 +124,21 @@ namespace FidelityFX.OpticalFlow |
|
|
public OpticalFlowComputeSCDDivergencePass(OpticalFlow.ContextDescription contextDescription, OpticalFlowResources resources, ComputeBuffer constants) |
|
|
public OpticalFlowComputeSCDDivergencePass(OpticalFlow.ContextDescription contextDescription, OpticalFlowResources resources, ComputeBuffer constants) |
|
|
: base(contextDescription, resources, constants) |
|
|
: base(contextDescription, resources, constants) |
|
|
{ |
|
|
{ |
|
|
|
|
|
InitComputeShader("Compute SCD Divergence", contextDescription.shaders.computeScdDivergence); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
throw new NotImplementedException(); |
|
|
|
|
|
|
|
|
ref var scdOutput = ref dispatchParams.opticalFlowSCD; |
|
|
|
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowScdHistogram, Resources.OpticalFlowSCDHistogram); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowScdPreviousHistogram, Resources.OpticalFlowSCDPreviousHistogram); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowScdTemp, Resources.OpticalFlowSCDTemp); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowScdOutput, scdOutput.RenderTarget, scdOutput.MipLevel, scdOutput.SubElement); |
|
|
|
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, OpticalFlowShaderIDs.CbOpticalFlow, Constants, 0, Marshal.SizeOf<OpticalFlow.OpticalFlowConstants>()); |
|
|
|
|
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -120,7 +149,7 @@ namespace FidelityFX.OpticalFlow |
|
|
{ |
|
|
{ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
throw new NotImplementedException(); |
|
|
throw new NotImplementedException(); |
|
|
} |
|
|
} |
|
|
@ -133,7 +162,7 @@ namespace FidelityFX.OpticalFlow |
|
|
{ |
|
|
{ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
throw new NotImplementedException(); |
|
|
throw new NotImplementedException(); |
|
|
} |
|
|
} |
|
|
@ -146,7 +175,7 @@ namespace FidelityFX.OpticalFlow |
|
|
{ |
|
|
{ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
|
|
|
|
|
|
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
|
|
{ |
|
|
{ |
|
|
throw new NotImplementedException(); |
|
|
throw new NotImplementedException(); |
|
|
} |
|
|
} |
|
|
|