Commit Graph

40 Commits

Author SHA1 Message Date
zach bethel
9911a6581b Coalesced UpdateAllPrimitiveSceneInfo calls into one call prior to scene rendering. This includes all {Add, Remove}Level instances and a spot on the game thread where all scenes are updated. The former case is handled by deferring level adds / removes until UpdateAllScenePrimitiveInfos is called. The latter processes scenes at the end of the frame only if they weren't already processed by a render event.
This coalescing has a few benefits. First, it allows async LPI and mesh command creation jobs to handle level streaming events. Second, batches more work together which opens more doors to parallelization in follow-up CL's.

Finally, this change splits the mesh caching jobs for nanite and ray tracing off into their own tasks, which improves parallelism.

#preflight 63ea8a675d72661e36f1a9b9

[CL 24195188 by zach bethel in ue5-main branch]
2023-02-13 18:49:51 -05:00
dan thompson
4a6b8c8b00 Removal of the r.Shaders.CompressionFormat CVar, and shader group compression during UnrealPak now inherits the packaging compresison level.
Due to the fact that UnrealPak doesn't load INIs, the cvar was always its default value. This, combined with the fact that shaders don't store what codec they are compressed with means that setting this cvar to anything other than default (oodle) causes a crash in UnrealPak as DecompressShader will try to decompress with Oodle independent of the actual codec. Rather than plumb this information down through ProjectParams, I felt it prudent to just always use Oodle.

Additionally, in order to facilitate faster iteration times for development build farm jobs, the shader compression level used during UnrealPak will inherit from the overall package compression level set via Project Settings (PackageCompressionLevel_*).

This tacitly avoids patch issues as the default shader compression level happens to be the default package compression level, except now it inherits any faster levels for iteration time.

Note that we still use Mermaid as the codec as it's faster for decompressing than Kraken, which we care about for shaders.

#rb Fabian.Giesen
#rb Arciel.Rekman
#preflight 63e2f94c786751d1e0ffb290

[CL 24092953 by dan thompson in ue5-main branch]
2023-02-09 00:35:55 -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
bob tellez
971983eb65 [Backout] - CL23624045
[FYI] christopher.waters
Original CL Desc
-----------------------------------------------------------------
RHI header dependency cleanup
- Reducing other header dependencies from RHIDefinitions.h
- Moved a few functions to the new RHIStrings.h
- Uniform buffer layout initializer moved to its own file to reduce RHI dependency on MemoryLayout.

#preflight 63bca752577437afe604b097

[CL 23631957 by bob tellez in ue5-main branch]
2023-01-10 15:28:15 -05:00
christopher waters
3df5dae685 RHI header dependency cleanup
- Reducing other header dependencies from RHIDefinitions.h
- Moved a few functions to the new RHIStrings.h
- Uniform buffer layout initializer moved to its own file to reduce RHI dependency on MemoryLayout.

#preflight 63bca752577437afe604b097

[CL 23631946 by christopher waters in ue5-main branch]
2023-01-10 15:27:33 -05:00
tiago costa
5e26d477a0 Append instead of overwrite output array in FRayTracingShaderLibrary::GetShaders(...)
- required to support RTPSO with hitgroups with different payloads.

#preflight 63b4858f2540a78d27bef4de
#rb chris.kulla
#jira UE-173204

[CL 23569623 by tiago costa in ue5-main branch]
2023-01-03 15:55:23 -05:00
christopher waters
6e30ddb01e Dependency cleanup around DataDrivenShaderPlatformInfo and a few other headers.
#preflight 63921e6a67018b14b5925197

[CL 23454104 by christopher waters in ue5-main branch]
2022-12-08 15:35:35 -05:00
arciel rekman
95b3818586 Use shader hashes for computing PrecachePSOHash.
- Allows construction of StatePrecachePSOHash in FGraphicsPipelineStateInitializers that are not associated with MDCs.
- Also better reflects the actual PSO compatibility.

[REVIEW] [at]Graham.Wihlidal, [at]Kenzo.TerElst
#preflight

