- 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]
- Shaders sampling mesh distance fields must define OFFSET_DATA_STRUCT according to r.DFShadowOffsetDataStructure.
- Also renamed cvar r.DFShadowOffsetDataStructure to r.DistanceFields.OffsetDataStructure since it applies to all techniques sampling mesh distance fields.
#preflight 626661771a71643e8b8b07df
#rb Krzysztof.Narkowicz
#jira none
[CL 19900311 by tiago costa in ue5-main branch]
* 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]
* Distance Field streaming GPU mask scope clean up, to avoid startup crash. Added single high level FRHIGPUMask::All() scope in PrepareDistanceFieldScene, to avoid the need to set the mask in multiple lower level functions, and hopefully cover future modifications to the distance field scene code. View dependent subset of the code is then masked to the view. Validation asserts added in case code gets moved around in the future.
* Fixed bug when generating SRVs for structured buffers -- wasn't pointing the SRV to the correct GPU buffer. Caused GPU hangs and all sorts of corrupted rendering.
* Fixed bug that RHICopyToResolveTarget wasn't using the correct GPU index. Main symptom was DumpGPU being non-functional on the second GPU, but could cause other artifacts as well.
#jira none
#rnx
#rb christopher.waters chris.kulla
#preflight 624716e2b6084b9832597015
[CL 19591778 by jason hoerner in ue5-main branch]
Remove unused param from ComposeHeightfieldsIntoPagesCS.
Added const keyword to GetHeightfieldRepresentation(...)
Remove TexCreate_RenderTargetable flag from VisualizeDistanceField texture since it is only used as UAV.
#fyi daniel.wright
#preflight 6202bbbd121599bf437e90a7
[CL 18906762 by tiago costa in ue5-main branch]
* 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]
- Multiple branches that only checked for mesh SDFs needed to be updated.
- New permutation of AllocatePagesCS to skip mesh SDFs when none are in the scene.
- New permutations of ComposeHeightfieldsIntoPagesCS to support composing with None/Previous/Parent.
- Previous - compose with mesh SDF pages.
- Parent - compose with mostly static pages.
- Improvements to distance field visualization mode conditions.
#rb Krzysztof.Narkowicz, Patrick.Kelly
#preflight 61f7af8fe55232619f74490f
#ROBOMERGE-AUTHOR: tiago.costa
#ROBOMERGE-SOURCE: CL 18787631 in //UE5/Release-5.0/... via CL 18787637 via CL 18787659
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v903-18687472)
[CL 18787662 by tiago costa in ue5-main branch]
- 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]
- 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]
* 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]
- 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]
* 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]
Fixed a crash that can happen on exit.
Further reduced self shadow artifact when using RTHF shadow.
#ROBOMERGE-SOURCE: CL 11077247 via CL 11077248 via CL 11077250
#ROBOMERGE-BOT: (v637-11041722)
[CL 11077251 by jian ru in Main branch]
#rb Krzysztof.Narkowicz
[FYI] Ben.Woodhouse
#ROBOMERGE-SOURCE: CL 10996123 via CL 10996131 via CL 10996136
#ROBOMERGE-BOT: (v633-10983880)
[CL 10996139 by jian ru in Main branch]
#rnx
#rb none
#ROBOMERGE-OWNER: ryan.durand
#ROBOMERGE-AUTHOR: ryan.durand
#ROBOMERGE-SOURCE: CL 10869210 via CL 10869511 via CL 10869900
#ROBOMERGE-BOT: (v613-10869866)
[CL 10870549 by ryan durand in Main branch]