Commit Graph

73 Commits

Author SHA1 Message Date
zach bethel
16dcf5b313 Refactored Lumen and Distance Field buffers to RDG.
- Replaced FRW{Structured, ByteAddress}Buffer with TRefCountPtr<FRDGPooledBuffer>
 - Replaced ResizeResourceIfNeeded with Resize{Structured, ByteAddress}BufferIfNeeded.
 - Replaced FScatterUploadBuffer with FRDGScatterUploadBuffer.
 - Removed awkward copy of page table buffers now that scatters are on the RDG timeline.
 - Reduced number of uniform buffers created by consolidating within FLumenSceneFrameTemporaries.
 - Fixed up const-correctness of FLumenSceneFrameTemporaries to sanity check that resources were not being mutated later in the frame.
 - Reduced explicit view creations somewhat.
 - Distance fields needs an FDistanceFieldSceneFrameTemporaries to cache RDG resources, but I held off on this due to the number of files it would touch.

#rb krzyzstof.narkowicz, daniel.wright

#ROBOMERGE-AUTHOR: zach.bethel
#ROBOMERGE-SOURCE: CL 19921040 via CL 19922067 via CL 19922607
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v943-19904690)

[CL 19925590 by zach bethel in ue5-main branch]
2022-04-26 14:37:07 -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
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
krzysztof narkowicz
0da8f71523 Refactored Distance Field culling
* Removed culled DF object copies during culling. Instead now only indices to culled objects are stored
* Refactored DF heightfield object loads into FHeightfieldObjectBounds and FHeightfieldObjectData

This is a step towards optimizing DF culling and reusing this code for Lumen Landscape culling

Perf Reverb on 2080:
* CullMeshSDFObjectsToFrustum 0.04ms->0.03ms (removed DF object copies)
* Other passes didn't change

#preflight 61f5a7b7694910780bd91918
#rb Tiago.Costa

#ROBOMERGE-AUTHOR: krzysztof.narkowicz
#ROBOMERGE-SOURCE: CL 18789232 in //UE5/Release-5.0/... via CL 18789258 via CL 18789368
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v908-18788545)

[CL 18789821 by krzysztof narkowicz in ue5-main branch]
2022-01-31 10:23:36 -05:00
tiago costa
9b91e5347d Refactor remaining DF shaders to not use legacy shader parameter binding - Part 3
- Created FGlobalDistanceFieldParameters2 using SHADER_PARAMETER_STRUCT.
    - Can't remove existing struct since it's used by Niagara.
    - Added SetupGlobalDistanceFieldParameters helper function to perform the necessary logic.
- Converted FScreenGridParameters to use SHADER_PARAMETER_STRUCT.
    - Added SetupScreenGridParameters helper function to perform the necessary logic.
- Bind AO SampleDirections using SHADER_PARAMETER_STRUCT instead of GLOBAL_SHADER_PARAMETER_STRUCT + SetUniformBufferParameterImmediate.
- Removed all legacy shader parameters from FVisualizeMeshDistanceFieldCS, FConeTraceScreenGridObjectOcclusionCS, FConeTraceScreenGridGlobalOcclusionCS, FCombineConeVisibilityCS.
- Removed some unused variables

#rb daniel.wright
#preflight 61b34475ee0de9822e3b72b6

#ROBOMERGE-AUTHOR: tiago.costa
#ROBOMERGE-SOURCE: CL 18432863 in //UE5/Release-5.0/... via CL 18435419
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v897-18405271)

[CL 18435907 by tiago costa in ue5-release-engine-test branch]
2021-12-10 18:08:26 -05:00
tiago costa
679e68ba83 Remove deprecated DFGI and Heightfield GI
#preflight 61b28664c01c89f906c39eb8
#rb daniel.wright

#ROBOMERGE-AUTHOR: tiago.costa
#ROBOMERGE-SOURCE: CL 18426710 in //UE5/Release-5.0/... via CL 18426730
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v897-18405271)

[CL 18426734 by tiago costa in ue5-release-engine-test branch]
2021-12-09 18:23:24 -05:00
tiago costa
b1de4538c2 Refactor remaining DF shaders to use RDG - Part 1
- Convert FAOParameters to SHADER_PARAMETER_STRUCT.
- Added DistanceField::SetupAOShaderParameters helper function to perform the necessary logic.
- Removed all legacy shader parameters from FComputeDistanceFieldNormalPS, FComputeDistanceFieldNormalCS, FBuildTileConesCS, FObjectCullVS, FObjectCullPS
- Use FComputeShaderUtils::AddPass for the compute shaders listed above.

#preflight 61b0e21fb12ed60581b08372
#rb daniel.wright, sebastien.hillaire

