Commit Graph

153 Commits

Author SHA1 Message Date
ola olsson
6c563cf263 Batch of improvements to page management, that help improve passes of page allocation.
Implemented single-page page table support for distant lights
- store only a single page table entry for distant lights
- modify page lookup logic in various places to handle this

Implemented override behavior to render everything to dynamic pages for a light that always invalidates using r.Shadow.Virtual.Cache.ForceInvalidateClipmaps (behave as uncached, despite caching being enabled).
This brings performance to par with uncached rendering by removing various overheads that are not achieving anything for this case.
- Added a new flag to the nanite view to indicate if it is uncached VSM_PROJ_FLAG_UNCACHED, currently driven by the cvar r.Shadow.Virtual.Cache.ForceInvalidateClipmaps
- If this flag is set on a view ShouldCacheInstanceAsStatic, which now takes a nanite view, returns false, causing all rendering to go to the dynamic pages.
- To preserve HZB functionality, the HZB build is modified to load from the dynamic depth pages (normally it uses the static)
- The page initializer (that clears depth) skips static pages for uncached bviews as they will not be used.
- Finally the page merge pass that combines static & dynamic depth into the dynamic page also skips pages from uncached views.

Optimized page allocation pass by storing the actual pages needing allocation from the cache init pass.
Optimized hierarchical page flag generation by dispatching over physical pages instead of virtual.
Fixed dynamic primitive cache invalidation logic.

#jira UE-122102
#rb andrew.lauritzen
#preflight 63087c2592620e5ec3aa3f2f

[CL 21590421 by ola olsson in ue5-main branch]
2022-08-26 11:06:04 -04:00
ola olsson
224a04a0d0 Changed VSM Dirty flags to physical space to save overhead from large virtual address spaces (e.g., many lights) and track cumulative dirty flags to ensure pages are merged when needed.
#rnx
#rb andrew.lauritzen
#preflight 62ff3bfe3f75602b2f4d7c91

[CL 21468241 by ola olsson in ue5-main branch]
2022-08-19 19:37:59 -04:00
wouter dek
ddae01c8d9 Make VSM debug visualizations work in splitscreen
#jira UE-160090
#preflight 62fdf1a93c4417dcecf7305b
#rb ola.olsson, andrew.lauritzen

[CL 21454765 by wouter dek in ue5-main branch]
2022-08-19 04:31:18 -04:00
christopher waters
e9a48d6897 Removing more uses of GMaxRHIFeatureLevel.
Focus started on GenerateMips and AddClearUAVPass.

#jira none
#rb mihnea.balta
#preflight 62fe768d200ff87e07c5e1ad

[CL 21448320 by christopher waters in ue5-main branch]
2022-08-18 15:29:29 -04:00
ola olsson
13b8af8359 Fix buffer size mixup causing crashes in VSM page marking & incorrect pixel position causing OOB buffer access (and presumably incorrect shadows).
- Also fetch correct light data when the light list is compacted.

#jira UE-160440,FORT-501102
#rb rune.stubbe,kevin.ortegren
[FYI] andrew.lauritzen
#preflight 62fb844dfd15f5152dc15b37

#ROBOMERGE-AUTHOR: ola.olsson
#ROBOMERGE-SOURCE: CL 21404060 via CL 21404063 via CL 21404064
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v975-21357124)

[CL 21407091 by ola olsson in ue5-main branch]
2022-08-16 12:33:52 -04:00
ola olsson
2b58babef4 Implement per-view clipmap cache entry for VSM & make page marking only mark relevant views.
#jira UE-159863
#rb rune.stubbe
[FYI] andrew.lauritzen,Arciel.Rekman
#preflight 62d94bf1110da0f944b19f1c

#ROBOMERGE-AUTHOR: ola.olsson
#ROBOMERGE-SOURCE: CL 21201156 via CL 21201164 via CL 21201176
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v972-20964824)

