Skip to content

Commit fbb4462

Browse files
Chris Tchoupbbastianelizabeth-legrosKink3d
authored
New Shader Graph serialization format (#222)
Co-authored-by: Peter Bay Bastian <[email protected]> Co-authored-by: Elizabeth LeGros <[email protected]> Co-authored-by: Matt Dean <[email protected]> Co-authored-by: elizabeth-legros <[email protected]> Co-authored-by: Peter Bay Bastian <[email protected]>
1 parent 8fefabd commit fbb4462

File tree

160 files changed

+13522
-1494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+13522
-1494
lines changed

LocalTestProjects/HDRP_DebugCrossFade_Tests/Packages/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"com.unity.render-pipelines.core": "file:../../../com.unity.render-pipelines.core",
1616
"com.unity.render-pipelines.high-definition": "file:../../../com.unity.render-pipelines.high-definition",
1717
"com.unity.shadergraph": "file:../../../com.unity.shadergraph",
18-
"com.unity.test-framework": "1.0.13",
18+
"com.unity.test-framework": "1.1.14",
1919
"com.unity.testframework.graphics": "file:../../../com.unity.testframework.graphics",
2020
"com.unity.testing.hdrp": "file:../../../com.unity.testing.hdrp",
2121
"com.unity.textmeshpro": "2.0.1",

TestProjects/HDRP_DXR_Tests/Packages/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"com.unity.render-pipelines.high-definition": "file:../../../com.unity.render-pipelines.high-definition",
1414
"com.unity.render-pipelines.high-definition-config": "file:../LocalPackages/com.unity.render-pipelines.high-definition-config",
1515
"com.unity.shadergraph": "file:../../../com.unity.shadergraph",
16-
"com.unity.test-framework": "1.1.11",
17-
"com.unity.testframework.graphics": "7.1.12-preview",
16+
"com.unity.test-framework": "1.1.14",
17+
"com.unity.testframework.graphics": "7.1.13-preview",
1818
"com.unity.testing.hdrp": "file:../../../com.unity.testing.hdrp",
1919
"com.unity.textmeshpro": "3.0.0-preview.1",
2020
"com.unity.timeline": "1.2.6",

TestProjects/HDRP_PerformanceTests/Packages/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"com.unity.render-pipelines.high-definition-config": "file:../../../com.unity.render-pipelines.high-definition-config",
99
"com.unity.shaderanalysis": "file:../../../com.unity.shaderanalysis",
1010
"com.unity.shadergraph": "file:../../../com.unity.shadergraph",
11-
"com.unity.test-framework.build": "0.0.1-preview.3",
12-
"com.unity.test-framework": "1.1.11",
11+
"com.unity.test-framework.build": "0.0.1-preview.12",
12+
"com.unity.test-framework": "1.1.14",
1313
"com.unity.test-framework.performance": "2.0.8-preview",
1414
"com.unity.testing.graphics-performance": "file:../../../com.unity.testing.graphics-performance",
1515
"com.unity.ugui": "1.0.0",

TestProjects/HDRP_RuntimeTests/Packages/manifest.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"com.unity.render-pipelines.high-definition": "file:../../../com.unity.render-pipelines.high-definition",
88
"com.unity.render-pipelines.high-definition-config": "file:../../../com.unity.render-pipelines.high-definition-config",
99
"com.unity.shadergraph": "file:../../../com.unity.shadergraph",
10-
"com.unity.test-framework": "1.1.5",
11-
"com.unity.test-framework.build": "0.0.1-preview.3",
12-
"com.unity.test-framework.utp-reporter": "0.1.3-preview.17",
13-
"com.unity.testframework.graphics": "7.1.12-preview",
10+
"com.unity.test-framework": "1.1.14",
11+
"com.unity.test-framework.build": "0.0.1-preview.12",
12+
"com.unity.test-framework.utp-reporter": "1.0.0-preview",
13+
"com.unity.testframework.graphics": "7.1.13-preview",
1414
"com.unity.testing.hdrp": "file:../../../com.unity.testing.hdrp",
1515
"com.unity.ugui": "1.0.0",
1616
"com.unity.visualeffectgraph": "file:../../../com.unity.visualeffectgraph",

TestProjects/HDRP_Tests/Packages/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"com.unity.render-pipelines.high-definition": "file:../../../com.unity.render-pipelines.high-definition",
88
"com.unity.render-pipelines.high-definition-config": "file:../../../com.unity.render-pipelines.high-definition-config",
99
"com.unity.shadergraph": "file:../../../com.unity.shadergraph",
10-
"com.unity.test-framework": "1.1.5",
11-
"com.unity.testframework.graphics": "7.1.12-preview",
10+
"com.unity.test-framework": "1.1.14",
11+
"com.unity.testframework.graphics": "7.1.13-preview",
1212
"com.unity.testing.hdrp": "file:../../../com.unity.testing.hdrp",
1313
"com.unity.ugui": "1.0.0",
1414
"com.unity.visualeffectgraph": "file:../../../com.unity.visualeffectgraph",

TestProjects/SRP_SmokeTest/Packages/manifest.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"com.unity.render-pipelines.high-definition-config": "file:../../../com.unity.render-pipelines.high-definition-config",
66
"com.unity.render-pipelines.universal": "file:../../../com.unity.render-pipelines.universal",
77
"com.unity.shadergraph": "file:../../../com.unity.shadergraph",
8-
"com.unity.test-framework": "1.1.5",
9-
"com.unity.testframework.graphics": "7.1.12-preview",
8+
"com.unity.test-framework": "1.1.14",
9+
"com.unity.testframework.graphics": "7.1.13-preview",
1010
"com.unity.ugui": "1.0.0",
1111
"com.unity.visualeffectgraph": "file:../../../com.unity.visualeffectgraph",
1212
"com.unity.xr.legacyinputhelpers": "2.1.2",
@@ -41,8 +41,8 @@
4141
"com.unity.modules.vr": "1.0.0",
4242
"com.unity.modules.wind": "1.0.0",
4343
"com.unity.modules.xr": "1.0.0",
44-
"com.unity.test-framework.utp-reporter": "0.1.3-preview.17",
45-
"com.unity.test-framework.build": "0.0.1-preview.3"
44+
"com.unity.test-framework.utp-reporter": "1.0.0-preview",
45+
"com.unity.test-framework.build": "0.0.1-preview.12"
4646
},
4747
"testables": [
4848
"com.unity.render-pipelines.core",

TestProjects/ShaderGraph/Assets/CommonAssets/Editor/AddAllNodesTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void ClearGraph()
3232
var allNodes = m_Graph.GetNodes<AbstractMaterialNode>().ToArray();
3333
foreach (var node in allNodes)
3434
{
35-
if(m_Graph.activeOutputNodeGuid != node.guid)
35+
if(m_Graph.outputNode != node)
3636
m_Graph.RemoveNode(node);
3737
}
3838
}

