4
4
using UnityEngine . Experimental . Rendering ;
5
5
using UnityEngine . Rendering . RenderGraphModule ;
6
6
using System . Collections . Generic ;
7
+ using UnityEngine . TestTools ;
7
8
8
9
#if UNITY_EDITOR
9
10
using UnityEditor . Rendering ;
@@ -13,10 +14,12 @@ namespace UnityEngine.Rendering.Tests
13
14
class RenderGraphTests
14
15
{
15
16
// For RG Record/Hash/Compile testing, use m_RenderGraph
16
- RenderGraph m_RenderGraph ;
17
+ RenderGraph m_RenderGraph ;
18
+
17
19
RenderPipelineAsset m_OldDefaultRenderPipeline ;
20
+ RenderPipelineAsset m_OldQualityRenderPipeline ;
18
21
19
- // For RG Execute/Submit testing with rendering, use m_RenderGraphTestPipeline and its recordRenderGraphBody
22
+ // For RG Execute/Submit testing with rendering, use m_RenderGraphTestPipeline and m_RenderGraph in its recordRenderGraphBody
20
23
RenderGraphTestPipelineAsset m_RenderGraphTestPipeline ;
21
24
RenderGraphTestGlobalSettings m_RenderGraphTestGlobalSettings ;
22
25
@@ -96,12 +99,14 @@ public void Setup()
96
99
#if UNITY_EDITOR
97
100
EditorGraphicsSettings . SetRenderPipelineGlobalSettingsAsset < RenderGraphTestPipelineInstance > ( m_RenderGraphTestGlobalSettings ) ;
98
101
#endif
99
- // Saving old render pipeline to set it back after testing
102
+ // Saving old render pipelines to set them back after testing
100
103
m_OldDefaultRenderPipeline = GraphicsSettings . defaultRenderPipeline ;
104
+ m_OldQualityRenderPipeline = QualitySettings . renderPipeline ;
101
105
102
106
// Setting the custom RG render pipeline
103
107
m_RenderGraphTestPipeline = ScriptableObject . CreateInstance < RenderGraphTestPipelineAsset > ( ) ;
104
108
GraphicsSettings . defaultRenderPipeline = m_RenderGraphTestPipeline ;
109
+ QualitySettings . renderPipeline = m_RenderGraphTestPipeline ;
105
110
106
111
// Getting the RG from the custom asset pipeline
107
112
m_RenderGraph = m_RenderGraphTestPipeline . renderGraph ;
@@ -113,6 +118,9 @@ public void Cleanup()
113
118
GraphicsSettings . defaultRenderPipeline = m_OldDefaultRenderPipeline ;
114
119
m_OldDefaultRenderPipeline = null ;
115
120
121
+ QualitySettings . renderPipeline = m_OldQualityRenderPipeline ;
122
+ m_OldQualityRenderPipeline = null ;
123
+
116
124
m_RenderGraph . Cleanup ( ) ;
117
125
118
126
Object . DestroyImmediate ( m_RenderGraphTestPipeline ) ;
@@ -969,6 +977,35 @@ public void CreateLegacyRendererLists()
969
977
GameObject . DestroyImmediate ( gameObject ) ;
970
978
}
971
979
980
+ [ Test ]
981
+ public void RenderPassWithNoRenderFuncThrows ( )
982
+ {
983
+ // We need a real ScriptableRenderContext and a camera to execute the render graph
984
+ // add the default camera
985
+ var gameObject = new GameObject ( "testGameObject" )
986
+ {
987
+ hideFlags = HideFlags . HideAndDontSave
988
+ } ;
989
+ gameObject . tag = "MainCamera" ;
990
+ var camera = gameObject . AddComponent < Camera > ( ) ;
991
+
992
+ // record and execute render graph calls
993
+ m_RenderGraphTestPipeline . recordRenderGraphBody = ( context , camera , cmd ) =>
994
+ {
995
+ using ( var builder = m_RenderGraph . AddRenderPass < RenderGraphTestPassData > ( "TestPassWithNoRenderFunc" , out var passData ) )
996
+ {
997
+ builder . AllowPassCulling ( false ) ;
998
+
999
+ // no render func
1000
+ }
1001
+ } ;
1002
+ LogAssert . Expect ( LogType . Error , "Render Graph Execution error" ) ;
1003
+ LogAssert . Expect ( LogType . Exception , "InvalidOperationException: RenderPass TestPassWithNoRenderFunc was not provided with an execute function." ) ;
1004
+ camera . Render ( ) ;
1005
+
1006
+ GameObject . DestroyImmediate ( gameObject ) ;
1007
+ }
1008
+
972
1009
/*
973
1010
// Disabled for now as version management is not exposed to user code
974
1011
[Test]
0 commit comments