Skip to content

Commit c7cca48

Browse files
Fixed deallocation of SSS buffers
1 parent 4baa326 commit c7cca48

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,15 @@ public void Dispose()
9696
/// <param name="scaledRTMSAASamples">Number of MSAA samples for automatically scaled RTHandles.</param>
9797
public void Initialize(int width, int height, bool scaledRTsupportsMSAA, MSAASamples scaledRTMSAASamples)
9898
{
99-
Debug.Assert(m_AutoSizedRTs.Count == 0, "RTHandle.Initialize should only be called once before allocating any Render Texture. This may be caused by an unreleased RTHandle resource.");
99+
if (m_AutoSizedRTs.Count != 0)
100+
{
101+
string leakingResources = "Unreleased RTHandles:";
102+
foreach (var rt in m_AutoSizedRTs)
103+
{
104+
leakingResources = string.Format("{0}\n {1}", leakingResources, rt.name);
105+
}
106+
Debug.LogError(string.Format("RTHandle.Initialize should only be called once before allocating any Render Texture. This may be caused by an unreleased RTHandle resource.\n{0}\n", leakingResources));
107+
}
100108

101109
m_MaxWidths = width;
102110
m_MaxHeights = height;

com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ void DestroySSSBuffers()
8484
{
8585
RTHandles.Release(m_SSSColorMSAA);
8686
RTHandles.Release(m_SSSCameraFilteringBuffer);
87+
if (!m_SSSReuseGBufferMemory)
88+
{
89+
RTHandles.Release(m_SSSColor);
90+
}
8791
}
8892

8993
RTHandle GetSSSBuffer()
@@ -117,11 +121,6 @@ void CleanupSubsurfaceScattering()
117121
{
118122
CoreUtils.Destroy(m_CombineLightingPass);
119123
CoreUtils.Destroy(m_SSSCopyStencilForSplitLighting);
120-
if (!m_SSSReuseGBufferMemory)
121-
{
122-
RTHandles.Release(m_SSSColor);
123-
}
124-
125124
DestroySSSBuffers();
126125
}
127126

0 commit comments

Comments
 (0)