Commit Graph

82 Commits

Author SHA1 Message Date
krzysztof narkowicz
6428bcdcc6 DF PrimitiveModifiedBounds memory and performance optimizations. This helps a lot in large scenes which place lots of objects onto this list:
*Don't track modified bounds if they are outside of the interest range of Global Distance Field or Lumen
*Change FBox to FRenderBounds (4 bytes less per box)
*Try to keep PrimitiveModifiedBounds memory allocation based on the last frame's usage

#rb Daniel.Wright


#ROBOMERGE-SOURCE: CL 16697019
#ROBOMERGE-BOT: (v835-16672529)

[CL 16697029 by krzysztof narkowicz in ue5-main branch]
2021-06-16 17:47:44 -04:00
christopher waters
17e4707703 Adding CreateUploadBuffer helpers.
Adding FRDGUploadData to create upload data directly from the GraphBuilder persistent memory.

#jira none
#rb Zach.Bethel
#preflight 60c0de551264df00015e307a

[CL 16613071 by christopher waters in ue5-main branch]
2021-06-09 17:17:23 -04:00
krzysztof narkowicz
0a2378b25d Don't maintain more memory than DistanceField::MinPrimitiveModifiedBoundsAllocation inside PrimitiveModifiedBounds arrays
[FYI] Kenzo.Terelst

#ROBOMERGE-SOURCE: CL 16501564 in //UE5/Private-Frosty/...
#ROBOMERGE-BOT: STARSHIP (Private-Frosty -> Main) (v823-16466674)

[CL 16501593 by krzysztof narkowicz in ue5-main branch]
2021-05-28 11:26:14 -04:00
Daniel Wright
6c168e2bfe Increase default r.AOGlobalDistanceField.OccupancyRatio to .5 to fix artifacts in cave scenes, probably caused by Sparse Mesh SDF not having as large of a negative region (by design)
[CL 16340030 by Daniel Wright in ue5-main branch]
2021-05-14 23:41:16 -04:00
danny couture
9332b64809 Prepare for the deprecation of direct access to the Resource member of UTexture in favor of the GetResource() accessor.
#rb Francis.Hurteau
#preflight 609e5182ef86d30001ad0a18
#rnx

[CL 16328103 by danny couture in ue5-main branch]
2021-05-14 07:17:32 -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
Krzysztof Narkowicz
ba57fa8632 Fixed -d3ddebug warning when shader uses default (dummy) distance field parameters
[CL 16113530 by Krzysztof Narkowicz in ue5-main branch]
2021-04-26 09:17:50 -04:00
zach bethel
9fc8b1722d Refactored RDG ConvertToUntrackedX functionality into the RDG builder; renamed the operation to 'FinalizeAccess' for clarity, as the resource is considered finalized in the graph and will not transition to any other state. This operation now supports multiple resources, improving performance in cases where multiple resources are finalized back-to-back. Added validation to check that the user don't attempt to use it outside of its finalized state. Fixed up a few places where this assumption was being violated. Minor refactors in various places to use new API.
#rb arne.schober, christopher.waters
#jira none

[CL 15931331 by zach bethel in ue5-main branch]
2021-04-06 11:45:09 -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
Guillaume Abadie
498f9d02ea Replaces SHADER_PARAMETER_RDG_BUFFER() with RDG_BUFFER_ACCESS() in Lumen
#rb none
#fyi daniel.wright
#robomerge Release-5.0-EarlyAccess

[CL 15718979 by Guillaume Abadie in ue5-main branch]
2021-03-17 06:01:59 -04:00
Jeremy Moore
62a42f9d67 #jira UE-106501
Add nullptr check
This corresponds to CL15495515 in UE4 which won't automatically robomerge due to many changes in this file.
#rb trivial

[CL 15495650 by Jeremy Moore in ue5-main branch]
2021-02-22 19:07:21 -04:00
daniel wright
b47a37549a Added project settings to choose Dynamic Global Illumination Method and Reflection Method
* These map to r.DynamicGlobalIlluminationMethod and r.ReflectionMethod under the hood
* Removed r.ssgi.enable.  Projects with r.ssgi.enable=1 lose SSGI being enabled, because there�s no way to do backward compatibility on cvars.
* Removed r.LumenScene.  Lumen GI and Reflections are now enabled independently and Lumen Scene will be set up if either feature is enabled.

Setting �Dynamic Global Illumination Method� to Lumen in Project Settings automatically sets �Reflection Method� to Lumen and enables �Generate Mesh Distance Fields�, so you only have to change one setting to convert your project to Lumen.

Newly created projects have:
 * r.GenerateMeshDistanceFields=True.  Needed for Lumen Software tracing.  Note this means all new projects have Mesh Distance Field memory overhead by default.
 * r.DynamicGlobalIlluminationMethod=1 (Lumen)
 * r.ReflectionMethod=1 (Lumen)

Added GI method and Reflection method overrides to Post Process Volume, and new Final Gather Quality and Reflections Quality for Lumen.

Changed the default for r.DistanceFields.DefaultVoxelDensity from .1 to .2, for all projects.  This is needed for good software tracing quality with Lumen.

Lumen GI operates on all lights, regardless of Mobility.  Precomputed shadowing on Stationary lights are ignored, and Lumen will fall back to SDF tracing to solve shadowing for these.

When Lumen GI is enabled, lightmap lighting is discarded in the shader.  This breaks Static lights with lighting built, because their direct lighting is only stored in the lightmap.  A future change will be needed to render Static Lights when Lumen GI is enabled.

NeedsVelocityDepth will be true on any platform that supports Lumen or Ray Tracing.  Lumen needs Velocity Depth but doesn�t have a readonly cvar to use to modify shader compilation.


#ROBOMERGE-SOURCE: CL 15321505 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v771-15082668)

