2855 Commits

Author SHA1 Message Date
Sebastien Hillaire
80d0af3da8 Substrate - fix for crash on mac when clearing MRTs with integer format.
#jira UE-228298
#rn Fixed Substrate crash on MAC when opening material editor.
#tests Tested PC editor, dx11, dx12 and ps4, with and without Substrate. And on MAC by Carl Lloyd.
#rb carl.lloyd, Kevin.Ortegren
#fyi charles.derousiers

[CL 38210001 by Sebastien Hillaire in 5.5 branch]
2024-11-19 09:57:34 -05:00
mihnea balta
ec33fdf176 Turn off RDG async tasks due to bad interactions with the old GPU profiler system.
RDG async tasks reference GPU profiler queries. These queries are deleted in EndFrameRenderThread, but async tasks can run after that, resulting in use-after-free crashes.

#jira UE-228852 FORT-812395
#rnx
#rb Luke.Thatcher

[CL 37610608 by mihnea balta in 5.5 branch]
2024-10-30 12:33:41 -04:00
florin pascu
d41502c15d Temporary fix the Directory path for Encrypted paths for metallibs
#rb Arciel.Rekman, Laura.Hermanns, Peter.Sauerbrei

[CL 37219216 by florin pascu in 5.5 branch]
2024-10-17 05:53:38 -04:00
daniele pieroni
c72246904e Workaround for RHI validation error due to prologue pass issuing a fence along with all its transitions.
#jira UE-219098
#rnx

[CL 37168030 by daniele pieroni in 5.5 branch]
2024-10-16 05:44:42 -04:00
luke thatcher
77ddadb0fb Fix crashes on shutdown when using OpenGL RHI
- Some resource destructors were calling FRHICommandListImmediate::Get(), which will break since RHI resources are destroyed by the RHI thread.
 - Acquire the GL context on the game thread when the rendering thread is stopped. The render thread is destroyed before RHIExit is called, which can lead to the game thread attempting to destroy GL resources while not owning the context.
 - Add some extra cleanup to the legacy GPU profiler. Some resources were still alive.

#jira UE-226165
#rb Allan.Bentham, mihnea.balta

[CL 37116288 by luke thatcher in 5.5 branch]
2024-10-15 08:56:01 -04:00
zach bethel
3e78b68d24 Added explicit Pipe wait inside of RDG to avoid speculative race condition between task completion and clearing the active task in the pipe.
#rb none
#jira UE-226893

[CL 37052593 by zach bethel in 5.5 branch]
2024-10-11 11:51:53 -04:00
serge bernier
2e13d4bf7d Fix PreloadShaderMap when DynamicShaderPreloading is enable. Go through the preloadshader code path when we want to load the entire shadermap.This make sure we only increase the NumRef once and the reloadentry will be release when either we release the RHI shaders, destroy the material instance or we call ReleasePreloadShaderIfNecessary.
#rb daniele.vettorel

[CL 36942631 by serge bernier in 5.5 branch]
2024-10-08 14:49:35 -04:00
jason hoerner
d9124dc8b0 MGPU: Fixes for QAVirtualProduction test map. Change from push to pull cross GPU transfers. Push transfers seem to have been broken across the board by a recent driver change, as all the way back to Release 5.1 (where push transfers were first implemented and tested) is now broken as well. To make pull transfers relatively performant, it is necessary to gather them from each scene renderer, and do them all at once on the last scene renderer, otherwise the GPUs get serialized. Other fix is to make global RHI resource initialization masked to run on all GPUs -- the uninitialized resources caused calls to AddDrawScreenPass to render nothing.
#jira UE-226545
#rnx
#rb zach.bethel

[CL 36942295 by jason hoerner in 5.5 branch]
2024-10-08 14:42:37 -04:00
dan elksnitis
3783c8a50c [shaders] fix asan issue; eliminate lambdas for code serialization/reserve in serialization context subclasses in favour of virtual functions for clarity, add an explicit reset function to change internal state to point to different buffers. The code in the job cache path (processing duplicate completed jobs with the same load context) which constructed a temporary object and assigned to reset the internal pointers was creating a new lambda capturing the wrong "this" and assigning it to the original object.
#rb Jason.Nadro
#jira UE-226290

