Nerfed/Nerfed.Runtime/Graphics/ComputePassPool.cs

26 lines
461 B
C#
Raw Normal View History

using System.Collections.Concurrent;
namespace Nerfed.Runtime.Graphics;
internal class ComputePassPool
{
private ConcurrentQueue<ComputePass> ComputePasses = new ConcurrentQueue<ComputePass>();
public ComputePass Obtain()
{
if (ComputePasses.TryDequeue(out ComputePass computePass))
{
return computePass;
}
else
{
return new ComputePass();
}
}
public void Return(ComputePass computePass)
{
ComputePasses.Enqueue(computePass);
}
}