diff --git a/Runtime/FrameInterpolation/FrameInterpolationResources.cs b/Runtime/FrameInterpolation/FrameInterpolationResources.cs index 84d0474..d27e5ac 100644 --- a/Runtime/FrameInterpolation/FrameInterpolationResources.cs +++ b/Runtime/FrameInterpolation/FrameInterpolationResources.cs @@ -5,7 +5,7 @@ using UnityEngine.Experimental.Rendering; namespace FidelityFX.FrameGen { - internal class FrameInterpolationResources + internal class FrameInterpolationResources: FfxResourcesBase { public RenderTexture ReconstructedDepthInterpolatedFrame; public RenderTexture GameMotionVectorFieldX; @@ -60,58 +60,5 @@ namespace FidelityFX.FrameGen DestroyResource(ref GameMotionVectorFieldX); DestroyResource(ref ReconstructedDepthInterpolatedFrame); } - - private static RenderTexture CreateResource(string name, Vector2Int size, GraphicsFormat format) - { - var rt = new RenderTexture(size.x, size.y, 0, format) { name = name, enableRandomWrite = true }; - rt.Create(); - return rt; - } - - private static RenderTexture CreateResourceMips(string name, Vector2Int size, GraphicsFormat format) - { - int mipCount = 1 + Mathf.FloorToInt(Mathf.Log(Math.Max(size.x, size.y), 2.0f)); - var rt = new RenderTexture(size.x, size.y, 0, format, mipCount) { name = name, enableRandomWrite = true, useMipMap = true, autoGenerateMips = false }; - rt.Create(); - return rt; - } - - private static ComputeBuffer CreateBuffer(string name, int count) - { - return new ComputeBuffer(count, Marshal.SizeOf()); - } - - private static void CreateDoubleBufferedResource(RenderTexture[] resource, string name, Vector2Int size, GraphicsFormat format, int numElements = 2) - { - for (int i = 0; i < numElements; ++i) - { - resource[i] = new RenderTexture(size.x, size.y, 0, format) { name = name + (i + 1), enableRandomWrite = true }; - resource[i].Create(); - } - } - - private static void DestroyResource(ref RenderTexture resource) - { - if (resource == null) - return; - - resource.Release(); - resource = null; - } - - private static void DestroyResource(ref ComputeBuffer resource) - { - if (resource == null) - return; - - resource.Release(); - resource = null; - } - - private static void DestroyResource(RenderTexture[] resource) - { - for (int i = 0; i < resource.Length; ++i) - DestroyResource(ref resource[i]); - } } } diff --git a/Runtime/OpticalFlow/OpticalFlowResources.cs b/Runtime/OpticalFlow/OpticalFlowResources.cs index 24449fc..d844116 100644 --- a/Runtime/OpticalFlow/OpticalFlowResources.cs +++ b/Runtime/OpticalFlow/OpticalFlowResources.cs @@ -3,7 +3,7 @@ using UnityEngine.Experimental.Rendering; namespace FidelityFX.FrameGen { - internal class OpticalFlowResources + internal class OpticalFlowResources: FfxResourcesBase { public readonly RenderTexture[][] OpticalFlowInputLevels = { @@ -36,11 +36,6 @@ namespace FidelityFX.FrameGen Vector2Int opticalFlowInputTextureSize = contextDescription.resolution; Vector2Int opticalFlowTextureSize = OpticalFlow.GetOpticalFlowTextureSize(contextDescription.resolution, OpticalFlow.MinBlockSize); - // TODO: this seems useless, delete unless something comes up - Vector2Int opticalFlowHistogramTextureSize = OpticalFlow.GetOpticalFlowHistogramSize(0); - Vector2Int globalMotionSearchMaxDispatchSize = OpticalFlow.GetGlobalMotionSearchDispatchSize(0); - int globalMotionSearchTextureWidth = 4 + (globalMotionSearchMaxDispatchSize.x * globalMotionSearchMaxDispatchSize.y); - for (int level = 0; level < OpticalFlow.OpticalFlowMaxPyramidLevels; ++level) { CreateDoubleBufferedResource(OpticalFlowInputLevels[level], $"OPTICALFLOW_OpticalFlowInputLevel{level}-", opticalFlowInputTextureSize, GraphicsFormat.R8_UInt); @@ -77,36 +72,5 @@ namespace FidelityFX.FrameGen { return (x + (y - 1)) & ~(y - 1); } - - private static RenderTexture CreateResource(string name, Vector2Int size, GraphicsFormat format) - { - var rt = new RenderTexture(size.x, size.y, 0, format) { name = name, enableRandomWrite = true }; - rt.Create(); - return rt; - } - - private static void CreateDoubleBufferedResource(RenderTexture[] resource, string name, Vector2Int size, GraphicsFormat format) - { - for (int i = 0; i < 2; ++i) - { - resource[i] = new RenderTexture(size.x, size.y, 0, format) { name = name + (i + 1), enableRandomWrite = true }; - resource[i].Create(); - } - } - - private static void DestroyResource(ref RenderTexture resource) - { - if (resource == null) - return; - - resource.Release(); - resource = null; - } - - private static void DestroyResource(RenderTexture[] resource) - { - for (int i = 0; i < resource.Length; ++i) - DestroyResource(ref resource[i]); - } } }