Skip to content

Commit c8e95e0

Browse files
PaulDemeulenaerejulienf-unity
authored andcommitted
Fix GPUEvent & SubGraph (#178)
* Fix SelectionHasCompleteSystems Detect correctly if there are dependencies due to GPUEvent (or stripAttribute) * Add allDependenciesIncludingNotCompilable in VFXData This helper is usefull for UI + use it in SelectionHasCompleteSystems * Add note without change the beahvior * Remove debug ToArray()
1 parent eedfcbd commit c8e95e0

File tree

3 files changed

+49
-14
lines changed

3 files changed

+49
-14
lines changed

com.unity.visualeffectgraph/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1515
- Exclude Operator, Context, Block and Subgraph from Preset [Case 1232309](https://issuetracker.unity3d.com/product/unity/issues/guid/1232309/)
1616
- Fix [Case 1212002](https://fogbugz.unity3d.com/f/cases/1212002/)
1717
- Incorrect path on Linux while targetting Android, IOS or WebGL [Case 1279750](https://issuetracker.unity3d.com/product/unity/issues/guid/1279750/)
18+
- Prevent creation of subgraph containing only partial systems [Case 1284053](https://issuetracker.unity3d.com/product/unity/issues/guid/1284053/)
1819

1920
## [10.2.0] - 2020-10-19
2021
### Added

com.unity.visualeffectgraph/Editor/Data/VFXData.cs

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public void CollectAttributes()
261261
if (m_Contexts == null) // Context hasnt been initialized (may happen in unity tests but not during actual compilation)
262262
InitImplicitContexts();
263263

264-
m_DependenciesIn = new HashSet<VFXData>(
264+
var allDepenciesIn =
265265
m_Contexts.Where(c => c.contextType == VFXContextType.Init)
266266
.SelectMany(c => c.inputContexts.Where(i => i.contextType == VFXContextType.SpawnerGPU))
267267
.SelectMany(c => c.allLinkedInputSlot)
@@ -281,18 +281,19 @@ public void CollectAttributes()
281281
return false;
282282
})
283283
.Select(s => ((VFXModel)s.owner).GetFirstOfType<VFXContext>())
284-
.Where(c => c.CanBeCompiled())
285-
.Select(c => c.GetData())
286-
);
284+
.Select(c => c.GetData());
287285

288-
m_DependenciesOut = new HashSet<VFXData>(
286+
m_DependenciesIn = new HashSet<VFXData>(allDepenciesIn.Where(c => c.CanBeCompiled()));
287+
m_DependenciesInNotCompilable = new HashSet<VFXData>(allDepenciesIn.Where(c => !c.CanBeCompiled()));
288+
289+
var allDependenciesOut =
289290
owners.SelectMany(o => o.allLinkedOutputSlot)
290291
.Select(s => (VFXContext)s.owner)
291-
.Where(c => c.CanBeCompiled())
292292
.SelectMany(c => c.outputContexts)
293-
.Where(c => c.CanBeCompiled())
294-
.Select(c => c.GetData())
295-
);
293+
.Select(c => c.GetData());
294+
295+
m_DependenciesOut = new HashSet<VFXData>(allDependenciesOut.Where(c => c.CanBeCompiled()));
296+
m_DependenciesOutNotCompilable = new HashSet<VFXData>(allDependenciesOut.Where(c => !c.CanBeCompiled()));
296297

297298
m_ContextsToAttributes.Clear();
298299
m_AttributesToContexts.Clear();
@@ -602,6 +603,7 @@ public uint layer
602603
}
603604
}
604605

606+
//Doesn't include not comilable context
605607
public IEnumerable<VFXData> dependenciesIn
606608
{
607609
get
@@ -618,6 +620,19 @@ public IEnumerable<VFXData> dependenciesOut
618620
}
619621
}
620622

623+
public IEnumerable<VFXData> allDependenciesIncludingNotCompilable
624+
{
625+
get
626+
{
627+
var all = Enumerable.Empty<VFXData>();
628+
all = all.Concat(m_DependenciesIn);
629+
all = all.Concat(m_DependenciesOut);
630+
all = all.Concat(m_DependenciesInNotCompilable);
631+
all = all.Concat(m_DependenciesOutNotCompilable);
632+
return all;
633+
}
634+
}
635+
621636
[SerializeField]
622637
protected List<VFXContext> m_Owners;
623638

@@ -640,9 +655,15 @@ public IEnumerable<VFXData> dependenciesOut
640655
[NonSerialized]
641656
protected HashSet<VFXData> m_DependenciesIn = new HashSet<VFXData>();
642657

658+
[NonSerialized]
659+
protected HashSet<VFXData> m_DependenciesInNotCompilable = new HashSet<VFXData>();
660+
643661
[NonSerialized]
644662
protected HashSet<VFXData> m_DependenciesOut = new HashSet<VFXData>();
645663

664+
[NonSerialized]
665+
protected HashSet<VFXData> m_DependenciesOutNotCompilable = new HashSet<VFXData>();
666+
646667
[NonSerialized]
647668
protected uint m_Layer;
648669
}

com.unity.visualeffectgraph/Editor/GraphView/Views/VFXView.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,17 +2267,30 @@ void CollapseOperator(DropdownMenuAction a)
22672267

22682268
public bool SelectionHasCompleteSystems()
22692269
{
2270-
HashSet<VFXContextUI> selectedContexts = new HashSet<VFXContextUI>(selection.OfType<VFXContextUI>());
2271-
if (selectedContexts.Count() < 1)
2270+
HashSet<VFXContextUI> selectedContextUIs = new HashSet<VFXContextUI>(selection.OfType<VFXContextUI>());
2271+
if (selectedContextUIs.Count() < 1)
22722272
return false;
22732273

2274-
HashSet<VFXData> usedDatas = new HashSet<VFXData>(selectedContexts.Select(t => t.controller.model.GetData()).Where(t => t != null));
2274+
var relatedContext = selectedContextUIs.Select(t => t.controller.model);
22752275

2276+
//Adding manually VFXBasicGPUEvent, it doesn't appears as dependency.
2277+
var outputContextDataFromGPUEvent = relatedContext.OfType<VFXBasicGPUEvent>().SelectMany(o => o.outputContexts);
2278+
relatedContext = relatedContext.Concat(outputContextDataFromGPUEvent);
2279+
var selectedContextDatas = relatedContext.Select(o => o.GetData()).Where(o => o != null);
2280+
2281+
var selectedContextDependencies = selectedContextDatas.SelectMany(o => o.allDependenciesIncludingNotCompilable);
2282+
var allDatas = selectedContextDatas.Concat(selectedContextDependencies);
2283+
2284+
var allDatasHash = new HashSet<VFXData>(allDatas);
22762285
foreach (var context in GetAllContexts())
22772286
{
2278-
if (context.controller.model is VFXBlockSubgraphContext)
2287+
var model = context.controller.model;
2288+
if (model is VFXBlockSubgraphContext)
22792289
return false;
2280-
if (usedDatas.Contains(context.controller.model.GetData()) && !selectedContexts.Contains(context))
2290+
2291+
//We should exclude model.contextType == VFXContextType.Event of this condition.
2292+
//If VFXConvertSubgraph.TransferContextsFlowEdges has been fixed & renabled.
2293+
if (allDatasHash.Contains(model.GetData()) && !selectedContextUIs.Contains(context))
22812294
return false;
22822295
}
22832296

0 commit comments

Comments
 (0)