From 505fa34bb55787a7cd216e59dc8b3fc36f60aab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Wed, 13 May 2020 11:28:06 +0200 Subject: [PATCH 1/2] Fixed max alloc planar size not taking in account the max cache size --- .../Runtime/Lighting/LightLoop/LightLoop.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs index 71ab4ad5a9e..7e7be7d3ee4 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs @@ -335,6 +335,8 @@ public void Initialize(HDRenderPipelineAsset hdrpAsset, RenderPipelineResources // For planar reflection we only convolve with the GGX filter, otherwise it would be too expensive GraphicsFormat planarProbeCacheFormat = lightLoopSettings.planarReflectionCacheCompressed ? GraphicsFormat.RGB_BC6H_SFloat : GraphicsFormat.R16G16B16A16_SFloat; int reflectionPlanarResolution = (int)lightLoopSettings.planarReflectionAtlasSize; + if (PlanarReflectionProbeCache.GetApproxCacheSizeInByte(1, reflectionPlanarResolution, planarProbeCacheFormat) > k_MaxCacheSize) + reflectionPlanarResolution = PlanarReflectionProbeCache.GetMaxCacheSizeForWeightInByte(k_MaxCacheSize, planarProbeCacheFormat); reflectionPlanarProbeCache = new PlanarReflectionProbeCache(defaultResources, (IBLFilterGGX)iBLFilterBSDFArray[0], reflectionPlanarResolution, planarProbeCacheFormat, true); } From 31b9c0699cb04561d44964f3aea3c7b68e96fa25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Thu, 14 May 2020 10:58:53 +0200 Subject: [PATCH 2/2] Removed the max cache clamp on texture atlases --- .../RenderPipeline/HDRenderPipelineUI.cs | 26 +++---------------- .../Runtime/Lighting/LightCookieManager.cs | 3 --- .../Runtime/Lighting/LightLoop/LightLoop.cs | 2 -- 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs index 860e10d0bcc..42b30c229f6 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs @@ -221,17 +221,8 @@ static void Drawer_SectionCookies(SerializedHDRenderPipelineAsset serialized, Ed { GraphicsFormat cookieFormat = (GraphicsFormat)serialized.renderPipelineSettings.lightLoopSettings.cookieFormat.intValue; long currentCache = PowerOfTwoTextureAtlas.GetApproxCacheSizeInByte(1, serialized.renderPipelineSettings.lightLoopSettings.cookieAtlasSize.intValue, true, cookieFormat); - if (currentCache > HDRenderPipeline.k_MaxCacheSize) - { - int reserved = PowerOfTwoTextureAtlas.GetMaxCacheSizeForWeightInByte(HDRenderPipeline.k_MaxCacheSize, true, cookieFormat); - string message = string.Format(Styles.cacheErrorFormat, HDEditorUtils.HumanizeWeight(currentCache), reserved); - EditorGUILayout.HelpBox(message, MessageType.Error); - } - else - { - string message = string.Format(Styles.cacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache)); - EditorGUILayout.HelpBox(message, MessageType.Info); - } + string message = string.Format(Styles.cacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache)); + EditorGUILayout.HelpBox(message, MessageType.Info); } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.cookieAtlasLastValidMip, Styles.cookieAtlasLastValidMipContent); @@ -305,17 +296,8 @@ static void Drawer_SectionReflection(SerializedHDRenderPipelineAsset serialized, else { long currentCache = PlanarReflectionProbeCache.GetApproxCacheSizeInByte(1, serialized.renderPipelineSettings.lightLoopSettings.planarReflectionAtlasSize.intValue, GraphicsFormat.R16G16B16A16_UNorm); - if (currentCache > HDRenderPipeline.k_MaxCacheSize) - { - int reserved = PlanarReflectionProbeCache.GetMaxCacheSizeForWeightInByte(HDRenderPipeline.k_MaxCacheSize, GraphicsFormat.R16G16B16A16_UNorm); - string message = string.Format(Styles.cacheErrorFormat, HDEditorUtils.HumanizeWeight(currentCache), reserved); - EditorGUILayout.HelpBox(message, MessageType.Error); - } - else - { - string message = string.Format(Styles.cacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache)); - EditorGUILayout.HelpBox(message, MessageType.Info); - } + string message = string.Format(Styles.cacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache)); + EditorGUILayout.HelpBox(message, MessageType.Info); } EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.maxPlanarReflectionOnScreen, Styles.maxPlanarReflectionOnScreen); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs index c113acf19eb..b528bbdb2f6 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs @@ -63,9 +63,6 @@ public LightCookieManager(HDRenderPipelineAsset hdAsset, int maxCacheSize) cookieFormat = (GraphicsFormat)gLightLoopSettings.cookieFormat; cookieAtlasLastValidMip = gLightLoopSettings.cookieAtlasLastValidMip; - if (PowerOfTwoTextureAtlas.GetApproxCacheSizeInByte(1, cookieAtlasSize, true, cookieFormat) > HDRenderPipeline.k_MaxCacheSize) - cookieAtlasSize = PowerOfTwoTextureAtlas.GetMaxCacheSizeForWeightInByte(HDRenderPipeline.k_MaxCacheSize, true, cookieFormat); - m_CookieAtlas = new PowerOfTwoTextureAtlas(cookieAtlasSize, gLightLoopSettings.cookieAtlasLastValidMip, cookieFormat, name: "Cookie Atlas (Punctual Lights)", useMipMap: true); m_CubeToPanoMaterial = CoreUtils.CreateEngineMaterial(hdResources.shaders.cubeToPanoPS); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs index 7e7be7d3ee4..71ab4ad5a9e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs @@ -335,8 +335,6 @@ public void Initialize(HDRenderPipelineAsset hdrpAsset, RenderPipelineResources // For planar reflection we only convolve with the GGX filter, otherwise it would be too expensive GraphicsFormat planarProbeCacheFormat = lightLoopSettings.planarReflectionCacheCompressed ? GraphicsFormat.RGB_BC6H_SFloat : GraphicsFormat.R16G16B16A16_SFloat; int reflectionPlanarResolution = (int)lightLoopSettings.planarReflectionAtlasSize; - if (PlanarReflectionProbeCache.GetApproxCacheSizeInByte(1, reflectionPlanarResolution, planarProbeCacheFormat) > k_MaxCacheSize) - reflectionPlanarResolution = PlanarReflectionProbeCache.GetMaxCacheSizeForWeightInByte(k_MaxCacheSize, planarProbeCacheFormat); reflectionPlanarProbeCache = new PlanarReflectionProbeCache(defaultResources, (IBLFilterGGX)iBLFilterBSDFArray[0], reflectionPlanarResolution, planarProbeCacheFormat, true); }