Commit Graph

215 Commits

Author SHA1 Message Date
Guillaume Abadie
0734868f53 Implements DynamicRenderScaling API with GPU timing measurement integrated within RDG
This allows to define a new dynamic scaling in the renderer with low amount of boiler plate:

DynamicRenderScaling::FHeuristicSettings GetDynamicTranslucencyResolutionSettings()
{
	RenderingDynamicScaling::FHeuristicSettings BucketSetting;
	BucketSetting.Model = RenderingDynamicScaling::EHeuristicModel::Quadratic;
	BucketSetting.bModelScalesWithPrimaryScreenPercentage = true;
	BucketSetting.MinResolutionFraction = ...
	...
	return BucketSetting;
}

DynamicRenderScaling::FBudget GDynamicTranslucencyResolution(TEXT("DynamicTranslucencyResolution"), &GetDynamicTranslucencyResolutionSettings);


And then simply define a scope to measure the GPU timing as such:

{
	DynamicRenderScaling::FRDGScope DynamicTranslucencyResolutionScope(GraphBuilder, GDynamicTranslucencyResolution);

	// add passes to GraphBuilder
}

#rb zach.bethel
#jira UE-152561
#preflight 628f1219bb14235aa38c904c

[CL 20376428 by Guillaume Abadie in ue5-main branch]
2022-05-26 01:58:36 -04:00
zach bethel
b480e5be5e Fixed crash in RDG due to transient extracted texture.
#jira UE-152668
#preflight trivial

[CL 20262222 by zach bethel in ue5-main branch]
2022-05-18 12:12:48 -04:00
zach bethel
8a1a598d53 Fixed static analysis error and added more assert information to catch regression.
#preflight trivial
#jira UE-152693

[CL 20247062 by zach bethel in ue5-main branch]
2022-05-17 13:54:01 -04:00
zach bethel
fdc795f5b9 Implemented support for fused CopySrc | CopyDest transitions for Vulkan in RDG.
- Simplified RDG transition logic to only use subresource transitions.
 - Don't allow unmergeable states to be merged during pass setup.

#preflight 627ebfadca3b90fc14fb9b85
#fyi jeannoe.morissette

[CL 20224647 by zach bethel in ue5-main branch]
2022-05-16 11:02:52 -04:00
zach bethel
e37a08177c Submit async compute work prior to a fence from graphics -> async compute so that prior work isn't grouped with the submission to work around an issue in D3D12, which currently brute forces a fence from graphics to async compute any time graphics work is submitted.
#preflight 627c359a9f7ad2a14b8388d0
#fyi sebastien.hillaire

[CL 20152556 by zach bethel in ue5-main branch]
2022-05-11 18:40:35 -04:00
zach bethel
1a6dbc061d Deprecated FRDGBufferDesc::EUnderlyingType
#preflight 62756de8d8373707f22a6144
#rb christopher.waters

[CL 20082899 by zach bethel in ue5-main branch]
2022-05-06 15:44:23 -04:00
jeannoe morissette
94b6b81129 VulkanRHI: Add possibility to force depth and stencil to always be treated together when considering transitions in RDG since underlying VulkanRHI cannot track them separately:
- when CopySrc or CopyDest is set on either depth or stencil, force the range to include the entire texture.
- force the transitions of both depth and stencil to occur on the same pass (do not split the copy transition into two different passes if StateBefore is not the same).

#rb zach.bethel
#jira UE-143575,UE-147932
#preflight 6272c703365de864c4be9312

[CL 20050377 by jeannoe morissette in ue5-main branch]
2022-05-04 17:36:33 -04:00
zach bethel
224cc4fe24 Fix for RHI validation error in AncientGame.
#preflight none

[CL 20045330 by zach bethel in ue5-main branch]
2022-05-04 14:20:45 -04:00
zach bethel
ac11396729 Fixed test and validation regressions due to RDG changes.
#preflight 6272a1f12f6d177be3c60a53
#jira UE-150908

