Commit Graph

14 Commits

Author SHA1 Message Date
zach bethel
aeede49417 Fix for distance field streaming pass / task filtering.
#fyi daniel.wright, krzysztof.narkowicz

[CL 16326162 by zach bethel in ue5-main branch]
2021-05-13 23:32:58 -04:00
zach bethel
92c4904a02 Don't create a distance field streaming and pass task if no streaming is requested.
#fyi krzysztof.narkowicz

[CL 16322722 by zach bethel in ue5-main branch]
2021-05-13 20:16:44 -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
75958e0f48 Optimized distance field streaming requests by skipping a bunch of memory reads and atomics
0.69ms -> 0.12ms of GPU time on 2080, flying with drone

#rb Daniel.Wright, Graham.Wihlidal
#lockdown Graham.Wihlidal
#jira UETOP-1088

#ROBOMERGE-SOURCE: CL 16093708 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v789-15992632)

[CL 16093910 by krzysztof narkowicz in ue5-main branch]
2021-04-22 11:44:49 -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
mihnea balta
8cfbeb2596 Fixed: UpdateDistanceFieldAtlas was assuming that the maximum dispatch group size was the same in all dimensions.
This isn't true in Vulkan, so we need to use the correct dimension for the variable group size (Z, in this case).

#rb trivial
#jira none
#rnx

[CL 15914477 by mihnea balta in ue5-main branch]
2021-04-05 07:35:30 -04:00
mihnea balta
efade690cd Fixed infinite loop on Vulkan due to integer overflow.
Vulkan actually queries the device for GRHIMaxDispatchThreadGroupsPerDimension instead of hardcoding 0xffff, so the value it gets can be as large as MAX_int32, which will overflow when multiplied.

#rb trivial
#jira none
#rnx

#ROBOMERGE-SOURCE: CL 15900910 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v786-15839533)

[CL 15900916 by mihnea balta in ue5-main branch]
2021-04-02 10:01:03 -04:00
daniel wright
dc3f9b25cc Manually transition DistanceFieldBrickVolumeTexture to final state, fixes RHI validation errors
#ROBOMERGE-SOURCE: CL 15879969 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v786-15839533)

[CL 15879974 by daniel wright in ue5-main branch]
2021-03-31 15:24:40 -04:00
daniel wright
f13f203645 Workaround for zero size BulkData on Distance Field streaming requests
#ROBOMERGE-SOURCE: CL 15877580 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v786-15839533)

[CL 15877605 by daniel wright in ue5-main branch]
2021-03-31 13:02:11 -04:00
Daniel Wright
204bde33fb Fixed Distance Field streaming attempting to upload a completed Read Request when a different asset has been allocated at the same index since the Read Request was kicked off
Fixes crash going into PIE in Frosty -d3d12

[CL 15871066 by Daniel Wright in ue5-main branch]
2021-03-30 23:07:13 -04:00
daniel wright
b339145bac Fixed Distance Field Streaming on cooked windows
Tested TopazEntry PIE and cooked win64

#ROBOMERGE-SOURCE: CL 15865752 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v786-15839533)

[CL 15865757 by daniel wright in ue5-main branch]
2021-03-30 14:38:12 -04:00
daniel wright
acb3ddfb8d Speculative fix for crash streaming distance fields
#ROBOMERGE-SOURCE: CL 15828044 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v785-15821902)

[CL 15834007 by daniel wright in ue5-main branch]
2021-03-25 18:24:28 -04:00
Daniel Wright
287a6598c2 Fixed crash with meshes that have zero SDF bricks
[CL 15806944 by Daniel Wright in ue5-main branch]
2021-03-24 16:00:54 -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