Commit Graph

41 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
tiago costa
d3e0196bd2 Fix error compiling shaders sampling distance fields when using non-default Distance Field Offset Data Structure
- 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]
2022-04-25 07:32:32 -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
078ea856d8 UE5_MAIN: Multi-GPU crash, corruption, and DumpGPU fixes.
* 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]
2022-04-01 13:44:07 -04:00
daniel wright
850ca59672 Global Distance Field Visualization only uses coverage atlas when Lumen is enabled
#preflight skip
#jira UE-144438
#rb Krzysztof.Narkowicz
#lockdown Juan.Canada

#ROBOMERGE-AUTHOR: daniel.wright
#ROBOMERGE-SOURCE: CL 19226213 in //UE5/Release-5.0/... via CL 19228047
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v921-19075845)

[CL 19231310 by daniel wright in ue5-main branch]
2022-03-02 17:24:09 -05:00
krzysztof narkowicz
7512b0a34d Global Distance Field - fixed crash when enabling global distance field visualization, but global distance field isn't used
#jira UE-144145
#rb Daniel.Wright
#lockdown Juan.Canada
#preflight 621e2018302e468cc58b7057

#ROBOMERGE-AUTHOR: krzysztof.narkowicz
#ROBOMERGE-SOURCE: CL 19197354 in //UE5/Release-5.0/... via CL 19197571
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v921-19075845)

[CL 19213007 by krzysztof narkowicz in ue5-main branch]
2022-03-01 20:01:22 -05:00
tiago costa
52b54ca696 Remove unused data from HeightfieldDescriptions buffer.
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]
2022-02-08 14:04:52 -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
3e6539db68 Fix GlobalDistanceField not getting correctly updated when scene only contains heightfields.
- 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]
2022-01-31 04:59:02 -05:00
zach bethel
a618c04cbf Converted light grid injection resources to RDG.
#preflight 61ddebe6ce7fe7aeff6fb109

#ROBOMERGE-AUTHOR: zach.bethel
#ROBOMERGE-SOURCE: CL 18576538 in //UE5/Release-5.0/... via CL 18576549
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v899-18417669)

[CL 18576556 by zach bethel in ue5-release-engine-test branch]
2022-01-11 15:57:18 -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
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
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
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
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
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
rolando caloca
d7fc07f4ea UE4.25 - Deprecate UnbindRenderTargets
#rb none
#lockdown Marcus.Wassmer
#jira UE-91584

#ROBOMERGE-OWNER: rolando.caloca
#ROBOMERGE-AUTHOR: rolando.caloca
#ROBOMERGE-SOURCE: CL 12632871 in //UE4/Release-4.25/... via CL 12632899 via CL 12633229
#ROBOMERGE-BOT: RELEASE (Release-Engine-Staging -> Main) (v675-12543919)

[CL 12633251 by rolando caloca in Main branch]
2020-04-06 16:28:53 -04:00
Josh Adams
aa9705149b Copying Private-LoadTimes-4.24 stream to Main. Biggest changes are in Materials/Shader memory freezing.
#rb none

[CL 11282608 by Josh Adams in Main branch]
2020-02-06 13:13:41 -05:00
jian ru
97a524b0cd RTHF shadow - added support that allows light cast inside terrains through holes. Due to its cost, it is only enabled in the highest quality level. Currently, boundaries are jaggy for shadows cast through holes. Users need to hide the aritifact with DF shadow by placing static meshes around holes.
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]
2020-01-21 16:48:23 -05:00
jian ru
983aa0af59 Extend distance field shadowing to also handle heightfields. This is another approach to shadow terrains. Compared to far shadow cascades, it showed lower RT and GPU overhead during internal testing.
#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]
2020-01-15 14:47:38 -05:00
ryan durand
0f0464a30e Updating copyright for Engine Runtime.
#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]
2019-12-26 14:45:42 -05:00
Rolando Caloca
f83ae4807a Copying //UE4/Dev-Rendering@9317594 to Dev-RenderPlat-Staging
#rb none
#rnx

[CL 9317904 by Rolando Caloca in Dev-RenderPlat-Staging branch]
2019-10-01 13:03:04 -04:00