[CL 21203556 by ola olsson in ue5-main branch]
2022-07-21 12:59:02 -04:00
ola olsson
89d17897c6 Added support for Distant Lights (VSM)
- Added FShadowSceneRenderer to handle shadow rendering (transient) work - intended to take over more responsibility from here on.
- Added cache invalidation when lights are removed from the FScene (required as ID / cache key may change)
- Modified caching scheme to drop cache entries when caching is disabled.
- Changed local light footprint estimation to depend on the scaled resolution (screen percentage)
- Moved light location data and test to per-light cache entry (rather than per-shadow map)

#rb andrew.lauritzen
#jira UE-122102
#preflight 62d820cb4b6d775f5fa9328a

#ROBOMERGE-OWNER: ola.olsson
#ROBOMERGE-AUTHOR: ola.olsson
#ROBOMERGE-SOURCE: CL 21198820 via CL 21198827 via CL 21198864
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v972-20964824)

[CL 21199396 by ola olsson in ue5-main branch]
2022-07-21 07:46:36 -04:00
jason hoerner
582670e01d VSM multi-GPU: Invalidate VSM cache when GPU mask changes, to prevent uninitialized data from being used.
#jira none
#rnx
#rb jason.nadro
#preflight 62c867b51d0706bf24c1ece0

[CL 21012100 by jason hoerner in ue5-main branch]
2022-07-08 15:10:05 -04:00
Charles deRousiers
9611ef9d94 Remove hair strands non-tiled path.
#rb none
#jira none
#preflight 62c58351a6654f97296f7fb6

[CL 20965425 by Charles deRousiers in ue5-main branch]
2022-07-06 08:50:35 -04:00
ola olsson
0b7b093519 Added distance based instance/cluster culling for views in Nanite to improve local light rendering (measured ~20% perf improvement for local lights - highly content dependent).
- Added RangeBasedCullingDistance to Nanite view & NANITE_VIEW_FLAG_DISTANCE_CULL to indicate if used
- Added light radius to VSM projection data and added culling invalidations based on range also.
- Added unrelated flag & flag field to VSM to reduce shader header change churn (VSM_PROJ_FLAG_CURRENT_DISTANT_LIGHT).
- Added light range test in page marking shader.

Simplify Nanite LOD calculations by performing them in world space instead of local space
- This also allows us no longer precalculate ViewPosScaledLocal and ViewForwardScaledLocal in DynamicData

#rb rune.stubbe
#preflight 62beb9303f0d6beee2da98db

#ROBOMERGE-AUTHOR: ola.olsson
#ROBOMERGE-SOURCE: CL 20913913 via CL 20913992 via CL 20913998
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v971-20777995)

[CL 20916199 by ola olsson in ue5-main branch]
2022-07-01 12:47:13 -04:00
zach bethel
34623f0321 Replaced thread-local MemStack with ConcurrentLinearAllocator across the renderer.
- Removed scene render mem-mark among others. MemStack usage is now restricted to local scopes with known marks.
 - Render resources with destructors are allocated using the FSceneRenderingBulkObjectAllocator on FSceneRenderer, which is deleted when the scene render is.

#preflight 62b266e20d4d6228de97babe
#rb mihnea.balta, yuriy.odonnell

[CL 20907647 by zach bethel in ue5-main branch]
2022-06-30 19:55:24 -04:00
andrew lauritzen
a8a3bebe8d Fix race between coarse and pixel page marking when non-nanite is disabled in coarse pages.
#rb ola.olsson
#preflight 62b3cd03896a01b1bdc419fd

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 20796768 via CL 20799839 via CL 20801509
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v971-20777995)

[CL 20803674 by andrew lauritzen in ue5-main branch]
2022-06-23 18:08:35 -04:00
andrew lauritzen
ae31bd8019 SMRT local lights updates
- Improvements to cube map filtering to eliminate various leaking artifacts at cube edges/corners
- Implement texel dither and optimal bias for local lights
- Remove some half stuff that was causing some sub-optimal compilation
- Fix VSM visualization alignment
- Add a general purpose permutation parameter that can be set for A/B testing projection performance that affects register allocation
- General cleanup

