浏览代码
* Hunt down code causing pixel cache dirtying every frame
* Hunt down code causing pixel cache dirtying every frame
* Put inline/port inputs in a shared pixel cache per node (rather than per input) * Make preview and controls independent of node collapsed state * Tidy up MaterialNodeView a bit * Introduce PixelCacheProfiler for somewhat manually hunting down bad pixel caches/main
Peter Bay Bastian
7 年前
当前提交
16db0624
共有 10 个文件被更改,包括 286 次插入 和 123 次删除
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
-
221MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs
-
14MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/PortInputView.cs
-
40MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss
-
59MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/PixelCacheProfilerView.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/PixelCacheProfilerView.cs.meta
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/PixelCacheProfiler.uss
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/PixelCacheProfiler.uss.meta
-
39MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/UXML/PixelCacheProfiler.uxml
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/UXML/PixelCacheProfiler.uxml.meta
|
|||
using System.Linq; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.UIElements; |
|||
|
|||
namespace UnityEditor.ShaderGraph.Drawing |
|||
{ |
|||
public class PixelCacheProfilerView : VisualElement |
|||
{ |
|||
readonly VisualElement m_Target; |
|||
Label m_TotalLabel; |
|||
Label m_DirtyLabel; |
|||
Label m_TotalNodeContentsLabel; |
|||
Label m_DirtyNodeContentsLabel; |
|||
Label m_TotalPreviewsLabel; |
|||
Label m_DirtyPreviewsLabel; |
|||
Label m_TotalInlinesLabel; |
|||
Label m_DirtyInlinesLabel; |
|||
|
|||
public PixelCacheProfilerView(VisualElement target) |
|||
{ |
|||
m_Target = target; |
|||
|
|||
var tpl = Resources.Load<VisualTreeAsset>("UXML/PixelCacheProfiler"); |
|||
tpl.CloneTree(this, null); |
|||
|
|||
m_TotalLabel = this.Q<Label>("totalLabel"); |
|||
m_DirtyLabel = this.Q<Label>("dirtyLabel"); |
|||
m_TotalNodeContentsLabel = this.Q<Label>("totalNodeContentsLabel"); |
|||
m_DirtyNodeContentsLabel = this.Q<Label>("dirtyNodeContentsLabel"); |
|||
m_TotalPreviewsLabel = this.Q<Label>("totalPreviewsLabel"); |
|||
m_DirtyPreviewsLabel = this.Q<Label>("dirtyPreviewsLabel"); |
|||
m_TotalInlinesLabel = this.Q<Label>("totalInlinesLabel"); |
|||
m_DirtyInlinesLabel = this.Q<Label>("dirtyInlinesLabel"); |
|||
} |
|||
|
|||
public void Profile() |
|||
{ |
|||
var caches = m_Target.Query().Where(ve => ve.clippingOptions == ClippingOptions.ClipAndCacheContents).Build().ToList(); |
|||
var dirtyCaches = caches.Where(ve => ve.IsDirty(ChangeType.Repaint)).ToList(); |
|||
m_TotalLabel.text = caches.Count.ToString(); |
|||
m_DirtyLabel.text = dirtyCaches.Count.ToString(); |
|||
|
|||
var nodeContentsCaches = caches.Where(ve => ve.name == "node-border").ToList(); |
|||
var dirtyNodeContentsCaches = nodeContentsCaches.Where(ve => ve.IsDirty(ChangeType.Repaint)).ToList(); |
|||
m_TotalNodeContentsLabel.text = nodeContentsCaches.Count.ToString(); |
|||
m_DirtyNodeContentsLabel.text = dirtyNodeContentsCaches.Count.ToString(); |
|||
|
|||
var previewCaches = caches.Where(ve => ve.name == "previewContainer").ToList(); |
|||
var dirtyPreviewCaches = previewCaches.Where(ve => ve.IsDirty(ChangeType.Repaint)).ToList(); |
|||
m_TotalPreviewsLabel.text = previewCaches.Count.ToString(); |
|||
m_DirtyPreviewsLabel.text = dirtyPreviewCaches.Count.ToString(); |
|||
|
|||
var inlineCaches = caches.Where(ve => ve.name == "portInputContainer").ToList(); |
|||
var dirtyInlineCaches = inlineCaches.Where(ve => ve.IsDirty(ChangeType.Repaint)).ToList(); |
|||
m_TotalInlinesLabel.text = inlineCaches.Count.ToString(); |
|||
m_DirtyInlinesLabel.text = dirtyInlineCaches.Count.ToString(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7147f25b12dd4427b4c8afd44624f35b |
|||
timeCreated: 1517227822 |
|
|||
PixelCacheProfilerView > #content > #title { |
|||
font-style: bold; |
|||
} |
|||
|
|||
PixelCacheProfilerView > #content > .row { |
|||
flex-direction: row; |
|||
} |
|||
|
|||
PixelCacheProfilerView > #content > .indented { |
|||
padding-left: 8; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 61cf67e9c1f54ceab08d2bd16ffd3c53 |
|||
ScriptedImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} |
|
|||
<UXML xmlns:ui="UnityEngine.Experimental.UIElements"> |
|||
<ui:VisualElement name="content"> |
|||
<Style path="Styles/PixelCacheProfiler"/> |
|||
<ui:Label name="title" text="Pixel Cache Profiler"/> |
|||
<ui:VisualElement class="row"> |
|||
<ui:Label text="Total pixel caches: "/> |
|||
<ui:Label name="totalLabel" text="-"/> |
|||
</ui:VisualElement> |
|||
<ui:VisualElement class="indented row"> |
|||
<ui:Label text="Node contents: "/> |
|||
<ui:Label name="totalNodeContentsLabel" text="-"/> |
|||
</ui:VisualElement> |
|||
<ui:VisualElement class="indented row"> |
|||
<ui:Label text="Node previews: "/> |
|||
<ui:Label name="totalPreviewsLabel" text="-"/> |
|||
</ui:VisualElement> |
|||
<ui:VisualElement class="indented row"> |
|||
<ui:Label text="Inline inputs: "/> |
|||
<ui:Label name="totalInlinesLabel" text="-"/> |
|||
</ui:VisualElement> |
|||
|
|||
<ui:VisualElement class="row"> |
|||
<ui:Label text="Dirty pixel caches: "/> |
|||
<ui:Label name="dirtyLabel" text="-"/> |
|||
</ui:VisualElement> |
|||
<ui:VisualElement class="indented row"> |
|||
<ui:Label text="Node contents: "/> |
|||
<ui:Label name="dirtyNodeContentsLabel" text="-"/> |
|||
</ui:VisualElement> |
|||
<ui:VisualElement class="indented row"> |
|||
<ui:Label text="Node previews: "/> |
|||
<ui:Label name="dirtyPreviewsLabel" text="-"/> |
|||
</ui:VisualElement> |
|||
<ui:VisualElement class="indented row"> |
|||
<ui:Label text="Inline inputs: "/> |
|||
<ui:Label name="dirtyInlinesLabel" text="-"/> |
|||
</ui:VisualElement> |
|||
</ui:VisualElement> |
|||
</UXML> |
|
|||
fileFormatVersion: 2 |
|||
guid: 0fda1aff5a5744478f70542e95fd3d42 |
|||
ScriptedImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} |
撰写
预览
正在加载...
取消
保存
Reference in new issue