[CL 20043535 by zach bethel in ue5-main branch]
2022-05-04 12:41:19 -04:00
zach bethel
4eedc02f37 Fixes to external access RDG feature to handle async compute without validation failures.
#preflight 6270551191629533ec2b4bc9

[CL 20017395 by zach bethel in ue5-main branch]
2022-05-02 18:31:37 -04:00
zach bethel
10131e1285 Refactored RDG in preparation for UnifiedBuffer conversions.
- Refactord 'Finalized Access' feature into a more flexible 'External' vs. 'Internal' access mode per resource toggle.
      - Resources can transition between modes multiple times within the graph.
      - Supports async compute pipeline.
      - Supports queueing of requests to avoid back-to-back helper passes.
      - This feature is needed to support conversion of GPU scene buffers.

 - Deprecated the ReadOnly and ForceTracking resource flags and added a 'SkipTracking' flag instead.
      - Previous semantics were confusing and error prone.
      - New model requires a manual flag to tell RDG never to transition a resource.
      - This flag is used for read-only dummy resources as an optimization.

 - Renamed some of the auxiliary 'FinalizedResource' utilities since the name no longer matches the semantics.

#preflight 6266cc6d0634d0904ce4ba46

[CL 19904734 by zach bethel in ue5-main branch]
2022-04-25 13:00:12 -04:00
zach bethel
3864629f00 Minor RDG improvements in preparation for UnifiedBuffer conversion.
- Added resource pool counters and events.
 - Added AllocatePooledBuffer method and refactored pool to no longer take a command list.
 - Refactored swap chain barrier logic to be a bit cleaner.
 - Added helper methods to cast between views.
 - Added power of two alignment option to buffer pool.
 - Added GetTypeHash implementations for RDG SRV | UAV descriptors.

#preflight 62631046006fa20b683d130f

[CL 19873407 by zach bethel in ue5-main branch]
2022-04-22 17:11:57 -04:00
zach bethel
49a06cd724 Fixed crash due to invalid extracted transient render target allocation lifetime.
#jira UE-148034
#preflight trivial

[CL 19627706 by zach bethel in ue5-main branch]
2022-04-05 13:14:19 -04:00
zach bethel
b2399555b2 Fix for crash in RDG due to bad aliasing transition.
#jira UE-147406
#preflight trivial

#ROBOMERGE-AUTHOR: zach.bethel
#ROBOMERGE-SOURCE: CL 19589458 via CL 19589500 via CL 19589523
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v938-19570697)

[CL 19590972 by zach bethel in ue5-main branch]
2022-04-01 13:05:11 -04:00
zach bethel
f457a69101 Added RHI tracked access API to remove Unknown transitions.
- New RHI command list SetTrackedAccess method for the user to supply a current whole-resource state.
 - New RHI command context GetTrackedAccess method for querying the tracked access in RHIBeginTransitions / RHIEndTransitions on the RHI thread.
 - Hooked RHICmdList.Transition and FRHICommandListExecutor::Transition to assign tracked state automatically.
 - Refactored RDG and resource pools to use new RHI tracking.
      - FRDGPooledBuffer / FRDGPooledTexture no longer contain tracked state. RDG temp-allocates state through the graph allocator instead.
      - All prologue transitions are 'Unknown', and all epilogue transitions coalesce into a whole resource state.
 - Implemented platform support for patching the 'before' state with the tracked state.
 - Implemented various RHI validation checks:
      - Asserts that the user assigned tracked state matches RHI validation tracked state, for all subresources.
      - Asserts that tracked state is not assigned or queried from a parallel translation context.
 - Added FRHIViewableResource and FRHIView base classes to RHI. FRHIView contains a pointer to an FRHIViewableResource. This is currently a raw pointer, but should be extended to a full reference in a later CL.

NOTE on RHI thread constraint:

