Commit Graph

260 Commits

Author SHA1 Message Date
luke thatcher
984a0bba79 Fix RHI validation layer error in SkeletalRenderGPUSkin.cpp
- MorphVertexBuffer was not in UAV state before being cleared with RHIClearUAVUint.

Fix RDGImmediate not uploading buffers if no render passes were enqueued.
 - Also remove stray debug string compare / debug break

#rb Zach.Bethel
#jira MH-8828
#preflight 64023e2aa726961ed9d598fe

[CL 24507908 by luke thatcher in ue5-main branch]
2023-03-03 17:05:15 -05:00
zach bethel
7ef5721365 Fixed race condition with RDG setup tasks and buffer creation callbacks.
#preflight trivial

[CL 24428159 by zach bethel in ue5-main branch]
2023-02-27 13:47:56 -05:00
zach bethel
15d39e7bd3 Always dispatch RHI thread in RDG BeginFlushResourcesRHI. Avoids a CPU induced stall when flushing the RHI thread.
#preflight trivial

[CL 24292145 by zach bethel in ue5-main branch]
2023-02-17 17:02:47 -05:00
christopher waters
1f21b73b25 Ran IWYU on RHI and RenderCore, private only.
#preflight 63d358c85c69f453c1f79c37

[CL 23889591 by christopher waters in ue5-main branch]
2023-01-27 14:54:10 -05:00
zach bethel
5fc7d77efc Fix for memory leak in transient allocator due to RDG async compute producer -> graphics consumer fence where the consumer was culled. This caused the passes resources to not be traversed and EndResourcesRHI was not called, resulting in a leak of the underlying memory.
- Fixed incorrect accumulation of reference counts when RDG culling is disabled but parallel setup is enabled.
 - Added assert to catch bad referencing counting in the future, which will be easier to debug than a leak.

#preflight 63d063d5f2318350a2bd6071
#jira UE-173062

[CL 23841216 by zach bethel in ue5-main branch]
2023-01-24 18:24:36 -05:00
jason hoerner
38521eae14 Multi-GPU: strip out Alternate Frame Rendering (AFR). Michal Valient requested this for 5.2. AFR has heavily decayed in 5.0, not supporting Lumen, Nanite, VSMs. and likely other newer features, and it's impossible even in principle to get most of those features to ever work in a performant way, due to their temporal nature. Removing this lowers maintenance and support costs for MGPU going forward.
A lot of files touched, but generally it's a mechanical matter of removing the global variable GNumAlternateFrameRenderingGroups, and treating all code using it as if it's a fixed constant of one.  If a conditional becomes always false, the code block is removed.  Certain utility functions only called from dead stripped AFR code are then removed (e.g. RHIBroadcastTemporalEffect).  On the D3D11 side, RHIBeginUpdateMultiFrameResource / RHIEndUpdateMultiFrameResource become NOPs (return at the top of the function) when GNumAlternateFrameRenderingGroups is 1, so those are removed across the board.

#jira none
#rb jason.nadro
#preflight 63cea0afb91ac945f5117110

[CL 23820752 by jason hoerner in ue5-main branch]
2023-01-23 15:30:48 -05:00
jason hoerner
b7d1627e22 MGPU: Crash when moving camera on CitySample startup map. Crash was caused by FRHICommandListBase::SwitchPipeline calling ParameterBatcher.FlushAllParameters outside the SCOPED_GPU_MASK for the Pass, and thereby running on all GPUs as opposed to just the view's GPU. Fix is to make it so FRHICommandListScopedPipeline is inside the GPU mask scope.
#jira UE-173849
#rnx
#rb zach.bethel
#preflight 63c9eaed977c626356d0dc03

[CL 23785049 by jason hoerner in ue5-main branch]
2023-01-19 21:10:19 -05:00
wouter dek
b0bd284033 Add ConvertUniformBufferToExternal to allow RDG UBs to be used in non-RDG contexts (e.g. RT pipeline)
#rb zach.bethel, ola.olsson
#preflight 63c7d0372a6acaf162f8a691

[CL 23753417 by wouter dek in ue5-main branch]
2023-01-18 06:10:35 -05:00
zach bethel
5e756befaa Fixed RDG setup tasks to sync prior to launching buffer uploads.
#preflight trivial

