Commit Graph

198 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
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
JayLu2000
e04a0ccdd5 PR #12150: [MetaXR]: Integrate Adreno Offline Shader Compiler into UE
#jira UE-220969
#rnx
#rb Dmitriy.Dyomin, Florin.Pascu

[CL 35369646 by JayLu2000 in ue5-main branch]
2024-08-07 11:07:33 -04:00
dan elksnitis
49e65b9086 [shaders]
- add strings as an option for shader statistics, and a flags member/option to hide specific shader statistics from UI (so we can use statistics for other internal usage)
- add debug output for shader platform hashes (use to track down cases of shader job output which has identical bytecode but differing metadata), using the above to record a stat containing the shader hash computed by the compiler. currently only implemented for a subset of platforms
- fix a bug in shader diagnostic remapping for cache hits - the value stored in the cache/DDC for a job should contain non-remapped diagnostics (so cache hits can properly remap them to their version of the unstripped shader code). this also slightly improves deduplication within the job cache/DDC. fixed by storing the job output in the cache/DDC before running the job oncomplete callback (which performs the remapping)
- cleanup dxc hash retrieval code to use actual type instead of hacking around with an offset into the opaque blob

#rb Jason.Nadro

[CL 34864220 by dan elksnitis in ue5-main branch]
2024-07-17 08:55:02 -04:00
christopher waters
cfc6f343df Uniform Buffer improvements
- Moving various UB booleans into a flags enum.
- UB booleans could not be reasonably deprecated without incurring memory overhead, so this will break custom code that uses them.
- Adding UB flag to force the shader compilers to generate reflection for the UB members which are normally excluded from reflection.
- Adding UB flag that tells MeshCommands that a UB will be bound during pass drawing and that it doesn't need to be set via MDCs.
- New flags are not used in this CL, they are prerequisites for subsequent, larger changes.

#rb jeannoe.morissette

[CL 34356503 by christopher waters in ue5-main branch]
2024-06-13 17:59:13 -04:00
christopher waters
320aed67bc Reducing allocations when using FShaderParameterMap
- TCHAR* arguments were being used to find elements in a TMap<FString,..> which creates temporary memory allocations.
- We can use FStringView with FindByHash/RemoveByHash to prevent temporary allocations.
- Adding FShaderParameterMap::FindAndRemoveParameterAllocation as a shortcut for Find+Remove (which Uniform Buffer member handling does).
- Fixing a few locations that were going FString->TCHAR*->FString.

#rb Laura.Hermanns

[CL 34065428 by christopher waters in ue5-main branch]
2024-06-03 10:21:45 -04:00
aleksander netzel
d33a06efeb HWRT: Reducing RHI_RAYTRACING throughout the engine - Editor
#jira UE-213513

[CL 33441267 by aleksander netzel in ue5-main branch]
2024-05-03 19:21:04 -04:00
zach bethel
0674d30d69 Added SRVNonPixel, SHADER_PARAMETER_RDG_NON_PIXEL_SRV, and modified RDG_TEXTURE_ACCESS to support texture subresources.
- SRVNonPixel is needed by mobile to insert a barrier between fragment -> vertex texture fetch, but since this is a heavyweight barrier, it is opt-in with SHADER_PARAMETER_RDG_NON_PIXEL_SRV.
 - Small refactor to FRDGTextureAccess to allow for arbitrary subresources, as the current model only allows full resource transitions.

#rb mihnea.balta, luke.thatcher, serge.bernier
#jira UE-211883

[CL 33179861 by zach bethel in ue5-main branch]
2024-04-23 17:02:48 -04:00
jeremy moore
ba42a867b2 #jira UE-209673
Split Work Graph shaders into multiple frequencies.
This is somewhat in anticipation of graphic nodes.
But also it is a replacement for using CFLAG_WorkgraphLocalNodes to differentiate nodes with local or global root signature.
#rb Yuriy.ODonnell

[CL 33146442 by jeremy moore in ue5-main branch]
2024-04-22 14:59:28 -04:00
john huelin
7121101cd8 SDK (1): Changes in common code needed to support SDK changes on some platforms
#rb Wojciech.Krywult

[CL 32855114 by john huelin in ue5-main branch]
2024-04-10 09:49:42 -04:00
dan elksnitis
b7bd62a7c5 [shaders]
- strip old job cache path (constructing an input hash based on all inputs); the cache key based on preprocessed source is now the One True Job Cache
- strip parallelfor-based job submission path (gamethread-blocking); the task path has been enabled for a long while now without issues
- remove the "compile job inputs" debug dump; this is no longer relevant since it's based on inputs to the now-stripped compile job path (similar functionality will be provided by the new form of debug usf once completed)

#rb Laura.Hermanns

[CL 32825320 by dan elksnitis in ue5-main branch]
2024-04-09 10:29:26 -04:00
christopher waters
dd2f49d25c Adding RHIResourceCollection RHI resource type which can store bindless indices in a buffer.
#rb Luke.Thatcher

[CL 32764889 by christopher waters in ue5-main branch]
2024-04-05 13:22:22 -04:00
dan elksnitis
1d261111ce [shaders]
- modify the input hash debug dump mechanism to output an empty "debughash_<hash>" file instead of a txt file with the hash in contents, and always dump these files for the instance of the job that actually compiled
- the existing cvar will now just make it so these files are also dumped for jobs which hit in DDC or the job cache; we don't do this by default so there's only a single match for the debug hash for any given shader normally and it is inside the folder containing the full debug info, including those artifacts which are only output as a side effect of the compile step
- add the same hash as the first line in the stripped source code, so "debughash_<hash>" can be used as a search term in Everything to quickly find debug info associated with a shader (i.e. when looking at a capture in renderdoc or similar)

