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 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..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,7 +976,14 @@ void DisposeProbeCameraPool() CameraCaptureBridge.enabled = false; - HDUtils.ReleaseComponentSingletons(); + // 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(); } 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..e557f10660d 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,12 +38,16 @@ 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(); UpdateRenderingLayerNames(); + + isInOnValidateCall = false; } [SerializeField]