From 898b5b4407c1ed7ebc1dc70afe9f113b2639fed2 Mon Sep 17 00:00:00 2001 From: bd_ Date: Wed, 21 Aug 2024 20:28:59 -0700 Subject: [PATCH] fix: more problems with TargetSet invalidation (#346) --- CHANGELOG.md | 3 ++- Editor/PreviewSystem/ComputeContext.cs | 9 ++++++++- Editor/PreviewSystem/Rendering/TargetSet.cs | 7 ++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dffed9..b73ae3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added ### Fixed -- [#343] TargetSet is not invalidated when GetTargetGroups context is invalidated + +- [#343] [#346] TargetSet is not invalidated when GetTargetGroups context is invalidated ### Changed diff --git a/Editor/PreviewSystem/ComputeContext.cs b/Editor/PreviewSystem/ComputeContext.cs index 0c7edb3..ca001f7 100644 --- a/Editor/PreviewSystem/ComputeContext.cs +++ b/Editor/PreviewSystem/ComputeContext.cs @@ -3,6 +3,7 @@ using System; using System.Threading.Tasks; using JetBrains.Annotations; +using UnityEngine; #endregion @@ -39,7 +40,13 @@ static ComputeContext() internal ComputeContext(string description) { - Invalidate = () => _invalidater.TrySetResult(null); + Invalidate = () => + { +#if NDMF_TRACE + Debug.Log("Invalidating " + Description); +#endif + _invalidater.TrySetResult(null); + }; OnInvalidate = _invalidater.Task; Description = description; } diff --git a/Editor/PreviewSystem/Rendering/TargetSet.cs b/Editor/PreviewSystem/Rendering/TargetSet.cs index 66610a3..4b5f226 100644 --- a/Editor/PreviewSystem/Rendering/TargetSet.cs +++ b/Editor/PreviewSystem/Rendering/TargetSet.cs @@ -34,12 +34,9 @@ public TargetSet(ImmutableList filters) foreach (var filter in _filters) { if (!filter.IsEnabled(_targetSetContext)) continue; - - var ctx = new ComputeContext("StageDescriptor for " + filter); - ctx.Invalidates(_targetSetContext); - + Profiler.BeginSample("TargetSet.GetTargetGroups[" + filter + "]"); - var groups = filter.GetTargetGroups(ctx); + var groups = filter.GetTargetGroups(_targetSetContext); if (groups.IsEmpty) continue; builder.Add(new Stage