#ROBOMERGE-AUTHOR: tiago.costa
#ROBOMERGE-SOURCE: CL 18417142 in //UE5/Release-5.0/... via CL 18417143
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v897-18405271)

[CL 18417145 by tiago costa in ue5-release-engine-test branch]
2021-12-09 04:49:36 -05:00
Marc Audy
0c3be2b6ad Merge Release-Engine-Staging to Test @ CL# 18240298
[CL 18241953 by Marc Audy in ue5-release-engine-test branch]
2021-11-18 14:37:34 -05:00
andrew davidson
57beb335f2 Merging //UE5/Dev-LargeWorldCoordinates [at] 17581892 to //UE5/Main
#ROBOMERGE-AUTHOR: andrew.davidson
#ROBOMERGE-SOURCE: CL 17595295 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v871-17566257)

[CL 17595306 by andrew davidson in ue5-release-engine-test branch]
2021-09-22 10:01:48 -04:00
zach bethel
7b8326ac7b Move ConeTraceGlobal pass to use the non-immediate command list.
[FYI] tiago.costa

#ROBOMERGE-SOURCE: CL 16963100 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v838-16927207)

[CL 16963193 by zach bethel in ue5-release-engine-test branch]
2021-07-26 20:01:54 -04:00
krzysztof narkowicz
bb54d82bdd Distance fields:
* Added r.DistanceFields.SupportEvenIfHardwareRayTracingSupported to allow to skip DF scene creation and DF streaming if HWRT is supported. Should be really a run-time switch, but it's something for later. By default set to 1 and everything works as before
* Added ShouldCompileDistanceFieldShaders to share shader compilation conditions between all DF shaders

#rb Patrick.Kelly
[FYI] Patrick.Kelly, Daniel.Wright, Tiago.Costa

#ROBOMERGE-SOURCE: CL 16825135 via CL 16825147
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v836-16769935)

[CL 16825153 by krzysztof narkowicz in ue5-release-engine-test branch]
2021-07-12 10:24:46 -04:00
tiago costa
3dc755958e Updated most of distance field ambient occlusion codepath to use RDG.
- Resource state transitions handled by RDG.
- FDistanceFieldObjectBufferResource replaced by FDistanceFieldCulledObjectBufferParameters to use RDG.
- FTileIntersectionResources replaced by FTileIntersectionParameters to use RDG.
- FAOScreenGridResources replaced by FAOScreenGridParameters to use RDG.
- Don't store DFAO resources in View.State.
- Split FDeferredShadingSceneRenderer::RenderDistanceFieldAOScreenGrid() into multiple passes.
- Split BuildTileObjectLists() into multiple passes.

#rb daniel.wright

#ROBOMERGE-SOURCE: CL 16660080 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v834-16658389)

[CL 16660083 by tiago costa in ue5-release-engine-test branch]
2021-06-14 12:46:26 -04:00
tiago costa
2b8a73fbb4 Convert a couple of template shader classes to use FPermutationDomain instead.
#rb daniel.wright

[CL 16437889 by tiago costa in ue5-main branch]
2021-05-24 14:08:15 -04:00
Andrew Davidson
3ddc3a4da3 Merge up from //UE5/Dev-LargeWorldCoordinates
#rb none

[CL 16211417 by Andrew Davidson in ue5-main branch]
2021-05-05 15:07:25 -04:00
Daniel Wright
697b5b9cf6 Sparse, narrow band, streamed Mesh Signed Distance Fields
* SDFs are now generated, allocated from the atlas and uploaded in 8^3 bricks (7^3 unique data, half voxel padding).
 * Tracing must load the brick index from the indirection table, and only bricks near the surface are stored
 * 3 mips are now generated, with the lowest resolution always loaded and the other 2 streamed
 * SDFs are now G8 narrow band.  Lower resolution mips must be traversed when querying distance to nearest surface far away from the surface
 * The Distance Field Brick Atlas is now stored for each FScene and dynamically resized based on needs with a GPU memcopy
 * Brick atlas uses a 1d pooled allocator which has no fragmentation and greatly reduces packing waste over the 3d allocator
 * Added new indirection for Distance Field Asset data, so that only a single entry needs to be updated when a mip is streamed in or out in scenes with millions of instances
 * Compute shaders operating on distance field instances generate streaming requests, which are async read back to CPU, turned into IO requests, which are polled and when complete uploaded to atlases
 * Any mesh instance inside the Global SDF extent (200m) requests mip1, and at 50m requests mip2
 * Now using a batched compute scatter to upload to the distance field atlas instead of RHIUpdateTexture3d, to bypass alignment restrictions and per-upload overhead
 * Distance Field streaming uses an async task to move Memcpy and IO request overhead off of the Rendering Thread
 * Distance Field Visualization now computes a normal from the SDF gradient and does simple lighting to better visualize the scene representation
 * Increased r.DistanceFields.MaxPerMeshResolution from 128 to 512, to better represent large objects
 * Mesh SDF generation now uses an Embree point query to calculate closest unsigned distance, and then a much smaller set of rays to count backfaces for negative region determination, for a 11x speedup
 * Upgraded mesh utilities to Embree 3.12.2 to get point queries
 * Fixed wrong transform used for SDF normals in Lumen, causing non-uniformly scaled meshes to have incorrect Surface Cache interpolation
 * Fixed Static Mesh materials not getting PostLoaded before SDF build, causing their blend modes to be wrong for the build, which corrupts the DDC.  Also included those blend modes in the DDC key.