note: this is a resubmit with fixes for mac/linux issues (avoiding printfs and using string builders instead; since wchar_t and TCHAR are not the same size on these platforms using %ls does not work), and a further fix for problems encountered with source compression when using wide chars in preprocessing instead of ansi chars.

#rb Laura.Hermanns
#jira UE-209753

[CL 32542773 by dan elksnitis in ue5-main branch]
2024-03-27 10:15:04 -04:00
dan elksnitis
52e25ae283 [Backout] - CL32436224
[FYI] dan.elksnitis
Original CL Desc
-----------------------------------------------------------------
[shaders]
- modify the input hash debug dump mechanism to output an empty "debughash_<hash>" file instead of a txt file with the hash in contents, and always dump these files for the instance of the job that actually compiled
- the existing cvar will now just make it so these files are also dumped for jobs which hit in DDC or the job cache; we don't do this by default so there's only a single match for the debug hash for any given shader normally and it is inside the folder containing the full debug info, including those artifacts which are only output as a side effect of the compile step
- add the same hash as the first line in the stripped source code, so "debughash_<hash>" can be used as a search term in Everything to quickly find debug info associated with a shader (i.e. when looking at a capture in renderdoc or similar)

#rb Laura.Hermanns
#jira UE-209753

[CL 32448284 by dan elksnitis in ue5-main branch]
2024-03-22 16:19:02 -04:00
dan elksnitis
82e140d0c5 [shaders]
- modify the input hash debug dump mechanism to output an empty "debughash_<hash>" file instead of a txt file with the hash in contents, and always dump these files for the instance of the job that actually compiled
- the existing cvar will now just make it so these files are also dumped for jobs which hit in DDC or the job cache; we don't do this by default so there's only a single match for the debug hash for any given shader normally and it is inside the folder containing the full debug info, including those artifacts which are only output as a side effect of the compile step
- add the same hash as the first line in the stripped source code, so "debughash_<hash>" can be used as a search term in Everything to quickly find debug info associated with a shader (i.e. when looking at a capture in renderdoc or similar)

#rb Laura.Hermanns
#jira UE-209753

[CL 32436259 by dan elksnitis in ue5-main branch]
2024-03-22 11:55:53 -04:00
matthew sorrels
b1018568f8 Fix crash when cooking Android OpenGLES on Linux by replacing swscanf based parser with native FindNextHLSLDefinitionOfType
#jira UE-205727
#rnx
#rb dan.elksnitis, Dmitriy.Dyomin, Florin.Pascu

[CL 32299451 by matthew sorrels in ue5-main branch]
2024-03-18 10:05:42 -04:00
christopher waters
cd0d92d515 Moving copy-pasted code into ShaderCompilerCommon.
#rb dan.elksnitis, jeannoe.morissette

[CL 32215186 by christopher waters in ue5-main branch]
2024-03-13 11:33:04 -04:00
dan elksnitis
8906e7ca0b [shaders] further fixes for debug dump artifacts. if the shader format modifies source, ensure that is output as the <ShaderTypeName>.usf file as .bat files for invoking platform compiler directly use this version; in this case we output the directcompile-compatible version with a "_DirectCompile" suffix attached. For backends that don't modify source (i.e. don't set the ModifiedShaderSource field on the output struct) just output the directcompile-compatible version as the single <ShaderTypeName>.usf file (CL also includes cosmetic changes to suffix the dumped .usf files instead of prefixing, to avoid needing extra logic to combine prefixes when the backend already adds its own)
#rb christopher.waters
#jira UE-208327

[CL 32211196 by dan elksnitis in ue5-main branch]
2024-03-13 09:31:38 -04:00
jeremy moore
804418158d #jira UE-206245, UE-206247
Add basic DX12 Work Graph support.
For this first pass there is no exposed RHI functionality for directly dispatching a work graph. Instead shader bundles have been extended to support a work graph based implementation.
Nanite compute materials now can use work graph shader bundles on D3D12 when r.Nanite.AllowWorkGraphMaterials and r.Nanite.Bundle.Shading are both set. Both of these default to off at the moment.
Also DataDrivenPlatformInfo now expose bSupportsWorkGraphs. This is false everywhere, but will be enabled for D3D12_SM6 as soon as we have the latest DXC shader compiler with lib_6_8 support submitted.
#rb Kenzo.Terelst, Yuriy.ODonnell

[CL 32196717 by jeremy moore in ue5-main branch]
2024-03-12 18:42:09 -04:00
dan elksnitis
f66213c368 [shaders]
- modify which version of source is dumped as a debug artifact by default to be the final preprocessed source instead of the stripped version; this is more useful when debugging in directcompile mode
- re-add the dump of defines as commented code to this artifact, which was inadvertantly removed in a previous CL (bad merge)
- make the "detailed" source dump add the stripped version, and the version modified by the compile step (if it exists)
- only add the additional debug data to the stripped version (which is still something that SCW can process successfully) but remove it from the "modified" version (which typically will cause errors when running in directcompile mode)

#rb Laura.Hermanns

[CL 31354417 by dan elksnitis in ue5-main branch]
2024-02-09 15:54:26 -05:00
dan elksnitis
6f2fd10236 [shaders] remove shader compilation related code deprecated in 5.3
#rb massimo.tristano

[CL 31339246 by dan elksnitis in ue5-main branch]
2024-02-09 10:07:32 -05:00
dan elksnitis
a1e2aceb07 [shaders] add additional data (serialized env, cmdline, etc) to all copies of source dumped when "detailed source" debug dump option is enabled
#rb Jeremy.Moore

[CL 31293804 by dan elksnitis in ue5-main branch]
2024-02-08 11:35:29 -05:00