tree sway and shadow improvements
[WindSway-HDRP.git] / Library / PackageCache / com.unity.postprocessing@2.1.2 / PostProcessing / Runtime / Utils / TargetPool.cs
blobcf7234232684e195363f3aa9bb73dc99fc8a61d7
1 using System.Collections.Generic;
3 namespace UnityEngine.Rendering.PostProcessing
5 class TargetPool
7 readonly List<int> m_Pool;
8 int m_Current;
10 internal TargetPool()
12 m_Pool = new List<int>();
13 Get(); // Pre-warm with a default target to avoid black frame on first frame
16 internal int Get()
18 int ret = Get(m_Current);
19 m_Current++;
20 return ret;
23 int Get(int i)
25 int ret;
27 if (m_Pool.Count > i)
29 ret = m_Pool[i];
31 else
33 // Avoid discontinuities
34 while (m_Pool.Count <= i)
35 m_Pool.Add(Shader.PropertyToID("_TargetPool" + i));
37 ret = m_Pool[i];
40 return ret;
43 internal void Reset()
45 m_Current = 0;