Commit Graph

356 Commits

Author SHA1 Message Date
Luke Thatcher
10cdd4a111 Merging //UE5/Dev-ParallelRendering/... (up to CL 30965645) to //UE5/Main/... (base CL 30962637)
Significant refactor of RHI command list management and submission, and RHI breadcrumbs / RenderGraph (RDG) scopes, to allow for parallel translation of most RHI command lists.
See individual changelists in //UE5/Dev-ParallelRendering for details. A summary of the changes is as follows:

This work's primary goal was to allow as many RHI command lists as possible to be parallel translated, to make more efficient use of many-core systems. To achieve this:
 - The submission code paths for the immediate and parallel RHI command lists have been merged into a single function: FRHICommandListExecutor::Submit().
 - A "dispatch thread" (which is simply a series of chained task graph tasks) is used to decide which command lists are batched together in a single parallel translate job.
 - Individual command lists can disable parallel translate, which forces them to be executed on the RHI thread. This happens automatically if an RHI command list performs an operation that is not thread safe (e.g. buffer lock, or low-level resource transition).

One of the primary blockers for parallel translation was the RHI breadcrumb system, and the way RDG builds scopes. This was also refactored to remove these limitations:
 - RDG could only push/pop events on the immediate command list, which resulted in parallel and immediate work being interleaved, breaking any opportunity for parallelism.
 - Platform RHI implementations of breadcrumbs (e.g. in D3D12 RHI) was not correct across multiple RHI contexts. Push/pop operations aren't necessarily balanced within any one RHI context given that RDG builds "parallel pass sets" containing arbitrary ranges of renderer passes.

A summary of the new RHI breadcrumb system is as follows:
 - A tree of breadcrumb nodes is built by the render thread and RDG. Each node contains the node name, and pointers to the parent and next nodes. When fully built, the nodes form a depth-first linked list which is used for traversing the tree for GPU crash debugging.
 - The memory for breadcrumb nodes is provided by ref-counted allocator objects. These allocators are pipelined through the RHI, allowing the platform RHI implementation to extend their lifetime for GPU crash debugging purposes.
 - RHIPushEvent / RHIPopEvent have been removed, replaced with RHIBeginBreadcrumbGPU / RHIEndBreadcrumbGPU. Platform RHIs implement these functions to perform GPU immediate writes using the unique ID of each node, for tracking GPU progress.
 - Format string arguments are captured by-value to remove the cost of string formatting while building the breadcrumb tree. String formatting only occurs when the actual formatted string is required (e.g. during GPU crash breadcrumb stack traversal, or when calling platform GPU profiling APIs).

RenderGraph scopes have been simplified:
 - The separate scope trees / arrays of ops have been combined. There is now a single tree of RDG scopes containing all types.
 - Each RDG pass holds a pointer to the scope it was created under.
 - BeginCPU / EndCPU is called on each RDG scope as the various RDG threads enter / exit them. This allows us to mark-up each worker thread with the relevant Unreal Insights scopes.

Other changes include:
 - Fixes for bugs uncovered when parallel translate was enabled.
 - Adjusted platform affinities necessary due to the new layout of thread tasks in the renderer.
 - Refactored RHI draw call stats to better fit the new pipeline design.

#rb jeannoe.morissette, zach.bethel
#jira UE-139543