#rb ola.olsson
#preflight 62b350da767c9aaf349e3243

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 20779131 via CL 20780276 via CL 20780946
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v970-20704180)

[CL 20782054 by andrew lauritzen in ue5-main branch]
2022-06-22 17:22:27 -04:00
jason hoerner
6144ebf450 Scene renderer no longer contains multiple view families. Instead, multiple view families are handled by creating multiple scene renderers, which are added to a linked list with the first scene renderer as the list head. This more or less reverses CL 19813996, while preserving the optimizations gained from having knowledge of multiple scene renderers. This includes deferring cross GPU resource transfer waits to the last scene render, running ray tracing scene update once, and only flushing resources once. Future optimizations and bug fixes may take advantage of additional information from other scene renderers.
The refactor to get rid of the FSceneTextures and FSceneTexturesConfig global singletons has also been preserved.  The FViewFamilyInfo is used to hold those structures, so client facing API functions that lack a scene renderer reference can still pull the FSceneTextures[Config] from the view family pointer.  All other scene renderer state has been moved from FViewFamilyInfo back into FSceneRenderer.

#jira none
#rnx
#rb ola.olsson krzysztof.narkowicz zach.bethel
#preflight 629f770e233ae0a8f8fb7f2e

[CL 20540730 by jason hoerner in ue5-main branch]
2022-06-07 13:19:54 -04:00
Jeremy Moore
f40585c803 ShaderPrint: Deprecate SetParameters version that takes an FViewInfo.
Clients outside Renderer should use the default view, or the self managed FShaderPrintData (improvements to that incoming).
#preflight 629a384c6879a2ac678a889e

[CL 20488523 by Jeremy Moore in ue5-main branch]
2022-06-03 12:58:31 -04:00
Ola Olsson
65feec4130 Fixed local VSM Nanite rendering by making sure the mip views have set up TranslatedWorldToSubpixelClip correctly.
#rnx
#rb jamie.hayes
#preflight 628739252c34da686abc3088
#jira UE-151665

[CL 20291919 by Ola Olsson in ue5-main branch]
2022-05-20 03:17:33 -04:00
zach bethel
f6311d1011 Cleaned up FRHIRenderPassInfo cruft and forwarded resolve operations through a common RHI core method.
#preflight 62842b5982530182724612f6

[CL 20262457 by zach bethel in ue5-main branch]
2022-05-18 12:29:26 -04:00
zach bethel
1a6dbc061d Deprecated FRDGBufferDesc::EUnderlyingType
#preflight 62756de8d8373707f22a6144
#rb christopher.waters

[CL 20082899 by zach bethel in ue5-main branch]
2022-05-06 15:44:23 -04:00
zach bethel
94dae5bea0 Ported GPU scene buffers to RDG.
#rb Krysztof.narkowicz
#preflight 627149d0fe09c0cfbc3c7bdd

[CL 20027095 by zach bethel in ue5-main branch]
2022-05-03 12:08:20 -04:00
jason hoerner
af48ea5a98 UE5_MAIN: Multi-view-family scene renderer refactor, part 2. Move FSceneTextures singleton out of RDG blackboard and FSceneTexturesConfig global variable singleton, into FViewFamilyInfo. This is necessary to allow multiple view families to render in a single render graph and a single scene renderer call.
* Existing calls to CreateSceneTextureShaderParameters and similar functions use "GetSceneTexturesChecked", which allows for the possibility that they are reached in a code path where scene textures haven't been initialized, and nullptr is returned instead of asserting.  The shader parameter setup functions then fill in dummy defaults for that case.  The goal was to precisely match the original behavior, which queried the RDG blackboard, and gracefully handled null if scene textures weren't there.  This definitely appears to occur in FNiagaraGpuComputeDispatch::ProcessPendingTicksFlush, which can be called with a dummy scene with no scene textures.  In the future, I may change this so dummy defaults are filled in for FSceneTextures at construction time, so the structure is never in an uninitialized state, but I would like to set up a test case for the Niagara code path before doing that, and the checks aren't harmful in the meantime.
* I marked as deprecated global functions which query values from FSceneTexturesConfig, but they'll still work with the caveat that if you use multi-view-family rendering, the results will be indeterminate (whatever view family rendered last).  There was only one case outside the scene renderer that accessed the globals (depth clear value), which I removed, noting that there is nowhere in the code where we modify the depth clear value from its global default.  I would like to permanently deprecate or remove these at some point.  Display Cluster is the only code that's currently using the multi-view-family code path, and as a new (still incomplete) feature, third party code can't be using it, and won't be affected.

