Commit Graph

173 Commits

Author SHA1 Message Date
dan elksnitis
5bcff15345 [shaders] modify FShaderCode finalize to create a FSharedBuffer object, and modify all downstream uses of shader code to re-use this buffer (job cache, pushes to DDC, shader maps, and shader library). This reduces total amount of LLM tracked memory allocated at the end of a cold Lyra PS4 cook by about ~350MB; impact likely much larger for cooks of larger projects.
resubmit with following fixes:
- static analysis error which caught an >=0 check on a uint64 which should have been >0
- fix for an inverted guard on multiprocess cook sending bytecode to director (was only sending code across if empty instead of non-empty)
- fix for uninitialized padding in the FShaderCodeResource::FHeader struct causing nondeterministic puts
- fix for incorrect size passed to job cache hashing on receiving buffers from DDC

#rb Devin.Doucette, Laura.Hermanns, Zousar.Shaker
#lockdown Marc.Audy

[CL 36754792 by dan elksnitis in 5.5 branch]
2024-10-01 19:02:22 -04:00
serge bernier
29d7e5ecc0 DynamicShaderPreloading. Removed changes to CollectPSOInitializers functions so that we dont have to do deprecations. Moved all code logic for PSO shader preloading in one location (AddGraphicsPipelineStateInitializer) to improve code maintenance.
#rb Kenzo.Terelst, daniele.vettorel

#ushell-cherrypick of 36478045 by serge.bernier (second/final submit)

[CL 36748004 by serge bernier in 5.5 branch]
2024-10-01 17:50:10 -04:00
serge bernier
f3620d4994 Support Dynamic shader preloading. Similar to PSOPrecaching, we can load shaders on demand instead of preloading all of them when we load the package. This reduce the memory footprint on shaders since we only load shaders that will be used for rendering. Shader preloading also support the same code logic to delay the creation of the prender proxy when the shaders are not finished loading.
Save up to 16MB on some platforms.

#rb daniele.vettorel, danny.couture, Kenzo.Terelst
#tests 66d8b4154a47dde1dd226334



#ushell-cherrypick of 36036431 by serge.bernier (first of 2 submits)

[CL 36747837 by serge bernier in 5.5 branch]
2024-10-01 17:48:22 -04:00
dan elksnitis
fd01802612 [Backout] - CL36470025
[FYI] dan.elksnitis
Original CL Desc
-----------------------------------------------------------------
[shaders] modify FShaderCode finalize to create a FSharedBuffer object, and modify all downstream uses of shader code to re-use this buffer (job cache, pushes to DDC, shader maps, and shader library). This reduces total amount of LLM tracked memory allocated at the end of a cold Lyra PS4 cook by about ~350MB; impact likely much larger for cooks of larger projects.

#rb Devin.Doucette, Zousar.Shaker
#lockdown Marc.Audy
resubmit with SA+MP cook fix

[CL 36747522 by dan elksnitis in 5.5 branch]
2024-10-01 17:45:02 -04:00
dan elksnitis
8c666d2108 [shaders] modify FShaderCode finalize to create a FSharedBuffer object, and modify all downstream uses of shader code to re-use this buffer (job cache, pushes to DDC, shader maps, and shader library). This reduces total amount of LLM tracked memory allocated at the end of a cold Lyra PS4 cook by about ~350MB; impact likely much larger for cooks of larger projects.
#rb Devin.Doucette, Zousar.Shaker
#lockdown Marc.Audy

resubmit with SA+MP cook fix

[CL 36746984 by dan elksnitis in 5.5 branch]
2024-10-01 17:40:02 -04:00
dan elksnitis
c02d3f0517 [Backout] - CL36437712
[FYI] dan.elksnitis
Original CL Desc
-----------------------------------------------------------------
[shaders] modify FShaderCode finalize to create a FSharedBuffer object, and modify all downstream uses of shader code to re-use this buffer (job cache, pushes to DDC, shader maps, and shader library). This reduces total amount of LLM tracked memory allocated at the end of a cold Lyra PS4 cook by about ~350MB; impact likely much larger for cooks of larger projects.

#rb Zousar.Shaker
#lockdown marc.audy

[CL 36440265 by dan elksnitis in 5.5 branch]
2024-09-19 13:16:02 -04:00
dan elksnitis
c7dfb5d9b6 [shaders] modify FShaderCode finalize to create a FSharedBuffer object, and modify all downstream uses of shader code to re-use this buffer (job cache, pushes to DDC, shader maps, and shader library). This reduces total amount of LLM tracked memory allocated at the end of a cold Lyra PS4 cook by about ~350MB; impact likely much larger for cooks of larger projects.
#rb Zousar.Shaker
#lockdown marc.audy

