Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit 6aa1a37

Browse files
committed
Fixed TAA release error spam
1 parent b34d48f commit 6aa1a37

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

PostProcessing/Runtime/Effects/TemporalAntialiasing.cs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ enum Pass
4747

4848
int[] m_HistoryPingPong = new int [k_NumEyes];
4949

50-
public TemporalAntialiasing()
51-
{
52-
m_HistoryTextures[(int)Camera.StereoscopicEye.Left] = new RenderTexture[k_NumHistoryTextures];
53-
m_HistoryTextures[(int)Camera.StereoscopicEye.Right] = new RenderTexture[k_NumHistoryTextures];
54-
}
55-
5650
public bool IsSupported()
5751
{
5852
return SystemInfo.supportedRenderTargetCount >= 2
@@ -160,7 +154,12 @@ void GenerateHistoryName(RenderTexture rt, int id, PostProcessRenderContext cont
160154

161155
RenderTexture CheckHistory(int id, PostProcessRenderContext context)
162156
{
163-
var rt = m_HistoryTextures[context.xrActiveEye][id];
157+
int activeEye = context.xrActiveEye;
158+
159+
if (m_HistoryTextures[activeEye] == null)
160+
m_HistoryTextures[activeEye] = new RenderTexture[k_NumHistoryTextures];
161+
162+
var rt = m_HistoryTextures[activeEye][id];
164163

165164
if (m_ResetHistory || rt == null || !rt.IsCreated())
166165
{
@@ -170,7 +169,7 @@ RenderTexture CheckHistory(int id, PostProcessRenderContext context)
170169
GenerateHistoryName(rt, id, context);
171170

172171
rt.filterMode = FilterMode.Bilinear;
173-
m_HistoryTextures[context.xrActiveEye][id] = rt;
172+
m_HistoryTextures[activeEye][id] = rt;
174173

175174
context.command.BlitFullscreenTriangle(context.source, rt);
176175
}
@@ -182,13 +181,13 @@ RenderTexture CheckHistory(int id, PostProcessRenderContext context)
182181
GenerateHistoryName(rt2, id, context);
183182

184183
rt2.filterMode = FilterMode.Bilinear;
185-
m_HistoryTextures[context.xrActiveEye][id] = rt2;
184+
m_HistoryTextures[activeEye][id] = rt2;
186185

187186
context.command.BlitFullscreenTriangle(rt, rt2);
188187
RenderTexture.ReleaseTemporary(rt);
189188
}
190189

191-
return m_HistoryTextures[context.xrActiveEye][id];
190+
return m_HistoryTextures[activeEye][id];
192191
}
193192

194193
internal void Render(PostProcessRenderContext context)
@@ -221,14 +220,21 @@ internal void Render(PostProcessRenderContext context)
221220

222221
internal void Release()
223222
{
224-
for (int i = 0; i < m_HistoryTextures.Length; i++)
223+
if (m_HistoryTextures != null)
225224
{
226-
for (int j = 0; j < m_HistoryTextures[i].Length; j++)
225+
for (int i = 0; i < m_HistoryTextures.Length; i++)
227226
{
228-
RenderTexture.ReleaseTemporary(m_HistoryTextures[i][j]);
229-
m_HistoryTextures[i][j] = null;
227+
if (m_HistoryTextures[i] == null)
228+
continue;
229+
230+
for (int j = 0; j < m_HistoryTextures[i].Length; j++)
231+
{
232+
RenderTexture.ReleaseTemporary(m_HistoryTextures[i][j]);
233+
m_HistoryTextures[i][j] = null;
234+
}
235+
236+
m_HistoryTextures[i] = null;
230237
}
231-
m_HistoryTextures[i] = null;
232238
}
233239

234240
m_SampleIndex = 0;

0 commit comments

Comments
 (0)