Commit Graph

297 Commits

Author SHA1 Message Date
Luke Thatcher
e6b40d3954 Major refactor of RHICreateShaderResourceView and RHICreateUnorderedAccessView functions - Merging //UE5/Dev-ParallelRendering (up to CL 24988990) to //UE5/Main
This changelist is a merge of work done in //UE5/Dev-ParallelRendering to remove tech debt in the SRV/UAV create functions. See individual changelist descriptions in that stream for further details, but a summary of the change is as follows:
 - We had multiple overloads of each of the RHICreateShaderResourceView and RHICreateUnorderedAccessView functions. Each function had a different set of supported view types and using them was complicated / ambiguous.
 - There's now only 2 create functions, and a common FRHIViewDesc descriptor struct, which is stored on the base view class.

 - FRHIView takes a reference on the underlying resource, ensuring that RHI views keep their viewed resource alive. This was not the case on some platforms, since it was previously the platform RHI implementation's responsibility.
 - Platform RHI implementations resolve an FRHIViewDesc into a full FViewInfo struct using GetViewInfo. This centralizes the logic for computing num mips / num slices / format etc so it is the same across all platforms.

 - Views must never be created with nullptr resources. This used to happen in the mesh streamer, but now all views require a real underlying resource. That resource can be a "BUF_NullResource" buffer, which is what the mesh streamer uses as a placeholder for buffers that have not streamed yet.
 - We will eventually replace FRHITextureReference with a "null texture", similar to how BUF_NullResource works for buffers. This is not yet implemented, so there is no "null view" of a texture currently.

#rb kenzo.terelst,jeannoe.morissette,dmitriy.dyomin
#preflight 643534642855180717af410e
#jira none

[CL 24989901 by Luke Thatcher in ue5-main branch]
2023-04-11 08:59:21 -04:00
zack neyland
be4e1f0887 Metal: Add experimental Nanite support for M2 based devices.
#jira UE-182683
#preflight https://horde.devtools.epicgames.com/job/64309adf2855180717cd4332
#rb Josh.Adams
#p4v-cherrypick 24968466

