From 5104acf451feee18d56ecbfaca27894890754d2b Mon Sep 17 00:00:00 2001 From: Christine Johnson Date: Wed, 24 Mar 2021 17:17:52 -0700 Subject: [PATCH] Reduce clear calls in TextureCache ClearCache functions --- .../Runtime/Core/Textures/TextureCache2D.cs | 9 +++------ .../Runtime/Core/Textures/TextureCacheCubemap.cs | 12 +++--------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCache2D.cs b/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCache2D.cs index 1c0c2f8f3a3..1f75e99841b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCache2D.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCache2D.cs @@ -108,13 +108,10 @@ internal void ClearCache() var desc = m_Cache.descriptor; bool isMipped = desc.useMipMap; int mipCount = isMipped ? GetNumMips(desc.width, desc.height) : 1; - for (int depthSlice = 0; depthSlice < desc.volumeDepth; ++depthSlice) + for (int mipIdx = 0; mipIdx < mipCount; ++mipIdx) { - for (int mipIdx = 0; mipIdx < mipCount; ++mipIdx) - { - Graphics.SetRenderTarget(m_Cache, mipIdx, CubemapFace.Unknown, depthSlice); - GL.Clear(false, true, Color.clear); - } + Graphics.SetRenderTarget(m_Cache, mipIdx, CubemapFace.Unknown, -1); + GL.Clear(false, true, Color.clear); } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCacheCubemap.cs b/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCacheCubemap.cs index 219b153c098..c9b5fb056af 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCacheCubemap.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCacheCubemap.cs @@ -162,16 +162,10 @@ internal void ClearCache() var desc = m_Cache.descriptor; bool isMipped = desc.useMipMap; int mipCount = isMipped ? GetNumMips(desc.width, desc.height) : 1; - for (int depthSlice = 0; depthSlice < desc.volumeDepth; ++depthSlice) + for (int mipIdx = 0; mipIdx < mipCount; ++mipIdx) { - for (int mipIdx = 0; mipIdx < mipCount; ++mipIdx) - { - for (int faceIdx = 0; faceIdx < 6; ++faceIdx) - { - Graphics.SetRenderTarget(m_Cache, mipIdx, (CubemapFace)faceIdx, depthSlice); - GL.Clear(false, true, Color.clear); - } - } + Graphics.SetRenderTarget(m_Cache, mipIdx, CubemapFace.Unknown, -1); + GL.Clear(false, true, Color.clear); } }