Original costs on 1080 GTX (full updates on everything and no screen traces)
10.60ms   UpdateGlobalDistanceField
3.62ms   LumenReflectiveTest.DirectionalLight_1 Shadowmap 1
1.73ms   VoxelizeCards Clipmaps=[0,1,2,3]
0.38ms   TraceCards 1 dispatch 1 groups
0.51ms   TraceCards 1 dispatch 1 groups

Sparse SDF costs
12.06ms   UpdateGlobalDistanceField
4.35ms   LumenReflectiveTest.DirectionalLight_1 Shadowmap 1
2.30ms   VoxelizeCards Clipmaps=[0,1,2,3]
0.69ms   TraceCards 1 dispatch 1 groups
0.77ms   TraceCards 1 dispatch 1 groups

Tested: TopazEntry PC, Reverb PC and PS5, EngineTests, QAGame, Rift, Frosty P_Construct_WP, FortGPUTestbed

#rb Krzysztof.Narkowicz

#ROBOMERGE-OWNER: Daniel.Wright
#ROBOMERGE-AUTHOR: daniel.wright
#ROBOMERGE-SOURCE: CL 15784493 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v783-15756269)
#ROBOMERGE-CONFLICT from-shelf

[CL 15790658 by Daniel Wright in ue5-main branch]
2021-03-23 22:40:05 -04:00
zach bethel
1219c611c8 Removed FRDGTexture::GetPooledRenderTarget() usage and deprecated in prepration for transient allocator support.
#rb kenzo.terelst

[CL 15628262 by zach bethel in ue5-main branch]
2021-03-05 15:28:03 -04:00
zach bethel
7874505724 Removed untracked access from RDG and other conversion-related stuff.
#rnx
#rb none

[CL 15465786 by zach bethel in ue5-main branch]
2021-02-18 19:54:54 -04:00
Emil Persson
4516b985df Name all resources and make naming mandatory
#rb yuriy.odonnel, kenzo.terelst

[CL 15416919 by Emil Persson in ue5-main branch]
2021-02-16 08:37:39 -04:00
zach bethel
2ac0eca45e Removed unused scene render target singleton accesses.
#rb none
#rnx

[CL 14986799 by zach bethel in ue5-main branch]
2021-01-04 18:13:38 -04:00
zach bethel
ba31d9b2f5 Added FMinimalSceneTextures and FSceneTextures to deferred shading renderer and marshaled it through the render pipeline.
#rb christopher.waters
#rnx

[CL 14780920 by zach bethel in ue5-main branch]
2020-11-18 15:16:23 -04:00
Kenzo Terelst
fde71a76d9 Distance field rhi validation fixes for missing/wrong transitions
#jira none
#rb Mihnea.Balta, Jonas.Meyer

[CL 14691291 by Kenzo Terelst in ue5-main branch]
2020-11-09 12:52:29 -04:00
zach bethel
e4f467569d Removed scene render target context snapshot system.
#rb arne.schober

[CL 14615156 by zach bethel in ue5-main branch]
2020-10-29 16:32:16 -04:00
zach bethel
1be4df8f48 Removed deprecated resource transition API from the engine.
#rb kenzo.terelst, christopher.waters, mihnea.balta
#fyi will.damon, brian.white, rolando.caloca
#jira none

[CL 14495239 by zach bethel in ue5-main branch]
2020-10-14 14:20:26 -04:00
Marcus Wassmer
3b81cf8201 Merging using //UE5/Main_to_//UE5/Release-Engine-Staging @14384769
autoresolved files
#rb none

[CL 14384911 by Marcus Wassmer in ue5-main branch]
2020-09-24 00:43:27 -04:00
Marc Audy
11f5b21210 Merging //UE5/Release-Engine-Staging @ 13752110 to Main (//UE5/Main)
#rnx

[CL 13753156 by Marc Audy in ue5-main branch]
2020-06-23 18:40:00 -04:00