From 4e29c3dfb4ec17fef1557f333aed4644b6b8c807 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Sat, 27 Jul 2024 13:36:40 +0200 Subject: [PATCH] Replaced allocating lambda expression with a regular method. --- .../FrameInterpolationContext.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Runtime/FrameInterpolation/FrameInterpolationContext.cs b/Runtime/FrameInterpolation/FrameInterpolationContext.cs index 4c46235..5ed41d1 100644 --- a/Runtime/FrameInterpolation/FrameInterpolationContext.cs +++ b/Runtime/FrameInterpolation/FrameInterpolationContext.cs @@ -196,14 +196,6 @@ namespace FidelityFX.FrameGen // Schedule work for the interpolation command list _setupPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, renderDispatchSizeX, renderDispatchSizeY); - // TODO delegates are reference types, i.e. this allocates some memory every frame - Action dispatchGameVectorFieldInpaintingPyramid = () => - { - SetupSpdConstants(dispatchDescription.renderSize, out var dispatchThreadGroupCount); - commandBuffer.SetBufferData(_spdConstantsBuffer, _spdConstantsArray); - _gameVectorFieldInpaintingPyramidPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, dispatchThreadGroupCount.x, dispatchThreadGroupCount.y); - }; - // Only execute FG data preparation passes when reset wasn't triggered if (executePreparationPasses) { @@ -214,7 +206,7 @@ namespace FidelityFX.FrameGen _reconstructPreviousDepthPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, renderDispatchSizeX, renderDispatchSizeY); _gameMotionVectorFieldPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, renderDispatchSizeX, renderDispatchSizeY); - dispatchGameVectorFieldInpaintingPyramid(); + DispatchGameVectorFieldInpaintingPyramid(commandBuffer, dispatchDescription, doubleBufferId); _opticalFlowVectorFieldPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, opticalFlowDispatchSizeX, opticalFlowDispatchSizeY); _disocclusionMaskPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, renderDispatchSizeX, renderDispatchSizeY); } @@ -230,7 +222,7 @@ namespace FidelityFX.FrameGen if ((dispatchDescription.flags & FrameInterpolation.DispatchFlags.DrawDebugView) != 0) { - dispatchGameVectorFieldInpaintingPyramid(); + DispatchGameVectorFieldInpaintingPyramid(commandBuffer, dispatchDescription, doubleBufferId); _debugViewPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, displayDispatchSizeX, displayDispatchSizeY); } @@ -241,6 +233,13 @@ namespace FidelityFX.FrameGen commandBuffer.EndSample(_sampler); } + + private void DispatchGameVectorFieldInpaintingPyramid(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchDescription, int doubleBufferId) + { + SetupSpdConstants(dispatchDescription.renderSize, out var dispatchThreadGroupCount); + commandBuffer.SetBufferData(_spdConstantsBuffer, _spdConstantsArray); + _gameVectorFieldInpaintingPyramidPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, dispatchThreadGroupCount.x, dispatchThreadGroupCount.y); + } private Vector4 SetupDeviceDepthToViewSpaceDepthParams(FrameInterpolation.DispatchDescription dispatchParams) {