Transition evaluation is now restricted to the RHI thread (i.e. no parallel translation contexts). Transitions aren't performed in parallel translate contexts anyway, so this is not a problem. If, however, we decide to refactor parallel translation to be more general, this implementation could be extended to track the state per context and update from the 'dispatch' thread.

#preflight 6233b4396666d7e753a16aaf
#rb kenzo.terelst

[CL 19513316 by zach bethel in ue5-main branch]
2022-03-25 11:19:10 -04:00
aleksander netzel
9a8aa76713 Add ERDGPassFlags::NeverParallel to allow RDG passes to stay on render thread.
Both Immediate/AsyncCompute passes are always executed in order on the render thread but other RDG passes can run in parallel.
With my previous change, RayTracingScene pass was changed to Compute/AsyncCompute to have the correct order on the GPU.
But when it was set to Compute (when AsyncCompute was disabled) it was running in parallel with passes it depends on which led to random crashes.
Because the dependency between passes was implicit, we needed a new flag to express the intent and get the desired order between execution lambdas.

On behalf of Zach Bethel.

#rb zach.bethel
#jira UE-141003
#preflight 61fb0d9e923ac18db7015160
#lockdown michal.valient

#ROBOMERGE-AUTHOR: aleksander.netzel
#ROBOMERGE-SOURCE: CL 18841970 in //UE5/Release-5.0/... via CL 18841984 via CL 18842341
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042)

[CL 18842374 by aleksander netzel in ue5-main branch]
2022-02-03 09:15:49 -05:00
zach bethel
9996233f7a Removed unused legacy MSAA multi-texture support from IPooledRenderTarget.
- Deprecated legacy members from FPooledRenderTargetDesc.
 - Deprecated ETextureRenderTarget and removed from RDG.
 - TargetableTexture always equals ShaderResourceTexture.
 - Simplified render target pool FindFreeElement.
 - Create pooled buffers and textures with a known state.

#rb graham.wihlidal
#preflight 61f8488568795b2f45852274

#ROBOMERGE-AUTHOR: zach.bethel
#ROBOMERGE-SOURCE: CL 18796880 in //UE5/Release-5.0/... via CL 18797840 via CL 18799070
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v908-18788545)

[CL 18799188 by zach bethel in ue5-main branch]
2022-01-31 17:22:31 -05:00
zach bethel
2230e96167 Removal of RDG drain experiment for UE5 release. It is currently unused and hasn't proven itself necessary yet. It would be relatively straightforward to re-add if the need arises in the future.
#rb mihnea.balta
#preflight 61f82d9b3e13556eb9c3eb34

#ROBOMERGE-AUTHOR: zach.bethel
#ROBOMERGE-SOURCE: CL 18794948 in //UE5/Release-5.0/... via CL 18795422 via CL 18796381
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v908-18788545)

[CL 18796735 by zach bethel in ue5-main branch]
2022-01-31 15:55:31 -05:00
zach bethel
25f20493c4 Backing out changes to remove unknown states in pooled resources. Unported code is still transitioning pooled resources while not updating the tracked state. This will result in incorrect before states.
#rb none
#preflight 61f1920ef8088a3d298fb3a9

#ROBOMERGE-AUTHOR: zach.bethel
#ROBOMERGE-SOURCE: CL 18740193 in //UE5/Release-5.0/... via CL 18740756 via CL 18741541
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v903-18687472)

[CL 18742250 by zach bethel in ue5-main branch]
2022-01-26 15:04:14 -05:00
zach bethel
516e26c7e3 Fix for assert when async compute pass creates a transient resource. The resource lifetime was being properly extended to the graphics fork pass, but the graphics fork pass was also within a merged render pass, and the resource lifetime was not properly extended to the start of the render pass. This is important because resource transitions cannot occur within a render pass. This fix adjusts async compute resource lifetimes to begin and end on render pass boundaries of the fork / join graphics pass.
#jira UE-139261
#rb ben.woodhouse
#preflight none

