Commit Graph

177 Commits

Author SHA1 Message Date
ola olsson
986ce1d230 Move processing of nanite visibility query out to FShadowSceneRenderer and make it not depend on the number of visible lights being rendered.
- This prevents leaving queries unprocessed which hits a check in the cleanup code.
 - Also translate the local-light culling volumes to world space to prevent incorrect culling.
 - Prevent nanite visibility queries from being issued if BeginVisibilityFrame has not been called (prevents potential leak).
 - Skip storing ActiveEvents if not running async.

#rb rune.stubbe
#preflight 637b416b4004f73f622b3779

[CL 23218910 by ola olsson in ue5-main branch]
2022-11-21 05:56:43 -05:00
ola olsson
21ad39d384 Support Nanite material visibility culling for VSM, r.Shadow.Virtual.Nanite.MaterialVisibility, default off.
#preflight 636e5ae58f4cb2e4dceda7e4

[CL 23107926 by ola olsson in ue5-main branch]
2022-11-11 18:59:13 -05:00
wouter dek
624299badf Disable VSM HZB culling when Nanite is disabled as a workaround for FORT-519775.
#preflight 636ba41ed0174259cc8682ca
#rb ola.olsson

[CL 23069543 by wouter dek in ue5-main branch]
2022-11-09 20:57:15 -05:00
wouter dek
7346256660 Fix compilation error due to var missing when precompiler flag is not set.
#rb trivial

[CL 22919193 by wouter dek in ue5-main branch]
2022-11-02 12:30:23 -04:00
wouter dek
582c3a10fe Add CSV counters for VSM.
#preflight 63624e2fce676ae8683cfaf2
#rb ola.olsson

[CL 22919154 by wouter dek in ue5-main branch]
2022-11-02 12:29:07 -04:00
ola olsson
991929f933 Add diagnostic logging / screen message for showing large objects overlapping many non-nanite VSM pages.
#rb wouter.dek
#preflight 635ba4b29c65b795862eba30

[CL 22829276 by ola olsson in ue5-main branch]
2022-10-28 11:39:21 -04:00
jamie hayes
2bb6c2d6df - Add DrawDistanceOrigin to Nanite view and allow it to be overridden for shadows.
- Enable Draw Distance culling and WPO Disable Distance for shadows.

#rb ola.olsson

[CL 22803497 by jamie hayes in ue5-main branch]
2022-10-26 23:18:39 -04:00
ola olsson
51e3d8ddfa Make the VSM page marking handle missing water mask (e.g., if r.Water.SingleLayer.TiledComposite is turned off)
#rb tim.doerries
#preflight 63566df5cb31f106ce873296

[CL 22779941 by ola olsson in ue5-main branch]
2022-10-26 10:53:03 -04:00
ola olsson
0210731408 Added support for using a stride to skip marking VSM every pixel, this improves performance on page marking (at the potential loss of some quality).
- Also moved Single Layer Water tile classification pass to the depth pre-pass and generated a mask to let the VSM page marking skip fetching water data for every pixel.

#rb tim.doerries,wouter.dek
[FYI] andrew.lauritzen
#preflight 635150d7047f3570ade21f92

[CL 22726871 by ola olsson in ue5-main branch]
2022-10-24 10:19:13 -04:00
graham wihlidal
1c86c4a042 Dynamic Nanite error heuristic (WIP)
#rb guillaume.abadie
[FYI] brian.karis, rune.stubbe, ben.woodhouse
#preflight skip

[CL 22724347 by graham wihlidal in ue5-main branch]
2022-10-24 09:18:17 -04:00
bryan sefcik
483f93dc1a Fixed misc include paths
#jira
#preflight 634f491669246074dbb2719d

[CL 22633214 by bryan sefcik in ue5-main branch]
2022-10-19 14:38:31 -04:00
ola olsson
3c9d97ef85 Implemented small-object culling for coarse pages, filters objects based on estimated footprint in pixels.
- Greatly reduces the number of non-nanite instances that are rasterized into the coarse pages, especially the very coarse one.
- Adds three cvars to control thresholds r.Shadow.Virtual.CoarsePagePixelThreshold[Dynamic|Static|DynamicNanite]
- Also culls invalidations in the same way.
- Refactored and optimized Nanite VSM instance culling (and also non-VSM).

#rb andrew.lauritzen,rube.stubbe
#preflight 634833cefd22d1fbde594be6

[CL 22571297 by ola olsson in ue5-main branch]
2022-10-17 14:30:13 -04:00
andrew lauritzen
5fa7ade72b Fix VSM when r.Nanite.ProjectEnabled=0
#jira UE-165479
#rb christopher.waters

[CL 22334556 by andrew lauritzen in ue5-main branch]
2022-10-04 13:52:45 -04:00
andrew lauritzen
f8032f4743 Optimizations to light loop for shadowed lights:
- Move translucent injection outside the loop rather as it shares state and doesn't need barriers between it. This had already been done for unshadowed lights but this implements it for shadowed lights as well.
- Implement VSM one pass projection (still default off) even when clustered shading is not enabled. Has two paths in the regular light loop:
  1) If another effect (ex. light functions) needs to interact with the screen shadow mask, a VSM composite path is inserted that does a quick copy from the one pass projection shadow mask bits
  2) If only VSM is needed for the light, the lookup is rolled directly into the deferred lighting pixel shader, eliding the screen shadow mask entirely
Especially in the second case this significantly cuts down on GPU idle time and g-buffer bandwidth, improving the performance of scenes with small local lights

#rb ola.olsson, charles.derousiers
#preflight 633b36f9ba39998ce84c34dd
#jira UE-122099

[CL 22327084 by andrew lauritzen in ue5-main branch]
2022-10-04 01:25:53 -04:00
ola olsson
e929658097 Implemented depth prepass for SingleLayerWater. Depth prepass output is fed into VSM page marking/allocation shader to get correct VSM pages for sampling VSM on water. The depth prepass is also used in the main water pass by setting the main pass depth test to EQUAL and forcing earlyZ. CopyTexture() is currently not supported for depth buffers on all platforms, so I had to write a custom copy shader to create a copy of the main depth buffer to render the water depth prepass into.
#ushell-cherrypick of 21812612 by tim.doerries
#rb Ola.Olsson, andrew.lauritzen, Sebastien.Hillaire
#rnx
#preflight 6331ccc3a4769ad714ad3473

[CL 22307543 by ola olsson in ue5-main branch]
2022-10-03 12:55:37 -04:00
ola olsson
d077efdf50 Dirty-page marking skips dynamic pages and merge only when static is dirty, also initialize dynamic pages from cached static pages, when available.
#preflight 6321b8948838676d103d3e75
#rb andrew.lauritzen
#preflight 632ae18af87253e02153cd56

[CL 22201428 by ola olsson in ue5-main branch]
2022-09-27 02:14:18 -04:00
dmitriy dyomin
0f1ba0cf45 Mobile: Light map artifacts with specific mesh when launched on Android
Supply a mesh LOD index into MDC batching CS so it can fetch a correct lighting information for each instance
#rb ola.olsson
#jira UE-164402
#preflight 632d8688671a1a24b564bd0c

[CL 22163633 by dmitriy dyomin in ue5-main branch]
2022-09-23 20:02:18 -04:00
wouter dek
735bad5574 Add a separate VSM cache for the views of each SceneCapture component
#jira UE-147440
#rb ola.olsson
#preflight 632821865f55ba280eab0a43

[CL 22072008 by wouter dek in ue5-main branch]
2022-09-19 04:15:20 -04:00
ola olsson
42e49bbbce Make distant light threshold respect resolution LOD bias for local lights such that more lights are treated as distant if LOD bias is increased.
#rb wouter.dek
#preflight 631f3c98ec5b0c765ffe0487

[CL 21986788 by ola olsson in ue5-main branch]
2022-09-13 13:23:39 -04:00
marc audy
4e37349e58 Attempt to fix vulkan shader compilation
error: cannot instantiate StructuredBuffer with given packed alignment; 'VK_EXT_scalar_block_layout' not supported
#rb Jamie.Hayes
[CODEREVIEW] Ola.Olsson
#rnx
#preflight 63200f15b602881e8eaee462

[CL 21986761 by marc audy in ue5-main branch]
2022-09-13 13:22:17 -04:00
ola olsson
a9b46eb202 Dirty page tracking for non-nanite implementation & WPO-invalidations from Nanite
- bMaterialMayModifyPosition -> bMaterialUsesWorldPositionOffset for non-nanite, we don't want to invalidate due to PDO
- Nanite instance culling records static primitives that invalidate the VSM (so they get cached as dynamic)
- Dirty page flags now store the invalidation as well (static & dynamic) so 3x in size
- Nanite VSM instance/cluster culling uses PRIMITIVE_SCENE_DATA_FLAG_EVALUATE_WORLD_POSITION_OFFSET to drive bHasMoved and invalidaiton.
- Non-nanite instance culling outputs dirty page flags for invalidating instances, with in-group load balancing for large footprints
- Store invalidation flags in physical page metadata flags (removed the cumulative dirty flags buffer).
- Added bAnyMaterialHasWorldPositionOffset (accessor AnyMaterialHasWorldPositionOffset()) to FPrimitiveSceneProxy.
- Driving PRIMITIVE_SCENE_DATA_FLAG_EVALUATE_WORLD_POSITION_OFFSET from bAnyMaterialHasWorldPositionOffset in addition to EvaluateWorldPositionOffset.
- Removed near clip permutation for non-nanite VSM culling shader.
- Non-nanite vsm raster passes are all batched in a single RDG pass to better allow overlap between draws and lower pass overhead.
- Removed old GPU->GPU invalidation logic.
- Removed dynamic caster flags and update the physical page metadata directly
- Renamed PRIMITIVE_SCENE_DATA_FLAG_SHOULD_CACHE_SHADOW -> PRIMITIVE_SCENE_DATA_FLAG_SHOULD_CACHE_SHADOW

#rb andrew.lauritzen,jamie.hayes
#jira UE-147061
#preflight 631b0a18a60c539c98cf1308

[CL 21973831 by ola olsson in ue5-main branch]
2022-09-12 18:06:57 -04:00
wouter dek
c0bf519247 Fix packing alignment of FShadowMapCacheData
#rb none
#jira none
#preflight 631f0cfb59159ac18338960c

[CL 21962497 by wouter dek in ue5-main branch]
2022-09-12 06:58:25 -04:00
wouter dek
517c4ca25d Make VSM clipmap CornerOffset relative and upgrade WorldCenter to 64-bit type to fix directional shadow LWC glitches
#jira ue-155125
#rb andrew.lauritzen
#preflight 631eded95b06877acb759720

[CL 21961247 by wouter dek in ue5-main branch]
2022-09-12 03:42:35 -04:00
andrew lauritzen
ac63934274 Automatic categorization of primitives into static/dynamic VSM caching based on invalidation requests:
- Store cache flag in primitive scene proxy, default based on mobility initially
- When CPU invalidations of primitives that are cached as static happen, invalidate the entire primitive (all instances) and flip the flag to dynamic
- When GPU invalidations of primitives that are cached as static happen, mark a bit in a buffer that is read back to the CPU. In future frames, use the bits to find the associated primitive (if it still exists), swap it to dynamic and invalidate all of its instances
- Dynamic primitives are always cached as dynamic/movable
- Moved instance invalidation buffer ownership to cache manager (we don't need two copies at once)

#rb ola.olsson
#preflight 630d0d88660db81edb749282
#jira UE-133723

[CL 21696465 by andrew lauritzen in ue5-main branch]
2022-08-30 02:21:44 -04:00
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