[CL 30973133 by Luke Thatcher in ue5-main branch]
2024-01-29 12:47:28 -05:00
jian ru
04c159beb8 New material HLSL translator fixes:
- Material property output activeness is now deferred. Previously, it was checked during tree generation. It needs to be deferred because the tree is shared between a base material and its instances. An inactive property in base can be active in an instance.
- For FExpressionSetStructField, do not generate a previous frame field expression if the field isn't requested.
- Implemented GenerateHLSLExpression for UMaterialExpressionVolumetricCloudEmptySpaceSkippingInput and UMaterialExpressionVolumetricCloudEmptySpaceSkippingOutput.
- Fallback to preview values (if allowed) for material function inputs connected to invalid reroute nodes.
- FExpressionTextureSample now falls back to hardware derivatives if analytic derivatives fail to prepare.
- Added virtual function GetPreviewExpression to FExpression. Some expressions don't have numeric values and cannot be previewed directly. Those expressions should override this virtual function to return numeric preview expressions that represent their preview values. Also implemented the virtual function for FExpressionParameter.
- Added SeenStaticParameterValues to FEmitContext. For some reasons, users can create static parameter nodes with the same name but different default values. Use the first default value seen to keep things consistent.
- FMaterialResource::HasVertexPositionOffsetConnected() now queries cached expression data instead of the base material because the answer can change in instances.

#rb tom.holmes
[FYI] tom.holmes, jason.nadro, danny.kabrane, massimo.tristano

[CL 30770932 by jian ru in ue5-main branch]
2024-01-22 09:29:18 -05:00
dmytro ivanov
8287cf4cdb Option to force always compiling materials for mobile in material editor
#rb Jack.Porter

[CL 30660119 by dmytro ivanov in ue5-main branch]
2024-01-17 11:31:40 -05:00
tim doerries
e5e124fe10 Implemented the same material graph node context menu actions for SparseVolumeTexture nodes as for regular Texture nodes. This now allows to convert between Sample, Object and Parameter nodes exactly the same as with regular textures. Also fixed the graph node title bar color being different to regular texture nodes.
#rb Patrick.Kelly
#jira UE-203979
#rnx

[CL 30632415 by tim doerries in ue5-main branch]
2024-01-16 09:24:04 -05:00
brian chrisman
e808cc720f Fix audio clock source dialog not suppressing when user selects 'no' when dismissing dialog.
#rb brooke.hubert, Max.Chen

[CL 30418742 by brian chrisman in ue5-main branch]
2023-12-20 14:39:46 -05:00
massimo tristano
724400d3d9 Material Editor - Made material translation DDC query async to material translation (running at the same time), so that the process that completes first will be used instead of doing them both serially.
#rb dan.elksnitis, rob.krajcarski
#jira UE-193797

[CL 30178621 by massimo tristano in ue5-main branch]
2023-12-07 09:23:09 -05:00
massimo tristano
b62e5dc336 [Backout] - CL30112943
[FYI] massimo.tristano
Original CL Desc
-----------------------------------------------------------------
Material Editor - Made material translation DDC query async to material translation (running at the same time), so that the process that completes first will be used instead of doing them both serially.

#rb dan.elksnitis
#jira UE-193797

[CL 30121479 by massimo tristano in ue5-main branch]
2023-12-05 11:54:35 -05:00
massimo tristano
63e6b14b6c Material Editor - Made material translation DDC query async to material translation (running at the same time), so that the process that completes first will be used instead of doing them both serially.
#rb dan.elksnitis
#jira UE-193797

[CL 30113016 by massimo tristano in ue5-main branch]
2023-12-05 07:24:32 -05:00
jason hoerner
14b74f7fa9 Material Editor: Added statistics for preshaders, and dumping of preshader expressions and parameter fetches in human readable form to the HLSL source. Similar statistics had been implemented in debug code to optimize a worst case shader, but now they are user facing to allow anyone to do similar content optimizations.
#jira UE-198495
#rb massimo.tristano

[CL 29857899 by jason hoerner in ue5-main branch]
2023-11-20 20:34:05 -05:00
marc audy
59f0feb3e4 Fix warning V595: The pointer was utilized before it was verified against nullptr.
#rnx

[CL 29459035 by marc audy in ue5-main branch]
2023-11-04 01:30:32 -04:00
sameer mirza
2d63804d3f Material Root node inline control updates
#jira UE-160029
#rb massimo.tristano

[CL 28924679 by sameer mirza in ue5-main branch]
2023-10-19 13:19:25 -04:00
dmytro ivanov
29dc070c2d Report issues in base material for shader platforms not covered by current RHI feature levels.
#rb Jack.Porter

