From c6743c515e533980e1684c85a71e2c3e3d6fd739 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Wed, 22 Apr 2020 16:02:56 +0200 Subject: [PATCH 1/4] fix bug 1238155 --- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 3 ++- .../Runtime/RenderPipeline/HDRenderPipelineAsset.cs | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 42cef9ae8be..24467e16f4a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -976,7 +976,8 @@ void DisposeProbeCameraPool() CameraCaptureBridge.enabled = false; - HDUtils.ReleaseComponentSingletons(); + if (!m_Asset.isInOnValidateCall) + HDUtils.ReleaseComponentSingletons(); } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs index de83731a0eb..bd886864e89 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs @@ -17,6 +17,8 @@ enum ShaderVariantLogLevel [HelpURL(Documentation.baseURL + Documentation.version + Documentation.subURL + "HDRP-Asset" + Documentation.endURL)] public partial class HDRenderPipelineAsset : RenderPipelineAsset { + [System.NonSerialized] + internal bool isInOnValidateCall = false; HDRenderPipelineAsset() { @@ -36,11 +38,15 @@ protected override RenderPipeline CreatePipeline() /// protected override void OnValidate() { + isInOnValidateCall = true; + //Do not reconstruct the pipeline if we modify other assets. //OnValidate is called once at first selection of the asset. if (GraphicsSettings.currentRenderPipeline == this) base.OnValidate(); + isInOnValidateCall = false; + UpdateRenderingLayerNames(); } From c41c690e5fe86eefd67b04e6b928403ce93282fa Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Wed, 22 Apr 2020 16:03:55 +0200 Subject: [PATCH 2/4] Update CHANGELOG.md --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 49a7e0de93b..1fb0c52ef9e 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -561,6 +561,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed unneeded cookie texture allocation for cone stop lights. - Fixed scalarization code for contact shadows. - Fixed volume debug in playmode +- Fixed issue when toggling anything in HDRP asset that will produce an error (case 1238155) ### Changed - Improve MIP selection for decals on Transparents From 421f62fe79c9b8587e22fb8a5143c5ae080b28f4 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Wed, 22 Apr 2020 16:11:06 +0200 Subject: [PATCH 3/4] Update HDRenderPipeline.cs --- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 24467e16f4a..bb59ef28112 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -976,6 +976,12 @@ void DisposeProbeCameraPool() CameraCaptureBridge.enabled = false; + // Dispose of Render Pipeline can be call either by OnValidate() or by OnDisable(). + // Inside an OnValidate() call we can't call a DestroyImmediate(). + // Here we are releasing our singleton to not leak while doing a domain reload. + // However this is doing a call to DestroyImmediate(). + // To workaround this, and was we only leak with Singleton while doing domain reload (and not in OnValidate) + // we are detecting if we are in an OnValidate call and releasing the Singleton only if it is not the case. if (!m_Asset.isInOnValidateCall) HDUtils.ReleaseComponentSingletons(); } From 05da268b88c0be9fbed78e92063c3d90b0b62890 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Wed, 22 Apr 2020 16:12:02 +0200 Subject: [PATCH 4/4] Update HDRenderPipelineAsset.cs --- .../Runtime/RenderPipeline/HDRenderPipelineAsset.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs index bd886864e89..e557f10660d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs @@ -45,9 +45,9 @@ protected override void OnValidate() if (GraphicsSettings.currentRenderPipeline == this) base.OnValidate(); - isInOnValidateCall = false; - UpdateRenderingLayerNames(); + + isInOnValidateCall = false; } [SerializeField]