Skip to content

Commit aebe387

Browse files
guillaumelevassEvergreen
authored andcommitted
Graphics Performance Test Framework UIToolkit update and additional loadable scenes for tests
This PR aims to add changes to the Graphics Performance Tests Package. The changes were made while working on the performance tests for the URP version of the Fantasy Kingdom demo. Those tests will live in the Fantasy Kingdom repo. **PerformanceTests.cs** : Bug where scene name is the a substring in another scene name **TestSceneAsset.cs**: Mostly come from Remi's PR. Added additionable scenes to add in build settings, added manual alias for RPAssets that shows up in test names **TestSceneAssetEditor.cs**: Update editor to UIToolkit
1 parent ead88bd commit aebe387

File tree

9 files changed

+305
-244
lines changed

9 files changed

+305
-244
lines changed

Tests/SRPTests/Packages/com.unity.testing.graphics-performance/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this package will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [17.2.0] - 2024-04-16
9+
- Converted Performance Tests Asset Editor to UIToolkit
10+
- Added additional loadable scenes to Test Scene asset
11+
- Added manually definable alias for Render Assets
12+
- Added R8G8B8A8_SRGB to the list of available color buffer Formats
13+
814
## [17.1.2] - 2024-04-03
915

1016
- Update com.unity.render-pipelines.core dependency.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Boxed
2+
{
3+
background-color: var(--unity-colors-tab-background-checked);
4+
border-color: var(--unity-colors-toolbar_button-border);
5+
border-width: 1px 1px 1px 1px;
6+
border-radius: 5px 5px 5px 5px;
7+
padding: 3px 6px 3px 6px;
8+
margin: 4px 0px 2px -10px;
9+
}
10+
11+
Boxed > Toggle
12+
{
13+
margin-left: 0px;
14+
}
15+
16+
Boxed > Toggle Label
17+
{
18+
-unity-font-style: bold;
19+
-unity-text-align: middle-center;
20+
}

Tests/SRPTests/Packages/com.unity.testing.graphics-performance/Editor/Common/Boxed.uss.meta

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

Tests/SRPTests/Packages/com.unity.testing.graphics-performance/Editor/Common/TestSceneAssetEditor.cs

Lines changed: 188 additions & 190 deletions
Large diffs are not rendered by default.

Tests/SRPTests/Packages/com.unity.testing.graphics-performance/Runtime/PerformanceTestSceneSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public enum ColorBufferFormat
1212
R8G8B8A8 = GraphicsFormat.R8G8B8A8_SNorm,
1313
R16G16B16A16 = GraphicsFormat.R16G16B16A16_SFloat,
1414
R11G11B10 = GraphicsFormat.B10G11R11_UFloatPack32,
15+
R8G8B8A8_SRGB = GraphicsFormat.R8G8B8A8_SRGB
1516
}
1617

1718
[HideInInspector, System.NonSerialized]

Tests/SRPTests/Packages/com.unity.testing.graphics-performance/Runtime/PerformanceTests.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,7 @@ public void Setup()
2626
// Add all test scenes from the asset to the build settings:
2727
if (testScenesAsset)
2828
{
29-
var testScenes = testScenesAsset.GetAllTests()
30-
.Select(test =>
31-
{
32-
var scene = SceneManager.GetSceneByName(test.sceneData.scene);
33-
var sceneGUID = AssetDatabase.FindAssets($"t:Scene {test.sceneData.scene}").FirstOrDefault();
34-
var scenePath = AssetDatabase.GUIDToAssetPath(sceneGUID);
35-
return new EditorBuildSettingsScene(scenePath, true);
36-
});
37-
EditorBuildSettings.scenes = testScenes.ToArray();
29+
EditorBuildSettings.scenes = testScenesAsset.ConvertTestDataScenesToBuildSettings();
3830
}
3931

4032
EditorUserBuildSettings.ps4HardwareTarget = PS4HardwareTarget.BaseOnly;

Tests/SRPTests/Packages/com.unity.testing.graphics-performance/Runtime/TestSceneAsset.cs

Lines changed: 76 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,101 @@
22
using UnityEngine;
33
using System;
44
using System.Linq;
5+
using UnityEditor;
56
using UnityEngine.Rendering;
67
using static UnityEngine.TestTools.Graphics.Performance.PerformanceMetricNames;
78

