329 Commits

Author SHA1 Message Date
carl lloyd
f1f8c9300a Added support for Metal Shader Converter with Bindless in MetalRHI
- Available on SM6
 - Disabled with config
 - Includes support for heap allocations on Metal, enabled by default, can be disabled with -nometalheap

#rb Luke.Thatcher, Chris.Waters, Laura.Hermanns
#jira UE-204112

[CL 31527528 by carl lloyd in 5.4 branch]
2024-02-15 13:52:54 -05:00
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
carl lloyd
511833e664 Added Texture atomic array flattening for TSR to SM5
#rb Jon.Cain

[CL 31287364 by carl lloyd in 5.4 branch]
2024-02-08 07:10:21 -05:00
aris theophanidis
8ae2292282 Remove Compression.h from CoreMinimal.h
It's about 1/4 of CoreMinimal.h but rarely needed (Compression.h pulls on CriticalSection.h and Map.h that are costly).
#rb Yoan.StAmant

[CL 30683417 by aris theophanidis in ue5-main branch]
2024-01-18 09:56:55 -05:00
dan elksnitis
3dc719a6f7 [shaders] fix IOS path to not assume ShaderConductor ignores nulls when loading source; I don't think this is an obvious or desirable choice in the API (despite the fact that changing this behaviour in my SC refactoring was unintentional)
#jira UE-203997
#rb Laura.Hermanns

[CL 30660432 by dan elksnitis in ue5-main branch]
2024-01-17 11:48:03 -05:00
yuriy odonnell
01419a8913 Add strongly typed EShaderOptionalDataKey to access shader optional data instead of adhoc characters
#rb carl.lloyd, christopher.waters, Colton.Daniels

[CL 30572888 by yuriy odonnell in ue5-main branch]
2024-01-11 13:36:32 -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
dan elksnitis
6ed653a189 [shaders] further preprocessing cleanup
- move sequence of preprocessing steps out of ShaderPreprocessor module and into UE::ShaderCompilerCommon::ExecuteShaderPreprocessingSteps; the former is now explicitly just the low-level preprocessor lib
- add an implementation of PreprocessShader in FBaseShaderFormat so backends which have no custom code to execute as part of preprocessing can just automatically inherit this implementation, and fix up such backends to eliminate now-unnecessary overrides

#rb christopher.waters, Laura.Hermanns

[CL 30178136 by dan elksnitis in ue5-main branch]
2023-12-07 08:55:41 -05:00
dan elksnitis
cc7c2c54f4 [shaders] shader format preprocessing cleanup & refactoring
- move uniform buffer cleanup and dead stripping into ShaderPreprocessor module's PreprocessShader function
- add "required symbols" to compiler input struct to specify additional symbols to keep during minification aside from those specified by the entrypoint; modify API such that both an entry point string and additional symbols can be specified (to avoid each backend needing to manually parse the compound RT entry point string)
- make use of ModifyShaderCompilerInput in all backends to set additional defines and required symbols on input struct up front; only use the AdditionalDefines map in cases where it's actually necessary
- remove the various per-platform defines for enabling minifier, no longer required now that this has been rolled out for all backends
- fix SCW directcompile mode; this had rotted due to pieces of the FShaderCompilerEnvironment having been added that weren't explicitly serialized to either cmdline or in the shader source. this now serializes as a base64 string written inside the USF containing all portions of the environment required for compilation (using the same serialization function as is used to write/read the SCW input file)
- use a debug flag for indicating we're in "direct compile" mode and should load the debug USF off disk, rather than the poorly named "bSkipPreprocessedCache" (this name is both inaccurate and also confusing due to the addition of the preprocessed job cache)
- modify platform "force wave32" mechanism to use a pragma directive to set a compiler define, instead of doing string replacement in the preprocessed source
- add a view version of the RT entrypoint parsing to use in preprocessing, note that other paths still need to construct fstrings due to further manipulation so keeping the FString path around too
- clean up backends manually checking the "directcompile" cmdline arg

#rb christopher.waters, Yuriy.ODonnell
#rb Chris.Waters
#rb Laura.Hermanns

[CL 30023082 by dan elksnitis in ue5-main branch]
2023-11-30 15:56:34 -05:00
marc audy
d2eef2ac23 Properly disable 510 for UE_LOG
Fix/silence handful of additional warnings
#rnx

[CL 29707387 by marc audy in ue5-main branch]
2023-11-14 02:24:24 -05:00
christopher waters
6f3f63b186 Bindless Conversion Changes
- Removing the need for COMPILER_DEFINE on GetResourceFromHeap and GetSamplerFromHeap
- FShaderParameterParser constructor now requires a FPlatformConfiguration object that each shader format can configure.
- FPlatformConfiguration::GenerateBindlessAccess allows each platform to generate the code for accessing a bindless resource or sampler.
- Added EShaderParameterParserConfigurationFlags to specify support for stable constant buffers and bindless.
- Moved EBindlessParameterMode into EShaderParameterParserConfigurationFlags::BindlessUsesArrays
- While moving things around, I was able to convert some TCHAR* uses to FStringView

#jira UE-166341
#rb mihnea.balta