[CL 23300306 by arciel rekman in ue5-main branch]
2022-11-28 19:16:55 -05:00
Arciel Rekman
f5f6d47027 Make sure shader refcount cannot be 0 during the creation.
#rb Yuriy O'Donnell
#review @Arne.Schober
#jira
#preflight 636e9116953c19d435584df2

[CL 23101686 by Arciel Rekman in ue5-main branch]
2022-11-11 13:36:14 -05:00
Arciel Rekman
a9a272c7a9 Support concurrent shader creation within a shadermap (UE-166109).
- Avoids oversubscription deadlock when multiple background threads are creating shaders during the PSO precaching.

#rb CM Nordin, Yuriy O'Donnell
#jira UE-166109
#review
#preflight 6365bb2b4b0e01486a9753be

[CL 23010571 by Arciel Rekman in ue5-main branch]
2022-11-07 10:15:34 -05:00
chris kulla
b00b7d70d0 Organize Ray Tracing shaders by their payload
Every shader now has the ability to declare which payload it uses. HitGroup, Miss and Callable shaders may only specify a single type, whereas Raygen shaders may provide more than one.

The global raytracing shader libraries have been categorized according to their payload type, which helps facilitate the creation of minimal ray-tracing pipelines.

Avoid adding callable shaders to the RTPSO if they are not being used.

All RHI shader compilers and shader loaders that support ray tracing have been modified to track an extra uint representing the payload type flagged in the source (at time of compilation).

Add the RayTracingPayloadType to the shadermap DDC key so that we can properly detect when a shader's payload type is invalidated. This is required because we serialize the payload type into the shaders from the C++ side.

#rb Yuriy.ODonnell
#jira none
#preflight 635715cae6096564af4dd28e

[CL 22742893 by chris kulla in ue5-main branch]
2022-10-24 20:11:02 -04:00
christopher waters
41c44beead Cleaning up deprecated items in "Shader" files for 5.2
#jira none
#rb yuriy.odonnell
#preflight 633cab5d0e66c104f1daed41

[CL 22356197 by christopher waters in ue5-main branch]
2022-10-05 11:38:15 -04:00
dan elksnitis
5c623efceb [shaders] fix determinism issue in serializing shader maps to DDC - previously warnings were appended to a single array in order of job completion which is inherently unstable.
- modified serialization to instead add the warnings along with debug info to an "editor only data" struct, and store one of these per deduplicated bytecode entry (note the previous separate deduplication step for debug data was determined to be redundant)
- append additional context information to each warning via a DebugName argument passed to AddShaderCompilerOutput and store all warnings associated with a single bytecode (including those encountered for different permutations with potentially different source code resulting in the same bytecode) in sorted order
- add a simple ToString helper to FShaderCompileJobKey for easy construction of the DebugName argument for the above
- modify all engine usage of AddShaderCompilerOutput to construct this debug name from the job key

#rb Yuriy.ODonnell
#rb Jason.Nadro
#preflight 633ae2263629a1a4f913a041
#jira UE-150069

[CL 22301631 by dan elksnitis in ue5-main branch]
2022-10-03 09:42:06 -04:00
kenzo terelst
5cffab66a5 PSO Precache Base Changes (disabled by default)
Add PSOPrecache file which wraps engine level PSO structs and functions
- FPSOPrecacheParams used to wrap certain parameters which drive the PSO collection (mostly set from components)
- IPSOCollector interface used as engine entry to the mesh pass processors in renderer project
- FPSOCollectorCreateManager to wrap all statically registered IPSOCollector CreateFuncions
- PSOCollectorStats structs and helper functions

Add PSOPrecache support to PipelineStateCache:
- functions to precache compute and graphics PSOs
- functions to check current precache state
- FPrecacheGraphicsPipelineCache which wraps all currently precached PSOs

