|
|
|
@ -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<TElem>(string name, int count) |
|
|
|
{ |
|
|
|
return new ComputeBuffer(count, Marshal.SizeOf<TElem>()); |
|
|
|
} |
|
|
|
|
|
|
|
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]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |