Commit Graph

138 Commits

Author SHA1 Message Date
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
andrew lauritzen
70a2837739 Move static separate cache to second texture array slice rather than "below" in UV space:
- Avoid gotchas with max texture size when static separate enabled
- Simplify addressing logic in a number of places
- Avoid allocating extra HZB that we never use

Details:
- Support rendering/sampling to 2D depth texture array in Nanite and virtual shadow map pass
- Remove some unnecessary HZB-related cvars
- Remove unused permutations from VSM HW raster

#preflight 624f4e5611261bc7b2171208
#rb jamie.hayes

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 19679616 via CL 19679656 via CL 19679706
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v938-19570697)

[CL 19680680 by andrew lauritzen in ue5-main branch]
2022-04-07 18:36:13 -04:00
Charles deRousiers
61cf50b66f Change Strata binding buffer function args to take view instead of the explicit scene data.
#rb none
#jira none
#preflight 6246ee2a292f228e0914eed2
#fyi sebastien.hillaire

[CL 19586823 by Charles deRousiers in ue5-main branch]
2022-04-01 08:35:55 -04:00
ola olsson
b86b9f1d70 Add tracking dirty VSM pages during Nanite rendering to reduce HZB build cost
- Make VSM HZB persistent, reallocated on pool size change.
- Enable two-pass HZB by default for Nanite VSM (r.Shadow.Virtual.UseHZB == 2)

#rb andrew.lauritzen
#preflight 623b1c6088538cd45e0ce824

#ROBOMERGE-AUTHOR: ola.olsson
#ROBOMERGE-SOURCE: CL 19478487 via CL 19481406 via CL 19481553
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v936-19480137)

[CL 19484029 by ola olsson in ue5-main branch]
2022-03-23 15:54:41 -04:00
Ola Olsson
245fe2702a Implement two-pass HZB occlusion culling for VSM (Nanite path) enabled through r.Shadow.Virtual.UseHZB = 2
- Refactor Nanite instance / cluster culling to accommodate VSM HZB tests without blowing out code size.
- Consolidate VSM HZB testing code to one flexible path.
- Always tests against static cached (when static separate is enabled) as this provides the best coverage.
- Currently performs a full HZB rebuild, which is expensive.

#rb rune.stubbe
#fyi andrew.lauritzen
#preflight 62309454e65a7e65d6855209
#robomerge fnnc

[CL 19384824 by Ola Olsson in ue5-main branch]
2022-03-15 10:05:21 -04:00
graham wihlidal
25f8e29153 Removed a massive number of Nanite rasterizer shader permutations across all platforms/shaderdbs, significantly improving iteration times for the editor and cooker, especially when these numbers get multiplied by the number of materials that utilize programmable features in addition to the default material "fixed function" path.
Reductions *per material*:

SM5
--
FHWRasterizeVS: 832 -> 21
FHWRasterizePS: 104 -> 39

SM6
--
FHWRasterizeVS: 320 -> 9
FHWRasterizeMS: 640 -> 9
FHWRasterizePS: 120 -> 30

Vulkan
--
FHWRasterizeVS: 320 -> 9
FHWRasterizePS: 40 -> 15

Other platforms redacted =)

-- Details

* CLUSTER_PER_PAGE has been fully removed (since we no longer ever run CLUSTER_PER_PAGE=0), which now makes it mutually inclusive with VIRTUAL_TEXTURE_TARGET
* HAS_RASTER_BIN has been replaced with a dynamic branch, since this is just a per cluster index offset based on a simple uniform buffer load
* ADD_CLUSTER_OFFSET has been replaced with a dynamic branch, since this is just a per cluster index offset based on a simple uniform buffer load
* HAS_PREV_DRAW_DATA has been replaced with a dynamic branch, since this is just a per cluster index offset based on a simple uniform buffer load
* NEAR_CLIP (only change to significantly affect codegen) has been turned into a dynamic branch based on FNaniteView - this lets us merge depth clip/clamp rasterizer calls in VSM together instead of relying on HAS_PREV_DRAW_DATA, and a future optimization can now be done to merge local and directional light full Nanite pipeline calls together.
* VISUALIZE permutation removed from VS/MS since it only loaded unform values that passed down per-vertex into fragment stage as nointerpolation parameters. Pixel shader now constructs this uint2 directly under the VISUALIZE permutation
* NANITE_MESH_SHADER_INTERP removed by default but still left in the code, since it is a work in progress potential optimization for DX12 mesh shaders
* Removed explicit Lumen and VSM usage of NANITE_RENDER_FLAG_HAVE_PREV_DRAW_DATA (now the dynamic branch path is only taken if CullRasterizeMultiPass implicitly breaks the rasterization into multiple calls due to NANITE_MAX_VIEWS_PER_CULL_RASTERIZE_PASS overflow)

Performance was tested on a 2080Ti in AncientGame, and the delta is effectively noise (tested cached and uncached VSM). Further testing on other platforms will occur, but important to get this change in for all the benefits and easy to tweak things later if needed.

#rb rune.stubbe
#fyi brian.karis, ola.olsson, andrew.lauritzen, jamie.hayes, daniel.wright, krzysztof.narkowicz
#preflight 622e684c7e2e35638c96a16a
#robomerge FNNC

[CL 19370372 by graham wihlidal in ue5-main branch]
2022-03-13 23:18:25 -04:00
Ola Olsson
cd997d47b2 Make page rect clipping consistently used and always before page flag overlap test (improves accuracy).
- also fix construction of top part of VSM HZB.

#rb rune.stubbe
#robomerge FNNC
#fyi andrew.lauritzen
#preflight 6220a20ad059c6be6c8ca719

[CL 19241653 by Ola Olsson in ue5-main branch]
2022-03-03 06:41:20 -05:00
Charles deRousiers
3b1b1c0a69 Merge ShaderPrint ShaderDrawDebug to ease binding/setup.
#rb none
#jira none
#preflight 62153e289e113332ba232936

[CL 19079474 by Charles deRousiers in ue5-main branch]
2022-02-22 15:35:01 -05:00
andrew lauritzen
ae021ee661 Rename cvar for consistency.
#preflight 620c18b601253d2e19ec8bdd

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 19059104 in //UE5/Release-5.0/... via CL 19074695
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v921-19075845)

[CL 19076601 by andrew lauritzen in ue5-main branch]
2022-02-22 13:52:40 -05:00
Charles deRousiers
a02d41c4ee Renamed PROJECT_STRATA into STRATA_ENABLED.
This avoids to define STRATA_ENABLED as 'env. define' for all global shaders needing a Strata specific path.

#rb none
#jira none
#fyi sebastien.hillaire
#preflight 62151b25797dbbeb472ae2eb

[CL 19074999 by Charles deRousiers in ue5-main branch]
2022-02-22 12:35:58 -05:00
charles derousiers
2a2828c8a4 Add VirtualShadowMap prefix to all shaders related to virtual shadow map.
#rb andrew.lauritzen
#jira none
#preflight 620a2a37015ab8f37a3e2d2c
#lockdown juan.canada

#ROBOMERGE-AUTHOR: charles.derousiers
#ROBOMERGE-SOURCE: CL 18977253 in //UE5/Release-5.0/... via CL 18977320 via CL 18977399
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)

[CL 18977416 by charles derousiers in ue5-main branch]
2022-02-14 05:44:50 -05:00
andrew lauritzen
c79193c915 Many LWC fixes for virtual shadow maaps:
- Shadow PreViewTranslation and ClipmapOrigin become full LWC tile/offset values on the GPU
- In most cases, the camera's and shadow's PreViewTranslations can be subtracted on the GPU to produce a regular-range value to transform from PrimaryView.TranslatedWorld to ShadowView.TranslatedWorld
- Miner cleanup and improvements to SMRT trace loop
- Remove special case for ortho matrices disabling PreViewTranslation in FViewMatrices
- Remove broken static function local and associated cvar r.PreViewTranslation

#preflight 6205dd571404d0fef964d721
#jira UE-139824
#rb graham.wihlidal
#lockdown juan.canada

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 18956693 in //UE5/Release-5.0/... via CL 18956877 via CL 18957087
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)

[CL 18958948 by andrew lauritzen in ue5-main branch]
2022-02-11 14:57:27 -05:00
Charles deRousiers
70470655e0 Add strata support for virtual shadow map
#rb none
#jira none
#fyi sebastien.hillaire
#preflight 62051f391f57995eddb7e40e

[CL 18935509 by Charles deRousiers in ue5-main branch]
2022-02-10 09:53:46 -05:00
andrew lauritzen
ea2a042954 Avoid asserts even when VSM is disabled/unsupported (in this case on Android devices with NPOT 2D texture size maxes)
Avoid a bunch of unnecessary math when VSM is disabled

#jira UE-140638
#rb florin.pascu
#preflight 62040cb3d619b08d92f483a7
#lockdown juan.canada

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 18923637 in //UE5/Release-5.0/... via CL 18927164 via CL 18928856
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v916-18915374)

[CL 18929282 by andrew lauritzen in ue5-main branch]
2022-02-09 19:28:57 -05:00
andrew lauritzen
a936f96e04 Add clipmap address space visualization and hook up to (advanced) visualization stuff.
Move visualize enum/defines to shared header file.
Rename a few cvars for consistency.

#rb graham.wihlidal
[FYI] ola.olsson
#preflight 61f9d8921d7ca8ed2d628ccd

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 18819821 in //UE5/Release-5.0/... via CL 18819825 via CL 18822904
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042)

[CL 18825054 by andrew lauritzen in ue5-main branch]
2022-02-02 08:19:08 -05:00
fred kimberley
7fbfaf57c8 Require explicit constructors/casts when converting between FVector, FVector3d, and FVector3f.
#jira UE-122078
#rb Andrew.Davidson, Colin.McGinley
#preflight standard build

#ROBOMERGE-AUTHOR: fred.kimberley
#ROBOMERGE-SOURCE: CL 18817999 in //UE5/Release-5.0/... via CL 18818012 via CL 18822871
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042)

[CL 18824721 by fred kimberley in ue5-main branch]
2022-02-02 07:59:31 -05:00