[CL 23739283 by zach bethel in ue5-main branch]
2023-01-17 11:36:40 -05:00
Josie Yang
9726e5c9fb Add RHI resource owner name tracking to RDG buffers used by hair plugin.
#rb Charles.deRousiers, zach.bethel
#jira UE-167816
#preflight 63c1a0672e714f64ad28b52f

[CL 23736020 by Josie Yang in ue5-main branch]
2023-01-17 05:44:27 -05:00
zach bethel
b852db62b9 Added RHI resource lifetime scopes which defer deletion of unreferenced resources until all scopes are closed.
The RDG builder holds a scope in order to avoid deletion of any resources during the graph setup / execution. This resolves the need to hold a strong reference during the RDG graph lifetime.

If FlushPendingDeletes is called within one of these scopes, the resources are instead queued onto the immediate command list and flushed at the end of the scope.

This change removes strong references held of uniform buffers held by RHI commands and certain platform contexts. When a flush is encountered, the backends will clear all caches removing any potential dangling references.

Resources can opt out of lifetime extension by calling ->DisableLifetimeExtension(). Subsequent calls to FlushPendingDeletes will release the resource immediately. This is used by a couple edge cases where resources must be deleted mid-frame (namely, DumpGPU and BVH building).

#rb christopher.waters
#preflight 63c5e5722e714f64ad017cfd

[CL 23734079 by zach bethel in ue5-main branch]
2023-01-16 19:13:49 -05:00
Kenzo Terelst
d2f1a92b2f Fixes to make ray tracing dynamic geometry and TLAS builds on async compute again
#jira UE-168252
#rb Luke.Thatcher, Zach.Bethel
#preflight 635a782ed86d91ca2c3ca925
#rnx

[CL 23625138 by Kenzo Terelst in ue5-main branch]
2023-01-10 06:28:18 -05:00
danny couture
2c5090a518 Fix assert in IsInActualRenderingThread() by using an optional tag instead of replacing the renderthread one
#rnx
#rb Zach.Bethel
#preflight 63855306766a2aeed2c51ee5

[CL 23300853 by danny couture in ue5-main branch]
2022-11-28 19:51:10 -05:00
zach bethel
395c776305 Added CVar to RDG to control whether to use async destruction task.
[REVIEW] [at]mickael.gilabert, [at]john.huelin
#ushell-cherrypick of 23297379 by zach.bethel

#localization none
#tests manual

[CL 23300654 by zach bethel in ue5-main branch]
2022-11-28 19:30:42 -05:00
kenzo terelst
aa561403f4 Flush the ParallelPassCandidates set when changing the force bParallelTranslate flag
[REVIEW] [at]mihnea.balta, [at]luke.thatcher, [at]ben.woodhouse
#rb Luke.Thatcher

#localization none
#tests reprod and fixes issue and ran a few replays without any others issues. perf improvements are still there when nanite parallal translate is enabled again via cvar

[CL 23227981 by kenzo terelst in ue5-main branch]
2022-11-21 17:17:05 -05:00
luke thatcher
854e9e8e16 Manual merge of 23164565 to resolve robomerge conflict. Original CL desc:
Move nanite programmable raster command list build to parallel translate tasks to offload RHI thread on PC

[REVIEW] [at]yuriy.odonnell, [at]zach.bethel, [at]luke.thatcher, [at]mihnea.balta
#localization none
#tests ran local replay and compared perf with it on and off and saves around 3 to 4 msec on rhi thread

[CL 23227976 by luke thatcher in ue5-main branch]
2022-11-21 17:16:53 -05:00
zach bethel
df1568434e Optimized RDG async compute fence computation.
#preflight 636d34ef1c14fe4505fdfc0e
#jira none

#ushell-cherrypick of 23068227 by zach.bethel

[CL 23101437 by zach bethel in ue5-main branch]
2022-11-11 13:21:11 -05:00
zach bethel
c7762df3f0 Added counters for tracking RDG stats and CSV counters for passes / resources.
#preflight 636ab090ed07daaa9a25dba6
[FYI] ben.woodhouse

[CL 23049849 by zach bethel in ue5-main branch]
2022-11-09 04:11:18 -05:00
zach bethel
37fe71e0d1 Latency improvements to RDG.
- Moved dispatch busy-wait out of the command-list recording task. Allows the render thread to help with jobs once it's done.
 - Added workload to pass to help load balancing.

