Skip to content

Commit 4084c58

Browse files
RoseHirigoyenEvergreen
authored andcommitted
SRP-266 Throw if AddRenderPass is used with NRP
1 parent 9b64832 commit 4084c58

4 files changed

Lines changed: 260 additions & 198 deletions

File tree

Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/NativePassCompiler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ void BuildGraph()
151151
if (inputPass.type == RenderGraphPassType.Legacy)
152152
{
153153
throw new Exception("Pass '" + inputPass.name + "' is using the legacy rendergraph API." +
154-
" You cannot use legacy passes with the native render pass compiler." +
155-
" Please do not use AddPass on the rendergraph but use one of the more specific pass types such as AddRasterRenderPass");
154+
" You cannot use legacy passes with the Native Render Pass Compiler." +
155+
" The APIs that are compatible with the Native Render Pass Compiler are AddUnsafePass, AddComputePass and AddRasterRenderPass.");
156156
}
157157
#endif
158158

Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ internal void ForceCleanup()
592592
nativeCompiler?.Cleanup();
593593

594594
m_CompilationCache?.Clear();
595-
595+
596596
DelegateHashCodeUtils.ClearCache();
597597
}
598598

@@ -1165,6 +1165,17 @@ void CheckNotUsedWhenRecordingPass()
11651165
throw new InvalidOperationException(RenderGraphExceptionMessages.GetExceptionMessage(RenderGraphState.RecordingPass));
11661166
}
11671167

1168+
[Conditional("DEVELOPMENT_BUILD"), Conditional("UNITY_EDITOR")]
1169+
void CheckNotUsingNativeRenderPassCompiler()
1170+
{
1171+
if (enableValidityChecks && nativeRenderPassesEnabled)
1172+
{
1173+
throw new InvalidOperationException(
1174+
"`AddRenderPass` is not compatible with the Native Render Pass Compiler. It is meant to be used with the HDRP Compiler. " +
1175+
"The APIs that are compatible with the Native Render Pass Compiler are AddUnsafePass, AddComputePass and AddRasterRenderPass.");
1176+
}
1177+
}
1178+
11681179
[Conditional("DEVELOPMENT_BUILD"), Conditional("UNITY_EDITOR")]
11691180
void CheckNotUsedWhenActive()
11701181
{
@@ -1368,11 +1379,12 @@ public RenderGraphBuilder AddRenderPass<PassData>(string passName, out PassData
13681379
[CallerLineNumber] int line = 0) where PassData : class, new()
13691380
#endif
13701381
{
1382+
CheckNotUsingNativeRenderPassCompiler();
13711383
CheckNotUsedWhenRecordingPass();
13721384

13731385
m_RenderGraphState = RenderGraphState.RecordingPass;
13741386

1375-
var renderPass = m_RenderGraphPool.Get<RenderGraphPass<PassData>>();
1387+
var renderPass = m_RenderGraphPool.Get<RenderGraphPass<PassData>>();
13761388
renderPass.Initialize(m_RenderPasses.Count, m_RenderGraphPool.Get<PassData>(), passName, RenderGraphPassType.Legacy, sampler);
13771389
renderPass.AllowGlobalState(true);// Old pass types allow global state by default as HDRP relies on it
13781390

0 commit comments

Comments
 (0)