Commit 9e3a043
Fix URP pass name handling
This is a continuation of https://github.cds.internal.unity3d.com/unity/unity/pull/50405
The goal is to have identical URP render pass names in all our profiling tools (RG viewer, Frame Debugger and Profiler).
The names are now also identical between RG and non-RG/Compatibility passes.
This PR fixes a number of potential bugs with regards to setting ScriptableRenderPass.profilerSampler to null, it fixes incorrect profiler scopes (inside the static method shared between RG and non-RG), improves more pass names using the naming convention from the previous PR and could have a very minor performance benefit in release build.
In this PR, we separately store the passName and the profileSampler because these samplers can be null in the release build. Therefore, we can't just use sampler.name. By using the ScriptableRenderPass properties (passName, profileSampler) these names are kept in sync automatically.
The default name for a (user created) sub-class of a ScriptableRenderPass is now more descriptive, using the sub-class name instead of the base class.
The default RenderFeature that users create from the menu is updated to using this.
The profile samplers being null in a release build was introduced by this PR as an optimization https://github.cds.internal.unity3d.com/unity/unity/pull/41824
However, in URP, many samplers are created differently, leading to limited performance gain, and inconsistency with some samplers being null and some not in the release build. This PR improves this so more samplers are null in a release build. Potentially gaining around 0.1ms main thread CPU in release on low end CPUs.
Before and after this PR (no change), URP, ProfileSamplers references are kept in a few different places. Depending on that, the samplers can be nullified in the release build.
- ScriptableRenderPass.profileSampler: used by RG and non-RG, in this PR, when using RG, they are nullified
- ProfileSampler.Get(URPProfileId): same pattern as with HDRP, these are nullified by the change from Julien
- RenderGraph.m_DefaultProfilingSamplers: created automatically when adding a pass without a sampler, these are nullified
- Other places of the URP code (outside of a pass): these are NOT nullified.
Likely, part of the optimization for HDRP came from the dictionary .TryGetValue with large pass dictionaries. The samplers kept outside of dictionary don't have this cost. So it likely will not improve performance to clean up these.
Since some samplers can be null in the release build, it's bad practice (errors!) to use sampler.name.
However, the earlier PR to nullify this might have introduced issues already. To avoid issues with user project that do this (very low chance), in this PR, ScriptableRenderPass.profileSampler is only nullified in RenderGraph mode (not Compatibility).
This makes it a bit more complicated to ensure that the pass name and the sampler name (shown in profiler) don't get out of sync. However, it's confusing for users to see different names in different tools and complicates matching them during analysis. Hence the changes in this PR.
The RenderGraph add pass methods (eg AddRasterPass, ...) have overloads for both passing a passName and a sampler, and one with only a passName. The use of passing only the passName seems recommended for users since they can't go out of sync, RG creates a new profiler with that name, and will nullify it in a release build, and users don't have access to the profilerSampler. In non release builds, there might be a small perf overhead of this practice since the dictionary can become large.1 parent 868e580 commit 9e3a043
File tree
32 files changed
+222
-176
lines changed- Packages/com.unity.render-pipelines.universal
- Editor/RendererFeatures
- Runtime
- Decal
- DBuffer
- ScreenSpace
- Passes
- RendererFeatures
- Samples~/URPRenderGraphSamples/Blit
32 files changed
+222
-176
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
| 241 | + | |
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
895 | 895 | | |
896 | 896 | | |
897 | 897 | | |
898 | | - | |
| 898 | + | |
899 | 899 | | |
900 | 900 | | |
901 | 901 | | |
| |||
Lines changed: 4 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
18 | 17 | | |
19 | 18 | | |
20 | | - | |
| 19 | + | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
32 | | - | |
| 31 | + | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
| |||
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
47 | | - | |
48 | | - | |
49 | 46 | | |
50 | 47 | | |
51 | 48 | | |
| |||
55 | 52 | | |
56 | 53 | | |
57 | 54 | | |
58 | | - | |
| 55 | + | |
59 | 56 | | |
60 | 57 | | |
61 | 58 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
| 283 | + | |
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| |||
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | | - | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
| |||
214 | 213 | | |
215 | 214 | | |
216 | 215 | | |
217 | | - | |
| 216 | + | |
218 | 217 | | |
219 | 218 | | |
220 | 219 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
0 commit comments