#jira NONE
#rb chris.kulla zach.bethel mihnea.balta
#preflight 6261aca76119a1a496bd2644

[CL 19873983 by jason hoerner in ue5-main branch]
2022-04-22 17:33:02 -04:00
jason hoerner
b19bb6be2f UE5_MAIN: Multi-view-family scene renderer refactor, part 1. Major structural change to allow scene renderer to accept multiple view families, with otherwise negligible changes in internal behavior.
* Added "BeginRenderingViewFamilies" render interface call that accepts multiple view families.  Original "BeginRenderingViewFamily" falls through to this.
* FSceneRenderer modified to include an array of view families, plus an active view family and the Views for that family.
* Swap ViewFamily to ActiveViewFamily.
* Swap Views array from TArray<FViewInfo> to TArrayView<FViewInfo>, including where the Views array is passed to functions.
* FSceneRenderer iterates over the view families, rendering each one at a time, as separate render graph executions.
* Some frame setup and cleanup logic outside the render graph runs once.
* Moved stateful FSceneRenderer members to FViewFamilyInfo, to preserve existing one-at-a-time view family rendering behavior.
* Display Cluster (Virtual Production) uses new API.

Next step will push everything into one render graph, which requires handling per-family external resources and cleaning up singletons (like FSceneTextures and FSceneTexturesConfig).  Once that's done, we'll be in a position to further interleave rendering, properly handle once per frame work, and solve artifacts in various systems.

#jira none
#rnx
#rb zach.bethel
#preflight 625df821b21bb49791d377c9

[CL 19813996 by jason hoerner in ue5-main branch]
2022-04-19 14:45:26 -04:00
andrew lauritzen
d78351e7a5 Check page mask in Nanite before invalidating VSM HZB to avoid excessive invalidations
Add cvar to force full HZB update for debugging
Force invalidation of static pages for any non-movable objects, even if they currently "draw velocity" due to editor movement
- Fixes shadows staying in the original location when dragging static objects in editor
- This is also step 1 to having a more heuristic static/dynamic per-prim split where things can go from one bucket to the other

#preflight 62585cb86e2c50550f07a394
#rb jamie.hayes

[CL 19766198 by andrew lauritzen in ue5-main branch]
2022-04-14 19:28:00 -04:00
Arciel Rekman
700c39e0e7 Fix VSM debug view being the same for the right eye.
#rb Andrew.Lauritzen
#review @Andrew.Lauritzen, @Robert.Srinivasiah, @Jules.Blok
#jira none
#preflight 625642c45f20a0a34d8fbaf7

[CL 19734289 by Arciel Rekman in ue5-main branch]
2022-04-12 23:44:41 -04:00
andrew lauritzen
d72db56fa1 Fix merge issue
#rb trivial

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 19727118 via CL 19727328 via CL 19727839
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v938-19570697)

[CL 19733201 by andrew lauritzen in ue5-main branch]
2022-04-12 21:16:56 -04:00
andrew lauritzen
833a1f56e1 Quantize VSM metadata allocations to reduce buffer size churn
#preflight 6255ce109a0f82a315260280
#rb graham-wihlidal

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 19727063 via CL 19727317 via CL 19727826
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v938-19570697)

[CL 19733194 by andrew lauritzen in ue5-main branch]
2022-04-12 21:16:42 -04:00