IMaterial entry function to PrecachePSOs with given vertex factories and params (implemented by UMaterial & UMaterialInstance) which forwards call to FMaterial and finally the FMaterialShaderMap
- FMaterialShaderMap will iterate all registered IPSOCollector to collect all possible PSOs used and forward them to the PipelineStateCache for actual (async) precaching

RHI Changes:
- Add RHI specific functions to retrieve & compare the FRHIVertexDeclaration and FGraphicsPipelineStateInitializer hash for each RHI
- Add helper functions to match RHI*State data by retrieving initializer

Minimal vertex factory changes for PSO precaching as prep - actual changes in upcoming CLs

MeshPassProcessor base functions to collect PSOs which can be used by all mesh pass processor implemention (actual changes in upcoming CLs)
- Cache complete precache data hash of stored minimal PSO so it can be used for fast actual PSO initializer hash computation (full PSO initializer is build at runtime)
- Cache if minimal PSO was successfully precache and option to skip draw when PSO is still precaching (disabled by default and doesn't work yet via GPU scene based rendering)
- Add helper functions to setup the per mesh pass render target data used during PSO collection

Refactor SceneTextureConfig so it can be initialized from an init struct and move all function to setup the internal members from SceneTexture to SceneTextureConfig using the data from the init struct (so it's available in Engine project)

Fix GBufferInfo format for velocity target (was always floating point while it should be unorm when not android

Make certain helper functions definitions to h file so they can be used everywhere (SupportsNaniteRendering, FTextureRenderTarget2DResource::GetFormat & CreateFlags)

#preflight 63189a5a967ffc68fb9044a5
#jira UE-139584
#rb Mihnea.Balta

[CL 21907508 by kenzo terelst in ue5-main branch]
2022-09-08 19:34:08 -04:00
christopher waters
f9e5f44dee Restoring functionality to r.ShaderCompiler.EmitWarningsOnLoad
#jira none
#rb jason.nadro
#preflight 62a8ab32d502a554367beb52

[CL 20657856 by christopher waters in ue5-main branch]
2022-06-14 17:03:34 -04:00
tiago costa
e98ce47a3b Keep track of all callable shaders to build RTPSO
- GetRayTracingCallableLibrary() similar to how we handle hitgroups.
FindRayTracingCallableIndex(...) to query callable shader index in RTPSO.

#rb yuriy.odonnell
#preflight 628620c99016c6dd8974b510

[CL 20278150 by tiago costa in ue5-main branch]
2022-05-19 07:03:30 -04:00
dmytro vovk
836eb44099 Fixed TSan warning in Shader Resource
#rb Andriy.Tylychko
#jira none
#preflight 6244f88df73c316f68ea74d3

[CL 19567472 by dmytro vovk in ue5-main branch]
2022-03-30 20:57:33 -04:00
zak middleton
cbbda06e18 #ue5 - Fix FMath::Clamp() and FMath::GridSnap() incorrectly mixing signed/unsigned types when an explicit signed template type is requested.
Changed macro used to resolve overloads for these 2 functions to the one requiring one actual float/double type in the arguments. Removed old macro that allowed mixing signed/unsigned int types and replaced it with one that requires all the types to be signed to match any overloads (tested but currently unused).

Resolved some compile errors that resulted from newly ambiguous calls that mixed signed/unsigned integer types.

#jira UE-143473
#rb Andrew.Davidson
#preflight 6215382b30639b44d2f52355


#ROBOMERGE-AUTHOR: zak.middleton
#ROBOMERGE-SOURCE: CL 19098314 via CL 19099699 via CL 19100188 via CL 19100709 via CL 19109894
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v921-19075845)

[CL 19147214 by zak middleton in ue5-main branch]
2022-02-25 10:09:25 -05:00
arciel rekman
fc7d2c93cb Silence spammy warning about uncompressed shaders.
#rb none

#ROBOMERGE-AUTHOR: arciel.rekman
#ROBOMERGE-SOURCE: CL 18735247 via CL 18736213 via CL 18736349 via CL 18736869 via CL 18737353
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v903-18687472)

[CL 18737684 by arciel rekman in ue5-main branch]
2022-01-26 12:32:20 -05:00
andrew davidson
0715ebc996 Type truncation fixes - Renderer
#rb arne.schober
#preflight 61d85ab0932a02483ce13e7d

#ROBOMERGE-AUTHOR: andrew.davidson
#ROBOMERGE-SOURCE: CL 18544411 in //UE5/Release-5.0/... via CL 18544434
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v899-18417669)

