Nerfed/Nerfed.Runtime/Graphics/RenderPassPool.cs

26 lines
447 B
C#

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