[CL 36937930 by dan elksnitis in 5.5 branch]
2024-10-08 13:04:55 -04:00
jeremie roy
feb7776b60 Fix UYVY color conversion.
24937677 introduced a regression, the UYVY to RGBA conversion used to be done by the UYVYConvertPS shader, which interpolates the chroma values using a bilinear sampler.
The change moved the UYVY conversion code to use YUVv216ConvertPS, which uses a point sampler by default.

This fix introduces an option (UseBilinearSampler) that dictates whether to use a bilinear sampler for the chroma values of the converter.

#jira UE-212498
#rb eric.renaudhoude

[CL 36905604 by jeremie roy in 5.5 branch]
2024-10-07 13:28:54 -04:00
eric renaudhoude
8ae8e594fd Media: Fixed color space transformation on HDR Electra videos.
The (optional) display mastering color space (usually used as a hints for the display devices) was incorrectly used as the sample source color space. Since we are linearizing to the working color space by default, display HDR metadata can be ignored. We also take this opportunity to cleanup the media sample color space interface, especially now that FColorSpace is in engine core. Furthermore, tonemapping is applied by on Electra HDR videos so that their (unlit or composited) default appearance resembles other media players.

This change also introduces two news console variables:
* Electra.HDR.WhiteLevel
* Electra.HDR.ToneMapMethod

#jira UE-221519
#rb dietmar.hauser, Jens.Petersam, Ruslan.Idrisov

[CL 36765643 by eric renaudhoude in 5.5 branch]
2024-10-01 20:56:27 -04:00
charles derousiers
adb3fcb44c Fix Substrate shader compilation issue when running -featureleveles31 with material having glints.
The glints code causes unrolling issue. Glints are normally disabled throught the platform settings, but when running with -featureleveles31, these settings are not taken into account. This CL disabled explicitely glints on platform lower than SM5.

#rb Sebastien.Hillaire
#jira UE-226153

[CL 36765472 by charles derousiers in 5.5 branch]
2024-10-01 20:54:08 -04:00
luke thatcher
688cf615f5 Restore fix for frame sync issues that was backed out in 36633942, but without the changes to FPendingCleanupObjects
- Only the additional RHI thread fences are inserted by FFrameEndSync::Sync.
 - Since we are still fencing the game and render threads to be no more than 1 frame apart, the original FPendingCleanupObjects mechanism should still work.

Original CL desc:

Fix frame sync issues
 - The engine still uses legacy syncing behaviour where the game thread syncs with the render thread. Renderer refactors have removed most of the RHI thread flushes that happened per frame, which were the only thing synchronizing the game/render threads with the RHI thread. Without these flushes, and when occlusion queries are disabled, the game thread can run ahead of the RHI thread by several hundred frames, since it is now entirely unsynchronized.
 - This fix changes mode 0 of "r.GTSyncType" to sync with the N-2 RHI thread frame when the RHI thread is active, rather than the N-1 render thread frame. The game thread is now always synchronized with the RHI thread to prevent it running ahead.
 - Mode 1 of "r.GTSyncType" now works even when vsync is disabled, and syncs the game thread with the N-1 RHI thread frame (same behaviour as before).

#jira UE-223692
#rb zach.bethel

[CL 36762632 by luke thatcher in 5.5 branch]
2024-10-01 20:19:59 -04:00
luke thatcher
39d49fd3ab Backout CLs 36573591, 36479070 and 36468180 due to crashes in the editor
- This will reintroduce UE-223692 but will prevent FORT-796488.
 - A proper fix for UE-223692 needs further investigation.

#rb zach.bethel

[CL 36761792 by luke thatcher in 5.5 branch]
2024-10-01 20:11:06 -04:00
jamie hayes
9abe13b5f9 Don't check for 64-bit atomic support of the local machine when adding Nanite config to the shader map DDC key. Fixes issues with mismatched keys when the cooker doesn't have support. Also fixes potential issues when r.Nanite is configured differently for the cooking platform than the target platform.
#rb jason.nadro

[CL 36758892 by jamie hayes in 5.5 branch]
2024-10-01 19:43:20 -04:00
florin pascu
241d2d8693 Re-enable VK SM5 preview for D3D
Force SM6 for preview VK SM5, Mac SM5
Enable Lumen Support for Preview VK SM5, Mac SM5
Modifying FeatureLevelSwitch to respect the parent ShaderPlatform FeatureLevel and not the one set by preview in order to have consistent material logic with the Shader Platform we are trying to preview

