51 Commits

Author SHA1 Message Date
carl lloyd
c1edfa3ade Added support for Metal Shader Converter to Metal
- Disabled by default
    - Removed MetalDerivedData and moved shader compiler specific code to seperate files

#rb Laura.Hermanns
#jira UE-204112

[CL 31524725 by carl lloyd in 5.4 branch]
2024-02-15 12:38:42 -05:00
christopher waters
d090f2823b Removing extra '\0' from files output from ShaderConductor.
DxcCreateBlob apparently force adds this on creation of strings, so we need to account for that when creating a view of the result.

#rb dan.elksnitis, Laura.Hermanns

[CL 31306629 by christopher waters in 5.4 branch]
2024-02-08 16:59:53 -05:00
dan elksnitis
f230a0d2d0 [shaders] shaderconductorcontext improvements:
- add support to shaderconductor to load shader source from a FAnsiStringView
- remove internal string conversion helpers in favour of using FAnsiString
- don't make copies of input strings if they are provided in ANSI format

#rb Laura.Hermanns

[CL 30594203 by dan elksnitis in ue5-main branch]
2024-01-12 11:06:50 -05:00
dan elksnitis
a9037b25ed [shaders]
- add FShaderSource class which wraps source as populated by preprocessing and subsequently accessed by compilation and other debug features; this class automatically inserts zeroed padding such that 16-byte-wide SIMD string comparison operations do not require a non-SIMD tail to process any overhang.
- add typedefs for the string/view/character types and update preprocessing code to use these typedefs instead of the explicit types
- add explicit if constexprs in minifier code around char width to disable simd optimizations for char width != 2 (and subsequently skip the non-simd tail if char width == 2 since FShaderSource automatically adds the required padding)

#rb Jason.Nadro, Yuriy.ODonnell

[CL 30358137 by dan elksnitis in ue5-main branch]
2023-12-15 15:28:27 -05:00
laura hermanns
d6acdc4eab Make DXC compile arguments consistent between Vulkan backend and CompileDXC.bat script.
#jira UE-198594
#rb Dan.Elksnitis
#rnx

[CL 29569710 by laura hermanns in ue5-main branch]
2023-11-08 14:23:36 -05:00
serge bernier
9ce7402b1f Support INVARIANT on platform using DXC-SPIRV
-Add a new define to wrap the output semantic that we want to be post declare as precise.
-Modify DXC-SIRV to add the NoContraction decorator on precise output semantics.
-Modify spirv_glsl to post declare as precise output semantics
  -Example: out precise float4 gl_positon; will add precise gl_position; post declaration.

[REVIEW] [at]laura.hermanns

[CL 29338529 by serge bernier in ue5-main branch]
2023-11-01 19:14:21 -04:00
christopher waters
0403f2caa0 Always set the HLSL version and don't assume the default is 2018.
#rb David.Harvey, Yuriy.Odonnell

[CL 28692390 by christopher waters in ue5-main branch]
2023-10-11 19:52:44 -04:00
laura hermanns
f9b3974ab9 Platform-specific DXC improvements:
- Avoid explicit FMA instructions in platform-specific GLSL to let backend-compiler decide when to use them.
- Fix code refelction when using SPIR-V directly with backend-compiler.
- Define preset of SPIR-V optimization passes to reduce nested expressions "preset(relax-nested-expr)".

#rb Serge.Bernier, Brian.White
[FYI] Graeme.Thornton, Jason.Nadro, Carl.Lloyd, Florin.Pascu, Michael.WAnderson
#jira UE-195236, UE-194869

[CL 27994871 by laura hermanns in ue5-main branch]
2023-09-19 10:25:17 -04:00
laura hermanns
d7fff598d5 Allow passing custom SPIV-V optimization passes to ShaderConductor. This allows us to control more fine-grained what optimization passes work best for certain render passes on different platforms.
#rb Serge.Bernier
[FYI] Carl.Lloyd, JeanNoe.Morissette
#rnx

[CL 27880727 by laura hermanns in ue5-main branch]
2023-09-14 11:39:49 -04:00
louisphilippe seguin
a11435338f Fix usage of const TCHAR* in the condition of checkf or ensureMsgf and test the strings for nullptr instead
#rb trivial
#rnx