[CL 36437741 by dan elksnitis in 5.5 branch]
2024-09-19 12:21:59 -04:00
denys mentiei
2d51207d47 Shader library fix to support loading chunks scattered over different folders.
Previously, it was looking in the base directory only.
However, when shader library is split between different install bundles, chunks might be scattered over multiple directories.

It actually happens with .metallibs, which are located in different UFS folders now (which is fine).
Refer to CL 35423329 to see why.

The fix is to look through the mounted chunk folder, so shader library picks that.

#rb anderson.ramos, Arciel.Rekman
#rnx

[CL 36227046 by denys mentiei in 5.5 branch]
2024-09-12 10:22:05 -04:00
dan elksnitis
c4deae64ff [shaders] bytecode sharing between shader and shadermap DDC buckets
- create utility classes (serialization context objects) which allow serialization of shader code blobs independently of "shader object" (i.e. whatever type of thing we're pushing to the cache, shader job or shader map) structure
- commonize bytecode format in cache entries for shadermap and shader DDC (FShaderCodeResource struct)
- rework per-shader caching to use the serialization helpers to separate serialization of job output struct data and bytecode
- rework material and global shadermap DDC serialization to use the serialization helpers to separate serialization of shadermap structural data and bytecode

#rb Laura.Hermanns, Zousar.Shaker
#jira UE-196556

(resubmit with monolithic build fix)

[CL 36153164 by dan elksnitis in 5.5 branch]
2024-09-10 13:06:22 -04:00
zousar shaker
5cabc11d45 Introduce an interface (ICookArtifactReader) for reading data back from a package store used at cook time, with implementations to either read artifacts from zen (if not present on the filesystem), or read artifacts from the filesystem alone. Also ensured that the reader is used in the places that currently expect to read data for incremental cook. Specifically:
- CookSettings.txt
- DevelopmentAssetRegistry.bin
- Shader code libraries

#rb Matt.Peters

[CL 35461438 by zousar shaker in ue5-main branch]
2024-08-12 14:45:14 -04:00
jason nadro
9ea1f9f125 Downgrade benign/innocuous ShaderLibrary logging to Verbose
- We blindly iterate _all_ content plugins and try to load a shader library for them.  Not all plugins will have shaders/materials so this results in too much log spam.
- This logging has caused confusion frequently so downgrading it will help.

[CL 34871521 by jason nadro in ue5-main branch]
2024-07-17 12:40:42 -04:00
adam kinge
a5416b5331 Metal doesn't support ushaderbytecode chunks, so use metallib chunks instead
#rb carl.lloyd

[CL 34379211 by adam kinge in ue5-main branch]
2024-06-14 14:37:59 -04:00
anton dunchev
6ceec8f13b [UE] Fixed ListShaderLibraries didn't output shader maps size
#rb simon.orr
#rnx
#tests cooked build

[CL 34221641 by anton dunchev in ue5-main branch]
2024-06-07 22:00:45 -04:00
anton dunchev
8b0b461407 [RHI] Added shader map and shader library listing commands that let you analyse the memory footprint of those structures.
[FYI] j.baumgartner
#rb serge.bernier
#tests local

[CL 34035856 by anton dunchev in ue5-main branch]
2024-05-31 13:17:18 -04:00
arciel rekman
40c2dc33fc stat shaders: removed some obsolete stats, added a stat showing actually used shadermaps.
[REVIEW] Serge.Bernier
#rb daniele.vettorel, serge.bernier
#tests ran a replay

[CL 33576191 by arciel rekman in ue5-main branch]
2024-05-10 11:19:30 -04:00
anton dunchev
69fd53db6a [LLM] Scope filesystem callbacks to shader code into Shader LLM, added more asset tags
#rb robert.millar
#tests PIE

[CL 33360979 by anton dunchev in ue5-main branch]
2024-04-30 20:09:23 -04:00
kenzo terelst
0482360a8a - Don't make failing of global compute PSO precached shaders fatal
- Log info on shader creation failure due to missing RHI features

#jira UE-212906
#rb mihnea.balta

[CL 33225195 by kenzo terelst in ue5-main branch]
2024-04-25 04:16:22 -04:00
arciel rekman
0e43db38ca Fix rare FShaderMapResource_SharedCode::ReleaseRHI crash
#rb Rex.Hill
[REVIEW] [at]Rex.Hill

[CL 32346330 by arciel rekman in ue5-main branch]
2024-03-19 20:56:27 -04:00
arciel rekman
ddbcb0698c Fix leaking shader code preloading entries.
- Credits to Rex Hill for working out the mechanics of the leak.

#rb Rex.Hill
[REVIEW] [at]Rex.Hill, [at]Daniele.Vetorel

[CL 32331074 by arciel rekman in ue5-main branch]
2024-03-19 13:28:59 -04:00
daniele pieroni
6a811b697e Enabling chunk discovery on all build configurations in order to support Zen Streaming on Test configuration, while relying on the runtime check
if (!IsRunningWithPakFile() && ShouldLookForLooseCookedChunks())
to not affect performance in Test and Shipping builds that are using pak files.

#rb Yuriy.ODonnell
[FYI] Arciel.Rekman
#jira UE-209658

[CL 32254188 by daniele pieroni in ue5-main branch]
2024-03-14 14:58:56 -04:00
bob tellez
b9a0ee14a3 [Backout] - CL31423450
[FYI] dan.elksnitis
Original CL Desc
-----------------------------------------------------------------
[shaders]
- store shadertype associations for each shader in a shadermap in the editor only data
- output a debug artifact containing per-shadertype permutation/memory stats; note that this is not directly representative of final shader memory usage since it doesn't account for shader library deduplication or shader library chunk re-duplication; it is only intended to be used as a tool for tracking/identifying shader growth due to added/modified shadertypes
- remove the old "dumpshadercodestats" path from the shader library, as well as the stats tracking "unique" shaders and shader memory; the former is no longer used and the latter does not correctly account for library chunking
- bump shader version due to shadermap editoronly data change

#rb Arciel.Rekman

[CL 31780302 by bob tellez in ue5-main branch]
2024-02-23 17:25:34 -05:00
kevin macaulayvacher
8a51319dfe DoesPackageExist AssetRegistry optimization: Re-enables optimization to avoid scanning on disk for corrected casing for FNames by changing the check to determine when the IoDispatcher is in use.
We expose the previously private, and unused HasScriptObjectsChunk method to the IODispatcher, as multiple codepaths are relying on this path to determine if the IoDispatcher is being used at runtime to load from chunks.

#jira UE-206417
#rb Per.Larsson
[FYI] Francis.Hurteau

[CL 31615213 by kevin macaulayvacher in ue5-main branch]
2024-02-19 12:40:05 -05:00
dan elksnitis
6f11179f09 [shaders]
- store shadertype associations for each shader in a shadermap in the editor only data
- output a debug artifact containing per-shadertype permutation/memory stats; note that this is not directly representative of final shader memory usage since it doesn't account for shader library deduplication or shader library chunk re-duplication; it is only intended to be used as a tool for tracking/identifying shader growth due to added/modified shadertypes
- remove the old "dumpshadercodestats" path from the shader library, as well as the stats tracking "unique" shaders and shader memory; the former is no longer used and the latter does not correctly account for library chunking
- bump shader version due to shadermap editoronly data change

#rb Arciel.Rekman

[CL 31423534 by dan elksnitis in ue5-main branch]
2024-02-13 09:09:37 -05:00
arciel rekman
d61e2cf74c Fix shader code stats being output in gigabytes instead of megabytes.
- Thanks to Dan Elksnitis for noticing!

#rb Dan.Elksnitis

[CL 31147346 by arciel rekman in ue5-main branch]
2024-02-02 18:15:30 -05:00
arciel rekman
9b1b932d44 Add per-shader-type itemization for shader libraries.
- At the end of the cook, produces stats like

Unique shaders itemization (sorted by compressed size):
SF_Compute: 3202 shaders (65.59%), compressed size: 0.06 MB (19.70 KB avg per shader), uncompressed size: 0.09 MB (29.44 KB avg per shader)
SF_Pixel: 1238 shaders (25.36%), compressed size: 0.02 MB (16.65 KB avg per shader), uncompressed size: 0.03 MB (24.99 KB avg per shader)
SF_RayGen: 296 shaders (6.06%), compressed size: 0.01 MB (37.48 KB avg per shader), uncompressed size: 0.02 MB (55.79 KB avg per shader)
SF_Vertex: 115 shaders (2.36%), compressed size: 0.00 MB (6.97 KB avg per shader), uncompressed size: 0.00 MB (10.78 KB avg per shader)
SF_RayHitGroup: 18 shaders (0.37%), compressed size: 0.00 MB (5.12 KB avg per shader), uncompressed size: 0.00 MB (7.84 KB avg per shader)
SF_RayMiss: 9 shaders (0.18%), compressed size: 0.00 MB (7.63 KB avg per shader), uncompressed size: 0.00 MB (11.81 KB avg per shader)
SF_Geometry: 3 shaders (0.06%), compressed size: 0.00 MB (2.63 KB avg per shader), uncompressed size: 0.00 MB (4.78 KB avg per shader)
SF_RayCallable: 1 shaders (0.02%), compressed size: 0.00 MB (1.68 KB avg per shader), uncompressed size: 0.00 MB (2.71 KB avg per shader)

#rb dan.elksnitis
[REVIEW] [at]Dan.Elksnitis

[CL 31141673 by arciel rekman in ue5-main branch]
2024-02-02 16:40:20 -05:00