[CL 18544466 by andrew davidson in ue5-release-engine-test branch]
2022-01-07 10:39:08 -05:00
arciel rekman
43b5c6d968 Change shader compression to Mermaid6 to increase memory savings (UE-136845).
#rb Discussed preflight results on Slack with Jay.C, Serge.B, Pete.S
#jira UE-136845

#ROBOMERGE-AUTHOR: arciel.rekman
#ROBOMERGE-SOURCE: CL 18537018 via CL 18537027 via CL 18537032 via CL 18538372 via CL 18538388
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v899-18417669)

[CL 18538396 by arciel rekman in ue5-release-engine-test branch]
2022-01-06 20:16:56 -05:00
arciel rekman
2a499437fe Change shader compression method to Oodle Selkie6 by default (UE-136845).
- Provides about 8% runtime memory savings (in local tests).
- Also, adds more compression types for shaders.
- Impact on the shader compilation (in SCWs) seems to be negligible in local tests.

#rb Devin.Doucette, Charles.Bloom
[REVIEW] [at]Devin.Doucette, [at]Charles.Bloom, [at]Jason.Nadro
#jira UE-136845

#ROBOMERGE-AUTHOR: arciel.rekman
#ROBOMERGE-SOURCE: CL 18502862 via CL 18503105 via CL 18503112 via CL 18505939 via CL 18505950
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v899-18417669)

[CL 18505961 by arciel rekman in ue5-release-engine-test branch]
2022-01-04 00:58:30 -05:00
yuriy odonnell
7f82e90db3 Add separate RHI capability properties for full ray tracing shaders and inline ray tracing. While most RHIs may support both features, some may only support one.
#preflight 619ce604f934c1a291f81cfe
#rb aleksander.netzel

#ROBOMERGE-AUTHOR: yuriy.odonnell
#ROBOMERGE-SOURCE: CL 18270186 in //UE5/Release-5.0/... via CL 18270194
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)

[CL 18270205 by yuriy odonnell in ue5-release-engine-test branch]
2021-11-23 10:25:31 -05:00
aurel cordonnier
69fe095547 Merge from Release-Engine-Staging @ 17636544 to Release-Engine-Test
This represents UE4/Main @17638339 and Dev-PerfTest @17636504

[CL 17638842 by aurel cordonnier in ue5-release-engine-test branch]
2021-09-27 19:54:25 -04:00
christopher waters
1c21a5489c Shader symbol terminology changes
- Splitting symbol generation and shader "debug info" generation into two different cvars. This should now allow us to generate symbols post-packaging without generating different shader variants. This should also enable us to always generate symbols and still have the final deduplicated shader sizes.
- r.Shaders.Symbols is now the primary way to enable shader symbols for debugging.
- r.Shaders.GenerateSymbols can be enabled to always generate symbols without writing them to disk.
- r.Shaders.WriteSymbols can be used to force write symbols if they were previously generated.
- r.Shaders.ExtraData can be used to generate shader names for engine runtime systems to use.
- NotifyShaderCooked replaced with NotifyShaderCompiled, prep for upcoming non-cook symbol writing.
- PC DXC shader compiles should only generate debug info when requested, not all the time.
- PC FXC shader compiles should generate debug info when requested, not just when r.Shaders.Optimize is 0.

#jira none
#rb arciel.rekman, lukas.hermanns
#preflight 611ad9035e737200015992db

#ROBOMERGE-SOURCE: CL 17186155 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v855-17104924)

[CL 17186162 by christopher waters in ue5-release-engine-test branch]
2021-08-16 23:18:23 -04:00