[CL 28658986 by dmytro ivanov in ue5-main branch]
2023-10-11 07:36:26 -04:00
sameer mirza
7e5d316534 Fix "Promote to Variable" in Root node pins only creating Vector nodes.
#jira UE-160029
#rb Jason.Nadro

[CL 28540497 by sameer mirza in ue5-main branch]
2023-10-06 10:53:19 -04:00
dmytro ivanov
253f2b03a5 Improve platform stats and material editor compilation warnings.
#rb Jack.Porter

[CL 28382284 by dmytro ivanov in ue5-main branch]
2023-10-02 12:31:34 -04:00
charles derousiers
7a8788dd6f Fix material function crash with Substrate on preview.
There were two issues:
* The material function preview was not correctly converting material attribute output.
* The cached expression were not populated, causing the IsMaterialAttributeOutput() function to not return the correct value.

Down the line, this was causing material attribute data to be connected to a float3 input causing a crash down the line.

#rb none
[FYI] sebastien.hillaire, massimo.tristano

[CL 28180761 by charles derousiers in ue5-main branch]
2023-09-25 03:14:01 -04:00
jason nadro
bbe8eb58e0 Fix for conflicting localization messages with material editor errors.
- Warning_CompileErrorsInMaterial was used twice for two different error messages.
- Renamed the second one to Warning_CompileErrorsInMaterialInstance, since it was an error message specific to material instances.

#rb Jon.Cain
#jira UE-195762

[CL 28033767 by jason nadro in ue5-main branch]
2023-09-20 09:38:01 -04:00
dmytro ivanov
9dba280cc1 Show material hierarchy in platform stats and warn if derived material instances fail to compile
#rb Jack.Porter

[CL 27909604 by dmytro ivanov in ue5-main branch]
2023-09-15 05:04:46 -04:00
sebastien hillaire
fc45c02460 Substrate - renaming - renamed to MCT_Substrate
#rb charles.derousiers

[CL 27593807 by sebastien hillaire in ue5-main branch]
2023-09-05 08:51:11 -04:00
marc audy
65de35fdfb Lof elements that were not renamed yet.
- MSM_Substrate
- MCT_Substrate
- FStrataMaterialInput

#rb charles.derousiers

[CL 27563163 by marc audy in ue5-main branch]
2023-09-01 15:06:19 -04:00
sebastien hillaire
eff56c2a11 Substrate - Renaming - Strata class redirection to Substrate class.
#rb none
[FYI] charles.derousiers

[CL 27518277 by sebastien hillaire in ue5-main branch]
2023-08-31 07:55:22 -04:00
charles derousiers
195d4a8fe8 * Fix Substrate colored connection on input
* Add colored pin for Substrate data flow

#rb none
[FYI] sebastien.hillaire

[CL 27515051 by charles derousiers in ue5-main branch]
2023-08-31 04:49:11 -04:00
sebastien hillaire
b7f8af4297 Substrate - Rename/move file(s)
#rb none
[FYI] charles.derousiers

[CL 27515000 by sebastien hillaire in ue5-main branch]
2023-08-31 04:48:07 -04:00
sebastien hillaire
4f274d1ef3 Substrate - Rename/move file(s)
#rb none
[FYI] charles.derousiers

[CL 27514986 by sebastien hillaire in ue5-main branch]
2023-08-31 04:47:50 -04:00
charles derousiers
fc598811b5 Add color Substrate wire.
#rb none
[FYI] sebastien.hillaire

[CL 27514913 by charles derousiers in ue5-main branch]
2023-08-31 04:46:18 -04:00
charles lefebvre
a7e99ef2cb Fix bad cast in MaterialEditor.cpp
#rb daren.cheng
#rnx

[CL 27322331 by charles lefebvre in ue5-main branch]
2023-08-23 17:30:49 -04:00