[CL 24972129 by zack neyland in ue5-main branch]
2023-04-07 19:00:54 -04:00
dan elksnitis
3df31bd37f [shaders] deprecate FShaderCompilerEnvironment::RemoteServerData field; since backend-specific remote compile functionality was removed (see https://p4-swarm.epicgames.net/changes/13777670) this is only used for adding unnecessary ifdef'd out debug info to associated shaders.
#rb Laura.Hermanns
#preflight 642735ab486e7cce7dd5b388

[CL 24877333 by dan elksnitis in ue5-main branch]
2023-03-31 15:51:46 -04:00
dan elksnitis
49d7985a85 [shaders] Add "compile argument" functionality for generic parameters consumed by compile backends, along with helper to set both a compile arg AND define for cases which require both. The purpose of this is to move towards enforcing that preprocessor defines should _only_ be used during the preprocessing phase itself; the subset of defines that are currently used only as arguments to the compile backends (or used as both actual preprocessor defines and backend arguments) should use this mechanism instead. This allows us to explicitly identify and hash such parameters to be included in a stable key based primarily on a hash of preprocessed/deadstripped source; without it we would need to hash all defines which will defeat most of the deduplication benefit of doing this. A subsequent change will deprecate the GetDefinitions function on the shader compilation environment to enforce that defines cannot be read by anything outside of core shader system functionality.
#rb Massimo.Tristano
#rb Laura.Hermanns
#preflight 64258c2e5e52099fe3d03625

[CL 24854110 by dan elksnitis in ue5-main branch]
2023-03-30 10:47:09 -04:00
dmitriy dyomin
bf4ed820ba Fixed: Flickering artifacts occur in the Mobile Game Project on iOS.
Make sure iOS vertex shaders are compiled with PreserveInvariance option set
#jira UE-179372
#rb jack.porter
#preflight 6412df4cd0208e8564bbb732

[CL 24671983 by dmitriy dyomin in ue5-main branch]
2023-03-16 11:40:36 -04:00
calvin zheng
9f3db54591 Update Apple metal version string format to match latest
#rb Carl.Lloyd, Zack.Neyland
#preflight 640a46ab482188d710be6062

[CL 24581974 by calvin zheng in ue5-main branch]
2023-03-09 16:06:24 -05:00
calvin zheng
a83747d71a Reducing metal version check in shader cache key to major version only, this will reduce shader compiling time on user machines with a different Xcode version.
Repurpose XcodeVersionInShaderVersion into UseFullMetalVersionInShaderVersion, setting this to true will force shaders to rebuild for each new Xcode version (reverting to previous behaviour)

#jira UE-179011
#rb Zack.Neyland, Arciel.Rekman, Carl.Lloyd
#lockdown Rolando.Caloca
#preflight 6402755daa00423335e22d0f

[CL 24525802 by calvin zheng in ue5-main branch]
2023-03-06 13:21:17 -05:00
devin doucette
5f370d9b86 Fixed static analysis warnings exposed by the log macro refactor
#jira none
#preflight 63fcd0adc35a141980f70d99
#rb Zousar.Shaker
#rnx
#lockdown zousar.shaker

[CL 24425468 by devin doucette in ue5-main branch]
2023-02-27 12:00:24 -05:00
Laura Hermanns
5a8a3b3063 Unify shader debug name in shader code output for DXC backends to improve cache hits.
The shader code output contains a little bit of plaintext such as I/O identifiers and the shader name, which was generated for the DXC backend in a way that prevents caching.
This unifies the shader name in the output code and improves the cache hit ratio for a Lyra cook from 0% to roughly 50% cache hits (for certain platforms).

#rb Jason.Nadro, Carl.Lloyd
#fyi Brian.White, Arciel.Rekman, Brandon.Schaefer
#jira FORT-548603
#preflight 63e26c6c07207b2570ba2d5b
#rnx

[CL 24050212 by Laura Hermanns in ue5-main branch]
2023-02-07 11:15:47 -05:00
Yuriy ODonnell
1dfc32d42d Enable r.Shaders.RemoveDeadCode by default for all back-ends except Metal and OpenGL
* Significantly reduces the size of shader debug data and improves shader compilation time (reducing parsing cost in the native shader compiler)
* Remove "experimental" label for the feature

#rb Jason.Nadro
#preflight 63d455d9be1970f8824c3f9b

[CL 23894592 by Yuriy ODonnell in ue5-main branch]
2023-01-27 18:24:18 -05:00
zack neyland
e8eb20415f MetalRT: Laying initial groundwork, disabled by default.
* Enabling requires re-building a metalpp with appropriate flags/defines set along with an OS version that supports the RT headers/libs.

#preflight 63c72f1a0225f00e14c05c46
#jira none

[CL 23750025 by zack neyland in ue5-main branch]
2023-01-17 19:53:36 -05:00
Wei Liu
e9b19b0a8e Fix a crash in FShaderCode::GetWriteAccess when r.Shaders.ExtraData=1 on mac.
#jira none

#rb Dmitriy.Dyomin, Carl.Lloyd
#preflight 63b8b79c763c6c10646417f1

[CL 23605837 by Wei Liu in ue5-main branch]
2023-01-06 19:27:11 -05:00
Yuriy ODonnell
bddca76c94 ShaderMinifier - Add support for dead code removal to all shader formats
* Add code to all shader format back-ends to take dead code removal into account when computing the version ID
* Not enabled in Metal and OpenGL back-ends (require further testing)

#rb dan.elksnitis
#preflight 6390f1f15c5308d18c7364fb

[CL 23433448 by Yuriy ODonnell in ue5-main branch]
2022-12-07 15:13:42 -05:00
christopher waters
b986207a34 Moving some RHI types into their own headers:
- DataDrivenShaderPlatformInfo
- ERHIFeatureLevel
- EShaderPlatform

#rb florin.pascu
#preflight 638589464004f73f629ee0b0

[CL 23314007 by christopher waters in ue5-main branch]
2022-11-29 13:36:02 -05:00
zack neyland
0eeb3732f1 Various misc fixes for Mac.
* Sets the Min/Max Wave Size
* Handles Vulkan headers and Mac a bit better
* Handles missing [shader] toolchains a bit better.

#preflight 63603e161622fbf582db4e07
#jira na

[CL 22920245 by zack neyland in ue5-main branch]
2022-11-02 13:10:22 -04:00
dan elksnitis
ecab3b4a9a [shaders] refactor usf/directcompile.txt dump into a utility in ShaderCompilerCommon to reduce code duplication in the shader backends
#rb Jason.Nadro
#rb Christopher.Waters
#preflight 635bf1e1df01edd149f5727e

[CL 22829548 by dan elksnitis in ue5-main branch]
2022-10-28 11:45:49 -04:00
christopher waters
f5ff98f2e1 ShaderParameterParser cleanup
- Making ConstantBufferType a constructor only argument. This removes the duplicated logic of calling ShouldUseStableConstantBuffer.
- Moving ShouldUseStableConstantBuffer to ShaderCompilerCommon.
- Made UE::ShaderCompilerCommon::ParseParameterType array arguments const

#jira UE-166341
#rb Guillaume.Abadie
#preflight 634eeceea1527f6b3bda9ff0

[CL 22608320 by christopher waters in ue5-main branch]
2022-10-18 15:25:05 -04:00
zack neyland
a195870a3a Fixing regression with metal shader versions bumps. Temporarily roll back MacOS to 2.2/2.3.
#jira UE-167179
#preflight 634d80b4305a762e7e40c8af
#rb adam.kinge
#lockdown rolando.caloca

[CL 22573078 by zack neyland in ue5-main branch]
2022-10-17 15:14:11 -04:00
richard wallis
8d24dcd6ee Add -fpreserve-invariance for Vertex shaders for Metal versions above 2.2. macOS only: Reinstate Metal versions 2.2 and 2.3 to work round what appears to be a M1 position invariance compiler bug.
#jira UE-164360
#preflight 63443b667045f13c96bda936
[REVIEW] [at]zack.neyland, [at]axel.riffard, [at]jack.porter, [at]adam.kinge

[CL 22509223 by richard wallis in ue5-main branch]
2022-10-13 14:40:48 -04:00
jason nadro
5ec1160356 Adding Total Thread Preprocess Time for shader compilation.
- Instrument how long shader preprocessing takes for each shader compilation job.
- Keep a running total in our shader stats per shader type.
- Add logging to track total thread preprocessing time for all shaders.
- Fixup local variable names to match the output log names.

#rb Dan.Elksnitis
#preflight 632a224ab40000c8f08c5815

[CL 22125080 by jason nadro in ue5-main branch]
2022-09-21 17:34:15 -04:00
axel riffard
b701c98a7e Set Metal minimum flow for iOS and MacOS
#jira UE-163352
#rb adam.kinge
#preflight 632954d3fc7f1efbdf238155

[CL 22089354 by axel riffard in ue5-main branch]
2022-09-20 03:10:30 -04:00
axel riffard
c64aa2de93 Catalina, iOS 14 removal
Metal 2.3 removed, Metal 3.0 added for Mac

#jira UE-163352
#rb adam.kinge bertrand.carre
#preflight 631ea7eb94758d0bf2008668

[CL 21960671 by axel riffard in ue5-main branch]
2022-09-11 23:47:08 -04:00
axel riffard
494b98c831 Remove Catalina support and Metal 2.2 from Mac.
#jira UE-149923
#rb jack.porter
#preflight 6315c60bf448dc6e58121822

[CL 21790515 by axel riffard in ue5-main branch]
2022-09-05 06:05:22 -04:00
Richard Wallis
5f67dcf13c Apply patch from Apple. Enable WaveOps for macOS - tested on Vega 56 Monterey 12.5.1
#jira none
#rnx
#preflight 6310b4d7ea685939704c090a
#review-21739599 @zack.Neyland
#rb zack.Neyland

[CL 21756741 by Richard Wallis in ue5-main branch]
2022-09-02 04:26:05 -04:00
Laura Hermanns
bbb62728d4 Strip [[clang::optnone]] attribute from Metal shaders due to performance hit with WPO on M1 Macs.
#rb Will.Damon
#fyi MarcAndre.Lalonde
#jira none
#preflight 62f56422f3107c023cc15341
#rnx

[CL 21344324 by Laura Hermanns in ue5-main branch]
2022-08-11 16:27:00 -04:00