[CL 27427505 by louisphilippe seguin in ue5-main branch]
2023-08-28 17:50:38 -04:00
jeannoe morissette
235b6cbfd3 VulkanRHI: Actually enable scalar_block_layout in raytracing and sm6 shaders to fix multiple alignment issues. Rename ReflectionSlot param to align with ShaderCommon code.
#rb carl.lloyd
#jira UE-171798
#rnx

[CL 27399055 by jeannoe morissette in ue5-main branch]
2023-08-25 22:19:15 -04:00
dan elksnitis
9a5a1b6f74 [shaders] minor include cleanup
#rb Jason.Hoerner
#rb Laura.Hermanns

[CL 26817718 by dan elksnitis in ue5-main branch]
2023-08-03 13:40:32 -04:00
jason hoerner
7f22080814 Shader Compiler: Made FShaderCompilerDefinitions private, to reduce code publicly visible in ShaderCore.h. For now, it's just marked deprecated for 5.4, but will be hidden more generally in 5.5.
#rnx
#rb yuriy.odonnell dan.elksnitis jason.nadro

[CL 26534998 by jason hoerner in ue5-main branch]
2023-07-22 06:35:10 -04:00
guillaume abadie
fb96324861 Adds bSupportsRealTypes=RuntimeDependent in Vulkan SM5 and SM6
#rb jeannoe.morissette
#jira UE-179496

[CL 26269642 by guillaume abadie in ue5-main branch]
2023-06-27 16:32:12 -04:00
jason hoerner
e1fe70dbca Shader Compiler: GlobalBeginCompileShader define optimizations, plus a few other micro-optimizations, producing a 3.2x performance improvement.
* Major define optimization involves converting map of defines to use FName keys and variant values rather than strings -- this eliminates most of the cost of string hashing, allocation, and conversion.
* Lower overhead FHashTable used instead of TMap.
* An initial map of defines can optionally be provided globally.  Anything using an initial define can have its map index cached for optimized lookup when reading or writing.

Other micro-optimizations:
* Added Reserve calls for uniform buffer related maps, to eliminate map resizing / rehashing.  Saved around 15% perf (after define optimizations).
* Added a map for UB lookup, instead of iterating through the linked list.  Saved around 10% perf.

Non-optimization:  Sort the order in which uniform buffer variable names are searched in BuildShaderFileToUniformBufferMap, to create determinism in ShaderDebug data for A/B testing (previously order was dependent on global constructor order for UB definitions, which could vary arbitrarily with unrelated changes).

#jira UE-187334
#rnx
#rb dan.elksnitis jason.nadro yuriy.odonnell

