From 875b90f6efb80d5fbfd1faf2ff0f95769cc39a6a Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Sat, 27 Jul 2024 13:44:20 +0200 Subject: [PATCH] Simplified backbuffer selection for interpolation source --- Runtime/FrameInterpolation/FrameInterpolation.cs | 11 +++++++++++ .../FrameInterpolation/FrameInterpolationContext.cs | 5 ++--- Runtime/FrameInterpolation/FrameInterpolationPass.cs | 9 ++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Runtime/FrameInterpolation/FrameInterpolation.cs b/Runtime/FrameInterpolation/FrameInterpolation.cs index 6ef37f6..900d336 100644 --- a/Runtime/FrameInterpolation/FrameInterpolation.cs +++ b/Runtime/FrameInterpolation/FrameInterpolation.cs @@ -86,6 +86,17 @@ namespace FidelityFX.FrameGen public BackbufferTransferFunction backbufferTransferFunction; public Vector2 minMaxLuminance; public ulong frameID; + + public ref ResourceView InterpolationSource + { + get + { + if (currentBackBuffer_HUDLess.IsValid) + return ref currentBackBuffer_HUDLess; + + return ref currentBackBuffer; + } + } } public enum BackbufferTransferFunction diff --git a/Runtime/FrameInterpolation/FrameInterpolationContext.cs b/Runtime/FrameInterpolation/FrameInterpolationContext.cs index 5ed41d1..4224910 100644 --- a/Runtime/FrameInterpolation/FrameInterpolationContext.cs +++ b/Runtime/FrameInterpolation/FrameInterpolationContext.cs @@ -227,9 +227,8 @@ namespace FidelityFX.FrameGen } // Store current buffer - ref var backBuf = ref dispatchDescription.currentBackBuffer; - ref var bbNoHud = ref dispatchDescription.currentBackBuffer_HUDLess; - commandBuffer.CopyTexture(bbNoHud.IsValid ? bbNoHud.RenderTarget : backBuf.RenderTarget, _resources.PreviousInterpolationSource); + ref var backBuf = ref dispatchDescription.InterpolationSource; + commandBuffer.CopyTexture(backBuf.RenderTarget, _resources.PreviousInterpolationSource); commandBuffer.EndSample(_sampler); } diff --git a/Runtime/FrameInterpolation/FrameInterpolationPass.cs b/Runtime/FrameInterpolation/FrameInterpolationPass.cs index bafdf04..7c950ea 100644 --- a/Runtime/FrameInterpolation/FrameInterpolationPass.cs +++ b/Runtime/FrameInterpolation/FrameInterpolationPass.cs @@ -60,13 +60,8 @@ namespace FidelityFX.FrameGen protected void BindCurrentInterpolationSource(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams) { - ref var backBuf = ref dispatchParams.currentBackBuffer; - ref var bbNoHud = ref dispatchParams.currentBackBuffer_HUDLess; - - if (bbNoHud.IsValid) - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, bbNoHud.RenderTarget, bbNoHud.MipLevel, bbNoHud.SubElement); - else - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, backBuf.RenderTarget, backBuf.MipLevel, backBuf.SubElement); + ref var backBuf = ref dispatchParams.InterpolationSource; + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, backBuf.RenderTarget, backBuf.MipLevel, backBuf.SubElement); } protected void BindMipmap(CommandBuffer commandBuffer, int nameID, RenderTexture renderTexture, int mipLevel)