TestProjects/ShaderGraph/Assets/CommonAssets/Editor/EdgeTypeConversionTests.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using UnityEditor.Graphing;
77
using UnityEditor.Graphing.Util;
88
using UnityEditor.Rendering;
9+
using UnityEditor.ShaderGraph.Serialization;
910
using UnityEngine;
1011

1112
namespace UnityEditor.ShaderGraph.UnitTests
@@ -17,9 +18,10 @@ public void Initialize(string graphPath)
1718
hideFlags = HideFlags.HideAndDontSave;
1819

1920
var textGraph = File.ReadAllText(graphPath, Encoding.UTF8);
20-
graph = JsonUtility.FromJson<GraphData>(textGraph);
21+
graph = new GraphData();
2122
graph.messageManager = new MessageManager();
2223
graph.assetGuid = AssetDatabase.AssetPathToGUID(graphPath);
24+
MultiJson.Deserialize(graph, textGraph);
2325
graph.OnEnable();
2426
graph.ValidateGraph();
2527
}
@@ -59,7 +61,7 @@ public void TestAllCombos()
5961
var edge = m_Graph.GetEdges(slot.slotReference).FirstOrDefault();
6062
if (edge == null) continue;
6163

62-
var outputNode = m_Graph.GetNodeFromGuid(edge.outputSlot.nodeGuid);
64+
var outputNode = edge.outputSlot.node;
6365
var outputSlot = outputNode.GetOutputSlots<MaterialSlot>().First(s => s.id == edge.outputSlot.slotId);
6466
var curOutputType = outputSlot.valueType.ToConcreteSlotValueType();
6567