#rb Jack.Porter, jeannoe.morissette

[CL 36758806 by florin pascu in 5.5 branch]
2024-10-01 19:42:38 -04:00
luke thatcher
bdf2d7d6c7 Improved game thread frame sync to resolve crashes introduced in 36468180 and worked around in 36479070
- Various legacy game thread code assumes the render thread will never be more than one frame behind. The original change in 36468180 switched from syncing the GT with the RT, to syncing the GT with the RHIT. That left the render thread "floating" in the center of the pipeline, and led to cases where resources are deleted too soon.
 - New approach is to always sync with the GT with the N-1 RT frame, so the GT is never too far ahead of the RT. This maintains compatibility with the legacy GT code paths. In addition to the GT->RT sync, we also sync with the RHIT to prevent the engine running ahead, which was the original bug that 36468180 was fixing.
 - "r.GTSyncType" mode 0 now allows for 1 frame of GT->RT overlap, and 2 frames of GT->RHIT overlap.
 - For debugging purposes, "r.GTSyncType" can also be made negative, which increases the number of GT->RHIT overlap frames, e.g. "r.GTSyncType -3" gives 5 frames of GT->RHIT overlap. While this is not overly useful in a shipped title, it can be used to prove the correctness of the rendering pipeline.
 - Merged the FDeferredCleanupInterface / FPendingCleanupObjects processing into the FFrameEndSync code path, plus made FFrameEndSync a static singleton. This allows us to manage the N frames of overlap between the GT and RHIT in a central place, and correctly cleanup deferred resources when the RT fences have passed.

In future, we will need to revisit this as part of the frame pacing initiative. Game thread code should be written to not require render thread fences for correctness / threadsafety.

#jira UE-223692
#rb zach.bethel

[CL 36758377 by luke thatcher in 5.5 branch]
2024-10-01 19:38:37 -04:00
dan elksnitis
55df76e600 [shaders] fix metal shader archive population, was still implementing a deprecated API
#rb Jason.Nadro

[CL 36757780 by dan elksnitis in 5.5 branch]
2024-10-01 19:32:51 -04:00
serge bernier
86f6fd8662 Wrap the preload shader group priority around a cvar.
#rb daniele.vettorel, john.huelin

[CL 36755078 by serge bernier in 5.5 branch]
2024-10-01 19:05:05 -04:00
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
cory kolek
f5c8671eb6 Removing a check that was crashing the editor.
[CL 36749829 by cory kolek in 5.5 branch]
2024-10-01 18:08:19 -04:00
zach bethel
badbe7829a Reworked RDG dispatch logic to cut a new parallel pass set when a dispatch is requested. Also reworked the Slate 8 swapchain limit workaround so we only dispatch after 8 instead of every time.
[CL 36749528 by zach bethel in 5.5 branch]
2024-10-01 18:06:24 -04:00
zach bethel
857947ece8 Fixed RDG immediate not properly setting reserved buffer commit sizes.
#jira UE-224042

[CL 36749496 by zach bethel in 5.5 branch]
2024-10-01 18:06:13 -04:00
serge bernier
29d7e5ecc0 DynamicShaderPreloading. Removed changes to CollectPSOInitializers functions so that we dont have to do deprecations. Moved all code logic for PSO shader preloading in one location (AddGraphicsPipelineStateInitializer) to improve code maintenance.
#rb Kenzo.Terelst, daniele.vettorel

#ushell-cherrypick of 36478045 by serge.bernier (second/final submit)

[CL 36748004 by serge bernier in 5.5 branch]
2024-10-01 17:50:10 -04:00
serge bernier
f3620d4994 Support Dynamic shader preloading. Similar to PSOPrecaching, we can load shaders on demand instead of preloading all of them when we load the package. This reduce the memory footprint on shaders since we only load shaders that will be used for rendering. Shader preloading also support the same code logic to delay the creation of the prender proxy when the shaders are not finished loading.
Save up to 16MB on some platforms.

#rb daniele.vettorel, danny.couture, Kenzo.Terelst
#tests 66d8b4154a47dde1dd226334



#ushell-cherrypick of 36036431 by serge.bernier (first of 2 submits)

[CL 36747837 by serge bernier in 5.5 branch]
2024-10-01 17:48:22 -04:00