[CL 23025379 by zach bethel in ue5-main branch]
2022-11-08 04:25:52 -05:00
zach bethel
9ab5293097 Fixed bug in RDG dependency tracking with multi-pipe skip-barrier UAVs.
[FYI] jian.ru

[CL 23019459 by zach bethel in ue5-main branch]
2022-11-07 17:23:06 -05:00
zach bethel
7dd9de3f39 Refactored UpdateTexture2D, UpdateFromBufferTexture2D, and UpdateTexture3D to take a non-immediate command list.
- Added explicit SwitchPipeline calls to async command lists.
 - Moved pipeline push / pop calls from platform implementations to RHI command list.

#rb christopher.waters
#preflight 636937204d3c1d9d9264ce7b

[CL 23012810 by zach bethel in ue5-main branch]
2022-11-07 12:18:59 -05:00
zach bethel
3b9b0f2d52 Resubmit of 22872901.
Added RDG_EVENT_SCOPE_FINAL variant that silences child scopes / events.
 - Added r.RDG.Events CVar to control GPU event behavior.
      - 0 disables GPU events; 1 enables GPU events and FINAL scopes suppress child scopes; 2 enables all GPU events.

#preflight 63614e16397c7af896701cae

[CL 22917968 by zach bethel in ue5-main branch]
2022-11-02 11:46:28 -04:00
nat parkinson
442a36cfd4 [Backout] - CL22872901 as it seems to have caused compile errors
[FYI] zach.bethel
Original CL Desc
-----------------------------------------------------------------
Added RDG_EVENT_SCOPE_FINAL variant that silences child scopes / events.
 - Added r.RDG.Events CVar to control GPU event behavior.
      - 0 disables GPU events; 1 enables GPU events and FINAL scopes suppress child scopes; 2 enables all GPU events.

#preflight 6360117d117bb4ce9da40ef0
#rb krzysztof.narkowicz, yuriy.odonnell, daniel.wright

[CL 22879513 by nat parkinson in ue5-main branch]
2022-11-01 07:02:14 -04:00
zach bethel
738376cef5 Added RDG_EVENT_SCOPE_FINAL variant that silences child scopes / events.
- Added r.RDG.Events CVar to control GPU event behavior.
      - 0 disables GPU events; 1 enables GPU events and FINAL scopes suppress child scopes; 2 enables all GPU events.

#preflight 6360117d117bb4ce9da40ef0
#rb krzysztof.narkowicz, yuriy.odonnell, daniel.wright

[CL 22876153 by zach bethel in ue5-main branch]
2022-10-31 20:56:49 -04:00
jason hoerner
ee5373b706 Virtual Production: Optimizations to help with D3D12 CPU and GPU performance regressions following Parallel Rendering integration:
* Feature that merges command lists from QueueAsyncCommandListSubmit into a single Payload where possible (r.D3D12.AllowPayloadMerge, default enabled).  Saves around 0.5 ms per async command list batch, with total savings from 1 to 4 ms on VP test scenes.
* Remove unnecessary command flush before Present on D3D12.  Added a virtual function "NeedFlushBeforeEndDrawing" that can return false if the platform function RHIEndDrawingViewport function flushes commands, and the calling function doesn't need to.
* Wrapped three scene rendering flushes, plus BeginFlushResourcesRHI with "RHIIncludeOptionalFlushes()", which returns false on D3D12.  These were a net perf loss on D3D12, as they wrap hardly any rendering.  I didn't want to change behavior on other platforms, hence the conditional.
* Overall the above changes remove 8 command list flushes in a two view scene, which typically cost in the range of 0.06 ms each, saving 0.48 ms CPU total.  Perf win increases with more views, and removing the flushes also helps with GPU bubbles.
* Added a flush in a strategic location at the end of Shadows and Lumen.  In a sample scene, saved 1.5 ms GPU eliminating a bubble.

#jira UE-167553
#rb luke.thatcher
#rnx
#preflight 635547519e14ee3c790cc14e
#lockdown mihnea.balta

[CL 22728231 by jason hoerner in ue5-main branch]
2022-10-24 11:23:51 -04:00