Skip to content

Commit

Permalink
fix: prevent creation of overlapping render groups
Browse files Browse the repository at this point in the history
This generally is unintended and can result in horrible performance issues, so block it entirely.
  • Loading branch information
bdunderscore committed Sep 1, 2024
1 parent 2dfa2a1 commit d588f1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#363] Reduce GC pressure caused by `ComputeContext.GetComponent`

### Changed
- [#364] Prevent creation of overlapping render groups in the same `IRenderFilter`

### Removed

Expand Down
11 changes: 11 additions & 0 deletions Editor/PreviewSystem/Rendering/TargetSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ public TargetSet(ImmutableList<IRenderFilter> filters)
var groups = filter.GetTargetGroups(_targetSetContext);
Profiler.EndSample();
if (groups.IsEmpty) continue;

var duplicateRenderers = groups.SelectMany(g => g.Renderers)
.GroupBy(r => r)
.FirstOrDefault(agg => agg.Count() > 1);
if (duplicateRenderers != null)
{
Debug.LogError("[" + filter + "] Duplicate renderer " + duplicateRenderers.Key +
" in groups: " + string.Join(", ", groups));
// Suppress this filter
continue;
}

builder.Add(new Stage
{
Expand Down

0 comments on commit d588f1d

Please sign in to comment.