#ROBOMERGE-OWNER: zach.bethel
#ROBOMERGE-AUTHOR: zach.bethel
#ROBOMERGE-SOURCE: CL 18678963 via CL 18678972 via CL 18680925 via CL 18681076 via CL 18681103
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v902-18672795)

[CL 18681506 by zach bethel in ue5-main branch]
2022-01-20 16:30:26 -05:00
zach bethel
14085dec09 RDG now reuses tracked state for external pooled textures and buffers. Added a variant of RegisterExternal{Texture, Buffer} that allows the user to specify the actual state if transitioned outside of RDG.
#preflight 61e84c67276892ce107685a0
#rb kenzo.terelst

#ROBOMERGE-AUTHOR: zach.bethel
#ROBOMERGE-SOURCE: CL 18662047 in //UE5/Release-5.0/... via CL 18662058 via CL 18662082
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v900-18638592)

[CL 18662103 by zach bethel in ue5-main branch]
2022-01-19 14:08:44 -05:00
zach bethel
2f790c0cc8 Removed r.RenderTargetPool.Events visualizer. It has been replaced by RDG insights.
#rb none
#preflight 61e6f8bb837b79f7cced82ee

#ROBOMERGE-AUTHOR: zach.bethel
#ROBOMERGE-SOURCE: CL 18642485 in //UE5/Release-5.0/... via CL 18644124 via CL 18644421
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v900-18638592)

[CL 18644664 by zach bethel in ue5-main branch]
2022-01-18 14:18:07 -05:00
jonathan bard
79f32ed47c Misc render-related changes:
* Added single-callback version of CreateStructuredBuffer to automatically infer element size, total size, element count and data pointer (e.g. CreateStructuredBuffer(GraphBuilder, TEXT("MyBuffer"), [&]() -> auto& { return BufferSource; });, where BufferSource is a TArray)
* Added support for uint2 shader parameters
* Added ForceTracking flag to ERDGBufferFlags/ERDGTextureFlags : force the RDG to track a resource even if it can be considered as readonly (no UAV, no RTV, etc.) This allows the graph to copy from and to external textures, and handling the corresponding transitions, for example.

#rb zach.bethel, sebastien.lussier
#tests editor
#preflight 61d8bc681f62d3ad4d728095

#ROBOMERGE-OWNER: jonathan.bard
#ROBOMERGE-AUTHOR: jonathan.bard
#ROBOMERGE-SOURCE: CL 18595021 via CL 18595031 via CL 18595035 via CL 18595668 via CL 18595682 via CL 18595700
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Test -> Main) (v899-18417669)

[CL 18596726 by jonathan bard in ue5-main branch]
2022-01-13 10:11:22 -05:00
zach bethel
26caf068be Fixed flashing artifact with transient allocator due to incorrect barrier placement. Fixed FastVRAM path in RDG to actually check if FastVRAM is supported.
#rb none
#preflight trivial

#ROBOMERGE-AUTHOR: zach.bethel
#ROBOMERGE-SOURCE: CL 18592457 in //UE5/Release-5.0/... via CL 18592471 via CL 18592497
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Test -> Main) (v899-18417669)

[CL 18592511 by zach bethel in ue5-main branch]
2022-01-12 19:38:45 -05:00
zach bethel
3b9e24d8b2 Replaced legacy XB1 transient page allocator with RDG page table mapped transient allocator. Added support for ESRAM page pool.
#rb ben.woodhouse
#preflight 61df2577ff67b6fe7ac00eae

#ROBOMERGE-AUTHOR: zach.bethel
#ROBOMERGE-SOURCE: CL 18587728 in //UE5/Release-5.0/... via CL 18587798 via CL 18587831
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Test -> Main) (v899-18417669)

[CL 18587909 by zach bethel in ue5-main branch]
2022-01-12 14:29:07 -05:00