89
namespace UnityEngine.TestTools.Graphics.Performance
910
{
1011
[CreateAssetMenu(menuName = "Testing/Performance Test Description")]
1112
public class TestSceneAsset : ScriptableObject
13+
{
14+
15+
[Serializable]
16+
public class SceneData
17+
{
18+
public string scene;
19+
public string sceneLabels;
20+
public string scenePath; //See also ScenePathUpdater
21+
public bool enabled;
22+
}
23+
24+
[Serializable]
25+
public class SRPAssetData
26+
{
27+
public RenderPipelineAsset asset;
28+
public string assetLabels;
29+
public string alias; // reference named used in the test
30+
}
31+
32+
[Serializable]
33+
public class SRPAssetDataAliasByHand : SRPAssetData { }
34+
35+
[Serializable]
36+
public class TestSuiteData
1237
{
13-
[Serializable]
14-
public class SceneData
15-
{
16-
public string scene;
17-
public string sceneLabels;
18-
public string scenePath;
19-
public bool enabled;
20-
}
38+
public List<SceneData> scenes;
39+
public List<SRPAssetData> srpAssets;
2140

22-
[Serializable]
23-
public class SRPAssetData
41+
public IEnumerable<(SceneData sceneData, SRPAssetData assetData)> GetTestList()
2442
{
25-
public RenderPipelineAsset asset;
26-
public string assetLabels;
27-
public string alias; // reference named used in the test
43+
foreach (var srpAsset in srpAssets)
44+
foreach (var scene in scenes)
45+
if (scene.enabled)
46+
yield return (scene, srpAsset);
2847
}
48+
}
2949

30-
[Serializable]
31-
public class TestSuiteData
32-
{
33-
public List<SceneData> scenes;
34-
public List<SRPAssetData> srpAssets;
35-
36-
public IEnumerable<(SceneData sceneData, SRPAssetData assetData)> GetTestList()
37-
{
38-
foreach (var srpAsset in srpAssets)
39-
foreach (var scene in scenes)
40-
if (scene.enabled)
41-
yield return (scene, srpAsset);
42-
}
43-
}
50+
// Store the name of the scenes so we can load them at runtime
51+
public TestSuiteData counterTestSuite = new TestSuiteData();
52+
public TestSuiteData memoryTestSuite = new TestSuiteData();
53+
public TestSuiteData buildTestSuite = new TestSuiteData();
54+
55+
public List<SRPAssetDataAliasByHand> srpAssetAliases = new List<SRPAssetDataAliasByHand>();
56+
public List<SceneData> additionalLoadableScenes = new List<SceneData>();
4457

45-
// Store the name of the scenes so we can load them at runtime
46-
public TestSuiteData counterTestSuite = new TestSuiteData();
47-
public TestSuiteData memoryTestSuite = new TestSuiteData();
48-
public TestSuiteData buildTestSuite = new TestSuiteData();
58+
public IEnumerable<(SceneData sceneData, SRPAssetData assetData)> GetAllTests()
59+
{
60+
foreach (var test in counterTestSuite.GetTestList())
61+
yield return test;
62+
foreach (var test in memoryTestSuite.GetTestList())
63+
yield return test;
64+
foreach (var test in buildTestSuite.GetTestList())
65+
yield return test;
66+
}
4967

50-
public List<SRPAssetData> srpAssetAliases = new List<SRPAssetData>();
68+
public string GetScenePath(string sceneName)
69+
=> GetAllTests().FirstOrDefault(s => s.sceneData.scene == sceneName).sceneData?.scenePath
70+
?? additionalLoadableScenes.FirstOrDefault(s => s.scene == sceneName)?.scenePath;
5171

52-
public IEnumerable<(SceneData sceneData, SRPAssetData assetData)> GetAllTests()
53-
{
54-
foreach (var test in counterTestSuite.GetTestList())
55-
yield return test;
56-
foreach (var test in memoryTestSuite.GetTestList())
57-
yield return test;
58-
foreach (var test in buildTestSuite.GetTestList())
59-
yield return test;
60-
}
72+
public string GetSRPAssetAlias(RenderPipelineAsset srpAsset)
73+
=> srpAssetAliases.Where(a => a.asset == srpAsset).FirstOrDefault()?.alias;
74+
75+
IEnumerable<SceneData> GetAllSceneData()
76+
{
77+
foreach (var scene in counterTestSuite.scenes)
78+
yield return scene;
79+
foreach (var scene in memoryTestSuite.scenes)
80+
yield return scene;
81+
foreach (var scene in buildTestSuite.scenes)
82+
yield return scene;
83+
foreach (var scene in additionalLoadableScenes)
84+
yield return scene;
85+
}
6186

62-
public string GetScenePath(string sceneName) => GetAllTests().FirstOrDefault(s => s.sceneData.scene == sceneName).sceneData?.scenePath;
87+
#if UNITY_EDITOR
88+
public UnityEditor.EditorBuildSettingsScene[] ConvertTestDataScenesToBuildSettings()
89+
{
90+
var scenesForTests = GetAllSceneData();
6391

64-
public string GetSRPAssetAlias(RenderPipelineAsset srpAsset) => srpAssetAliases.Where(a => a.asset == srpAsset).FirstOrDefault()?.alias;
92+
var scenesForTestsConvertedBuildSettingsScenes =
93+
scenesForTests.Select(x => new EditorBuildSettingsScene(x.scenePath, x.enabled)).ToArray();
94+
95+
return scenesForTestsConvertedBuildSettingsScenes;
6596
}
6697

98+
#endif
99+
}
67100
public struct CounterTestDescription
68101
{
69102
public TestSceneAsset.SceneData sceneData;

Tests/SRPTests/Packages/com.unity.testing.graphics-performance/ValidationExceptions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[
44
{
55
"ValidationTest": "NDA Filename Validation",
6-
"PackageVersion": "17.1.1"
6+
"PackageVersion": "17.2.0"
77
}
88
]
99
}

Tests/SRPTests/Packages/com.unity.testing.graphics-performance/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.unity.testing.graphics-performance",
33
"displayName": "Performance Graphics Tests Framework",
4-
"version": "17.1.2",
4+
"version": "17.2.0",
55
"unity": "6000.0",
66
"unityRelease": "0b15",
77
"rootNamespace": "UnityEngine.TestTools.Graphics.Performance",

0 commit comments

Comments
 (0)