@@ -73,7 +75,7 @@ public void TestAllCombos()
7375
// Verify all errors are expected
7476
foreach (var message in m_Graph.messageManager.GetNodeMessages())
7577
{
76-
if (message.Key.Equals(m_CFNode.guid) && message.Value.Exists(msg =>
78+
if (message.Key.Equals(m_CFNode.objectId) && message.Value.Exists(msg =>
7779
msg.severity == ShaderCompilerMessageSeverity.Error))
7880
{
7981
Assert.IsFalse(SlotValueHelper.AreCompatible(slotValType, curOutputType),
@@ -105,17 +107,17 @@ public void RedirectNodes_DoNotAffectOutput()
105107
var edge = m_Graph.GetEdges(slot.slotReference).FirstOrDefault();
106108
if (edge == null) continue;
107109

108-
var outputNode = m_Graph.GetNodeFromGuid(edge.outputSlot.nodeGuid);
110+
var outputNode = edge.outputSlot.node;
109111
var outputSlot = outputNode.GetOutputSlots<MaterialSlot>().First(s => s.id == edge.outputSlot.slotId);
110112

111-
RedirectNodeData.Create(m_Graph, outputSlot.valueType, Vector2.zero, edge.inputSlot, edge.outputSlot, Guid.Empty);
113+
RedirectNodeData.Create(m_Graph, outputSlot.valueType, Vector2.zero, edge.inputSlot, edge.outputSlot, null);
112114

113115
m_Graph.ValidateGraph();
114116

115117
// Verify all errors are expected
116118
foreach (var message in m_Graph.messageManager.GetNodeMessages())
117119
{
118-
if (message.Key.Equals(m_CFNode.guid) && message.Value.Exists(msg =>
120+
if (message.Key.Equals(m_CFNode.objectId) && message.Value.Exists(msg =>
119121
msg.severity == ShaderCompilerMessageSeverity.Error))
120122
{
121123
Assert.Fail(message.Value.FirstOrDefault().message);
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using NUnit.Framework;
2+
using System.Collections;
3+
using System.IO;
4+
using UnityEditor.Graphing.Util;
5+
using UnityEditor.ShaderGraph.Serialization;
6+
using UnityEngine;
7+
8+
namespace UnityEditor.ShaderGraph.UnitTests
9+
{
10+
[TestFixture]
11+
class ImportUpdateTests
12+
{
13+
public class ImportCases : IEnumerable
14+
{
15+
private const string kGraphsLocation = "PreviousGraphVersions/";
16+
public IEnumerator GetEnumerator()
17+
{
18+
return Directory.GetFiles(Application.dataPath + "/../" + kGraphsLocation, "*", SearchOption.AllDirectories).GetEnumerator();
19+
}
20+
}
21+
22+
[OneTimeSetUp]
23+
public void Setup()
24+
{
25+
if(!AssetDatabase.IsValidFolder("Assets/Testing/ImportTests"))
26+
{
27+
AssetDatabase.CreateFolder("Assets/Testing", "ImportTests");
28+
}
29+
}
30+
31+
[TestCaseSource(typeof(ImportCases))]
32+
public void CopyOverAndImport(string assetPath)
33+
{
34+
string fileName = Path.GetFileName(assetPath);
35+
string fileContents = File.ReadAllText(assetPath);
36+
string localFilePath = "Assets/Testing/ImportTests/" + fileName;
37+
File.WriteAllText(Application.dataPath + "/Testing/ImportTests/" + fileName, fileContents);
38+
AssetDatabase.ImportAsset(localFilePath);
39+
var graphGuid = AssetDatabase.AssetPathToGUID(localFilePath);
40+
var messageManager = new MessageManager();
41+
GraphData graphData = new GraphData() { assetGuid = graphGuid, messageManager = messageManager };
42+
MultiJson.Deserialize(graphData, fileContents);
43+
graphData.OnEnable();
44+
graphData.ValidateGraph();
45+
}
46+
47+
[OneTimeTearDown]
48+
public void Cleanup()
49+
{
50+
foreach (string assetGuid in AssetDatabase.FindAssets("*", new string[] { "Assets/Testing/ImportTests" }))
51+
{
52+
Debug.Log(AssetDatabase.GUIDToAssetPath(assetGuid));
53+
AssetDatabase.DeleteAsset(AssetDatabase.GUIDToAssetPath(assetGuid));
54+
}
55+
}
56+
}
57+
}

com.unity.shadergraph/Editor/Data/Interfaces/Graph/ISlot.cs.meta renamed to TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ImportUpdateTests.cs.meta

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)