[CL 26142884 by jason hoerner in ue5-main branch]
2023-06-21 03:26:02 -04:00
Laura Hermanns
b8c526c389 DXC and SPIRV-Cross fixes to enable Substrate in D3D11:
- Support structured buffers in HLSL backend of SPIRV-Cross (PR #2143).
- Integrate SPIRV-Cross fix to forward opaque types in GLSL backend (PR #2110).
- Integrate SPIRV-Cross fix to use actual field offset to validate vec4 boundary alignment (#PR 2139).
- Integrate SPIRV-Cross fix to not restrict SV_RenderTargetArrayIndex to GS and MS (#PR 2138).
- Make SV_Position decoration as implicitly invariant optional (Used to address Z-fighting issues in Vulkan and Metal; Drastically impacts vertex shader performance on certain platforms).
- Don't force DXC for all shaders when r.Substrate is enabled.

#jira UE-174555
#rb Sebastien.Hillaire, Carl.Lloyd, Dan.Elksnitis
#fyi Brian.White, Jason.Nadro, JeaNoe.Morissette, Yuriy.Odonnell, Guillaume.Abadie
#preflight 6453d3df0e33f2d51d2b032e

[CL 25353473 by Laura Hermanns in ue5-main branch]
2023-05-05 09:21:36 -04:00
jeannoe morissette
efa00a9cb5 OpenGL: Avoid StorageImageWriteWithoutFormat SPIRV capability when compiling shaders for GL by adding a "-fvk_force_storage_image_format" flag that brings back old behavior (promote 3-component UAV to 4-component instead of using Unknown format). (author: Carl.Lloyd)
Broken since 24910389.

#rb Florin.Pascu,Carl.Lloyd
#fyi Laura.Hermanns,Dmitriy.Dyomin
#preflight 6442c73d0171aae0b1c6e85e
#jira UE-183868,UE-183432
#rnx

[CL 25149146 by jeannoe morissette in ue5-main branch]
2023-04-21 13:52:26 -04:00
jeannoe morissette
279e3fe462 VulkanRHI: Add Vulkan_1_3 support for shader compilation. (WIP towards VULKAN_SM6)
#fyi laura.hermanns, carl.lloyd
#preflight 641b05eb32723d4a200be648
#rnx

[CL 24747522 by jeannoe morissette in ue5-main branch]
2023-03-22 10:40:26 -04:00
laura hermanns
bcf95545bd Add host machine name to OOM report in DXC backend and refactor global SCW error-code handling. Bumped ShaderCompileWorkerOutputVersion to 9.
#rb Jason.Nadro, Dan.Elksnitis, Yuriy.Odonnell, Arciel.Rekman
#preflight 638e610c255f07df8ea212f4
#rnx

[CL 23428544 by laura hermanns in ue5-main branch]
2022-12-07 10:29:08 -05:00
kate ellis
839f9f1889 [Backout] - CL23401851
[FYI] Laura.Hermanns
Original CL Desc
-----------------------------------------------------------------
Add host machine name to OOM report in DXC backend and refactor global SCW error-code handling.

#rb Jason.Nadro, Dan.Elksnitis, Yuriy.Odonnell, Arciel.Rekman
#preflight 638e610c255f07df8ea212f4
#rnx

[CL 23421737 by kate ellis in ue5-main branch]
2022-12-06 19:47:06 -05:00
laura hermanns
c17b2976f9 Add host machine name to OOM report in DXC backend and refactor global SCW error-code handling.
#rb Jason.Nadro, Dan.Elksnitis, Yuriy.Odonnell, Arciel.Rekman
#preflight 638e610c255f07df8ea212f4
#rnx

[CL 23421619 by laura hermanns in ue5-main branch]
2022-12-06 19:45:07 -05:00
axel riffard
105479f091 Fix Metal 3.0 shader compilation on iOS
#rb jack.porter
#jira UE-166909
#preflight 6385cd67d76995cb142c0695

[CL 23303343 by axel riffard in ue5-main branch]
2022-11-29 05:55:31 -05:00
dan elksnitis
b81ae6648c [shader compilation] changes to error handling in ShaderCompileWorker
- each platform compilation request is now wrapped in __try/__except rather than a single exception handling block at the top level of the worker; this allows us to log an exception (with callstack) as a compilation error and continue the batch
- remove SEH code from ShaderConductorContext, the above makes this redundant (and it didn't provide any actionable information)
- strip down SEH code in D3DShaderCompiler; now only used for the purposes of pre-compiling with DXC in the case of an FXC crash. dumping preprocessed source will be handled in a different manner in a forthcoming CL
- minor change in the DXC precompile path to not log an unnecessary warning when performing an explicitly-requested DXC precompile

#rb Jason.Nadro
#rb Laura.Hermanns
#rb Yuriy.ODonnell
#preflight 63514c798176062ea73acb41
#jira FORT-524383

[CL 22654436 by dan elksnitis in ue5-main branch]
2022-10-20 09:43:50 -04:00
carl lloyd
379853c1ea Added new android patch pass to fix driver crashes on Adreno devices running Android 10
#rb Laura.Hermanns
#preflight 625540723f5641db59e7628a

[CL 19718421 by carl lloyd in ue5-main branch]
2022-04-12 05:31:35 -04:00
Lukas Hermanns
999fb99c6c Enable HLSL 2021 language version (CFLAG_HLSL2021) in shader compiler backends.
#rb Guillaume.Abadie, Will.Damon
#fyi Carl.Lloyd, Ryan.Vance, Christopher.Waters, Mihnea.Balta, Rolando.Caloca, Yuriy.ODonnell, Graham.Wihlidal
#jira UE-138358
#preflight 6227b6b3c653e7ef9f571dc8

[CL 19319858 by Lukas Hermanns in ue5-main branch]
2022-03-09 09:47:28 -05:00