[CL 15321508 by daniel wright in ue5-main branch]
2021-02-04 15:30:42 -04:00
Andrew Davidson
10bca5261b Double math ambiguity Engine fixes
#rb jeanfrancois.dube, trivial

[CL 14974758 by Andrew Davidson in ue5-main branch]
2021-01-04 07:59:22 -04:00
Emil Persson
72db809300 Replace legacy LockVertexBuffer()/LockIndexBuffer()/LockStructuredBuffer() calls with the unified LockBuffer()
#rb kenzo.terelst

[CL 14898308 by Emil Persson in ue5-main branch]
2020-12-10 11:51:32 -04:00
zach bethel
056a26cddd Refactored uniform buffers to use static bindings as opposed to FPersistentUniformBuffers across the deferred renderer. This removes the view uniform buffer and reflection capture uniform buffers from mesh draw commands and reduces the use of RHIUpdateUniformBuffers.
- View / InstancedView uniform buffers are now bound through RDG directly from the FViewInfo, or created on-demand for cases like jitter-free custom depth.
 - Removed most of the custom persistent view uniform buffers. Left one in Lumen to be done in a later CL.
 - ReflectionCapture uniform buffer is now bound at the RDG pass level.

#rb christopher.waters

[CL 14873982 by zach bethel in ue5-main branch]
2020-12-07 17:43:21 -04:00
zach bethel
e8495060db Fixed deprecation warnings.
#rb none

[CL 14821612 by zach bethel in ue5-main branch]
2020-11-30 13:28:09 -04:00
Ola Olsson
69d2af54aa Refactored GPU-Scene to store per-view dynamic primitives (for all views) in the one and primitive data buffer, after the regular primitives.
- Added step after dynamic primitives are gathered to allocate a range in GPU scene for the dynamic primitives.
- Moved more GPU-Scene functionality to member functions to clean up references to internal data
- Removed the PrimitiveShaderDataBuffer/Texture from FSceneViewState
- Removed OneFramePrimitiveShaderDataBuffer/Texture from FViewInfo
- Encapsulated the collection of dynamic primitive data for upload to avoid uploading twice and prepare for parallel upload.

#rb Krzysztof.Narkowicz,graham.wihlidal

[CL 14785776 by Ola Olsson in ue5-main branch]
2020-11-19 05:23:44 -04:00
Kenzo Terelst
1a57367603 Make sure all external textures are transitioned back into ERHIAccess::SRVMask when done with distance field rendering
#rb Mihnea.Balta

[CL 14762632 by Kenzo Terelst in ue5-main branch]
2020-11-17 06:39:02 -04:00
Krzysztof Narkowicz
14d02c6809 MeshSDF - implemented a tight bounding box with one voxel margin for bilinear gradient reconstruction. This allowed the MESH_SDF_APPROX_MARGIN hack to be removed and secured all gradient reconstruction operations from reading outside of valid bounds. Also saved ~50% of SDF atlas space, and speed up some mesh SDF operations:
UpdateGlobalDistanceField: ~7% faster
TraceMeshSDFs: ~5% faster

#rb Daniel.Wright, Patrick.Kelly

[CL 14618591 by Krzysztof Narkowicz in ue5-main branch]
2020-10-29 23:43:01 -04:00
zach bethel
f3fb7ddab6 Moved RDG builder to top of Deferred Shading Render function. Ported hit proxy rendering to RDG.
#rb christopher.waters
#jira none

[CL 14589785 by zach bethel in ue5-main branch]
2020-10-27 13:40:36 -04:00
Krzysztof Narkowicz
3a849204a4 Replaced multiple Lumen voxelization algorithms with single. New approach is based on caching visibility and consists out of two phases:
1. Cache trace hit points per voxel into a visibility buffer {meshId;HitT}
  * All camera and object updates are cached and converted into a list of dirty bricks
  * Build list of {brickId; meshId} for dirty regions
  * Clear vis buffer for dirty regions
  * Trace mesh SDF rays per list element, and scatter results with atomic into the vis buffer
2. Shade cached visibility buffer every frame
  * Clear voxel lighting climap
  * Compact voxel lighting vis buffer per brick
  * Shade compacted bricks

Reverb, NV 1080, Clipmap 0 in cave (largest object density in Reverb):
Previous:
   * 1.06ms
New one:
   * Update cache for a 4 voxel scroll on diagonal - 0.18ms
   *  Reshade: 0.14ms

#rb Daniel.Wright

[CL 14514004 by Krzysztof Narkowicz in ue5-main branch]
2020-10-19 10:34:37 -04:00
Krzysztof Narkowicz
25a21949be Fixed global distance field visualization. Legacacy binding's don't support float3 array well.
#rb Daniel.Wright

[CL 14396182 by Krzysztof Narkowicz in ue5-main branch]
2020-09-25 10:57:10 -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
Krzysztof Narkowicz
121299f149 Cherrypick CL 14318800
Added single mip level to the global distance field clipmaps. Rebuild on any clipmap modification using Eikonal propagation and speeds up empty space skiping during tracing.

On 1080:
0.05ms to rebuild entire clipmap (mostly time spend in barriers between propagation passes)
FortGPUTestBed: ~17% faster tracing
Reverb Entrance: 3% faster tracing
Reverb Graveyard: ~27% faster tracing

#fyi Daniel.Wright
#rb none

[CL 14319372 by Krzysztof Narkowicz in ue5-main branch]
2020-09-15 11:03:59 -04:00
Krzysztof Narkowicz
cc9ff85f5a Fixed compilation error from an incorrect robomerge of CL 14313029
#rb none
#fyi Lukas.Hermanns

[CL 14315541 by Krzysztof Narkowicz in ue5-main branch]
2020-09-14 20:21:15 -04:00