Commit Graph

254 Commits

Author SHA1 Message Date
steve robb
6d5b974842 Fixed up a lot of bool-taking container resize functions to take EAllowShrinking instead.
[CL 30735396 by steve robb in ue5-main branch]
2024-01-19 19:41:56 -05:00
dan elksnitis
89776aba21 [shaders] add ANSICHAR path for FShaderSource and enable by default
#rb Yuriy.ODonnell, Laura.Hermanns
#jira UE-196110

[CL 30632304 by dan elksnitis in ue5-main branch]
2024-01-16 09:15:51 -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
christopher waters
aaeb9ff464 Fixing Vulkan compiles on Mac.
[CL 30166357 by christopher waters in ue5-main branch]
2023-12-06 15:35:23 -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
laura hermanns
3ae332cccb Only check empty SPIR-V module when compilation was reported as successful.
#rb JeanNoe.Morissette
#rnx

[CL 29827128 by laura hermanns in ue5-main branch]
2023-11-17 19:47:08 -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
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
jeannoe morissette
8a024170db VulkanRHI: Fix Vulkan bindless and RT heap prefix issues.
#rb none
#rnx

[CL 29168365 by jeannoe morissette in ue5-main branch]
2023-10-26 23:07:24 -04:00
christopher waters
5c304ed095 Removing FShaderParameterParser from FShaderPreprocessOutput.
#jira UE-197328
#rb dan.elksnitis

[CL 29168356 by christopher waters in ue5-main branch]
2023-10-26 23:07:19 -04: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
ab21e17d39 Bindless Resources
- Splitting "Bindless Resource" shader parameter types into "Bindless SRV" and "Bindless UAV" to make sure reflection/binding validation is correct.

#jira UE-166341
#rb jeannoe.morissette

[CL 28995862 by christopher waters in ue5-main branch]
2023-10-20 23:12:44 -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
jeannoe morissette
f30a320eeb VulkanRHI: Fix Vulkan bindless and ray tracing shader compilation to work with new UB generation code.
#rb none
#jira UE-171798
#rnx

[CL 28125266 by jeannoe morissette in ue5-main branch]
2023-09-22 04:12:24 -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
jeannoe morissette
b7c12c8b0e VulkanRHI: VK RT WIP: Use tighly packed indices for the bindless UBs in the shader parameters, and at runtime use ConstantDataOriginalBindingIndex to write the handle in the correct slot.
#rb none
#jira UE-171798
#rnx

[CL 27409804 by jeannoe morissette in ue5-main branch]
2023-08-28 09:44:39 -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
carl lloyd
34d53bc691 Added validation to ensure UAV/SRV types and UB sizes match the ones generated by the shader compiler
#rb jeannoe.morissette
#jira UE-82353

[CL 27399050 by carl lloyd in ue5-main branch]
2023-08-25 22:19:10 -04:00
jeannoe morissette
ec701f8ca4 VulkanRHI: VK RT WIP: Shader compiler changes for Vulkan RT. Add an option for extra blobs for AnyHit and Intersection shaders in HitGroup. Add option of bindless UBs for ray tracing shaders. Correctly set GRHISupportsRayTracingDispatchIndirect.
#rb Aleksander.Netzel
#jira UE-190075
#rnx

[CL 27231539 by jeannoe morissette in ue5-main branch]
2023-08-19 19:17:32 -04:00
jeannoe morissette
e97f023224 VulkanRHI: Add handling of multiple entrypoints for RayHitGroup shaders (VK RT WIP, does not change current output)
#rb carl.lloyd
[FYI] aleksander.netzel
#jira UE-171798
#rnx

[CL 27209304 by jeannoe morissette in ue5-main branch]
2023-08-18 13:12:21 -04:00
jeannoe morissette
4e65bdc179 VulkanRHI: Start adding code in VulkanShaderCompiler to track bindless UB and handle RootParametersStructure. (VK RT WIP, disabled for now)
#rb none
#jira UE-171798
#rnx

[CL 27185944 by jeannoe morissette in ue5-main branch]
2023-08-17 17:14:45 -04:00
jeannoe morissette
150748bbaa VulkanRHI: (VK RT WIP) Move all serialized parameter of the shader compilation process into a struct together (Header, SRT, Spirv).
#rb none
#jira UE-171798
#rnx

[CL 27151506 by jeannoe morissette in ue5-main branch]
2023-08-16 15:44:45 -04:00