[CL 29533376 by christopher waters in ue5-main branch]
2023-11-07 16:26:20 -05:00
christopher waters
a1af36037f Shader versioning cleanup
- Changing all shader versions to Guid.
- Fixing shader version guids in shaders to not be in comments.
- Adding a shader version to RayTracingCommon.ush.

#rb dan.elksnitis, Jason.Nadro, Yuriy.ODonnell, Laura.Hermanns

[CL 29168287 by christopher waters in ue5-main branch]
2023-10-26 23:06:40 -04:00
dan elksnitis
54fb5cf56d [shaders] further deprecation (SupportsIndependentPreprocessing/OptionalFinalShaderSource/bIndependentPreprocessed are no longer needed since all backends are migrated)
#rb Laura.Hermanns

[CL 29117027 by dan elksnitis in ue5-main branch]
2023-10-25 22:21:30 -04:00
jason hoerner
0e18ea7e81 Shader Preprocessor: Roll TEXT macro substitution into the C preprocessor step, via custom macro callback feature, making it effectively free. Saves 3% overall on preprocess, but also represents a simplification by reducing the number of unique preprocess passes.
#jira UE-198496
#rnx
#rb dan.elksnitis yuriy.odonnell jason.nadro

[CL 29100104 by jason hoerner in ue5-main branch]
2023-10-25 16:01:11 -04:00
christopher waters
6797229f23 Moving more platforms to use ShaderParameterParser in the compile step.
#rb Jason.Nadro
#jira UE-197328

[CL 28655234 by christopher waters in ue5-main branch]
2023-10-11 03:20:39 -04:00
christopher waters
bb0a274b8c Reworking UniformBuffer code generation to not use an intermediate struct
- When generating Uniform Buffer HLSL code, a 'static const struct {} Name' was created which has been causing compiler issues off and on for years.
- When RemoveUniformBuffersFromSource removed said struct, it parsed the struct's structure to figure out how to translate UniformBuffer.Member into UniformBuffer_Member in code that accessed Uniform Buffers.
- Now, instead of a struct, a "UniformBuffer <Name>" declaration is created and filled with mappings from "UniformBuffer.Member" into the correct code.
- This allows ConstantBuffer objects to be used differently from cbuffer where the former generates "UniformBuffer.Member" and the latter generates "UniformBuffer_Member"
- This also allows resources to always be translated to "UniformBuffer_Member"
- Shader define 'PLATFORM_SUPPORTS_UB_STRUCT' is now 'PLATFORM_SUPPORTS_CONSTANTBUFFER_OBJECT' and will be set on shader formats that support ConstantBuffer<> objects.
- Removed lots of unused code from BindlessResources.ush

#jira UE-195103
#rb dan.elksnitis, jeannoe.morissette

[CL 28058373 by christopher waters in ue5-main branch]
2023-09-20 17:33:36 -04:00
carl lloyd
802f14d2bf Change Texture2DArray's to flatten by texture name instead of using shader names.
#rb jeannoe.morissette

[CL 27823019 by carl lloyd in ue5-main branch]
2023-09-13 05:09:45 -04:00
dan elksnitis
df634c7352 [shaders] metal shader format: enable minifier and migrate to independent preprocessing API
#rb Laura.Hermanns

[CL 27631995 by dan elksnitis in ue5-main branch]
2023-09-06 09:24:57 -04:00
adam kinge
06a3585301 Required Metal shader compiler changes to support iOS Simulator. Set to disabled by default via "bEnableSimulatorSupport" in IOSRuntimeSettings.
#jira UE-168571
#rnx
#rb carl.lloyd, jack.porter
#lockdown jack.porter

[CL 27022463 by adam kinge in ue5-main branch]
2023-08-11 01:01:38 -04:00
david harvey
da9b5b86f5 Do not include PreWindowsApi.h / PostWindowsApi.h directly in code.
- mostly just replacing them AllowWindowsPlatformTypes.h / HideWindowsPlatformTypes.h
 - some other files had both Pre/PostWindowsApi.h and Allow/HideWindowsPlatformTypes.h, so just removed
 - some occasional include order changes.

#jira UE-152863
#rnx
#rb Devin.Doucette

[CL 26985385 by david harvey in ue5-main branch]
2023-08-10 03:34:53 -04:00
david harvey
bdb4199eeb Remove unnecessary WindowsHWrapper.h & MinWindows.h include - both files will be automatically included by AllowWindowsPlatformTypes.h
#jira UE-152863
#rnx
#rb Josh.Adams

[CL 26912096 by david harvey in ue5-main branch]
2023-08-08 05:50:53 -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
dan elksnitis
5f85b46590 [shaders] remove unnecessary passing of hlslcc flags as an option to debug info output. this was just used to pass a switch on the SCW directcompile cmdline which SCW no longer does anything with. also cleaned up some additional unnecessary code related to these flags in backends that no longer use hlslcc at all.
#rb Laura.Hermanns

[CL 26685354 by dan elksnitis in ue5-main branch]
2023-07-28 15:58:01 -04:00
joe kirchoff
d31b8ce8a3 Resolve several module public include paths not using references
#rnx

[CL 26558470 by joe kirchoff in ue5-main branch]
2023-07-24 18:35:16 -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