Skip to content

BlueAmulet/UnityNvidiaFix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity Linux NVIDIA Crash Backport Patch

Overview

In versions of Unity 2022.3.37f1 and below, running the Unity editor with Vulkan graphics on NVIDIA graphics will likely lead to crashes when performing actions such as importing a package.
Unity 2022.3.38f1 to 2022.3.40f1 have a fix for the NVIDIA crashes, but 2022.3.22f1 is required for VRChat compatibility.
This project backports the two changed functions from 2022.3.40f1 back to 2022.3.22f1.

Usage

Make sure the binutils package is installed. as, ld, and objcopy are required for the script to function.
Place the Unity binary next to build.sh, this is typically located in ~/Unity/Hub/Editor/2022.3.22f1/Editor
Run build.sh
Copy Unity_fixed back to ~/Unity/Hub/Editor/2022.3.22f1/Editor, replacing the original file
The Unity editor should no longer crash.

Caveats

The .eh_frame and .gcc_except_table sections have not been modified and continue to have old data for the old functions.
Exception handling for the custom functions is currently broken, but does not seem to matter in practice.

Details

The following functions were extracted from Unity 2022.3.40f1:

GfxDeviceVK::AdvanceImage(vk::SwapChain*)
vk::SwapChain::AcquireNextImage(vk::FrameTracking&, unsigned long, unsigned int*, bool*, fixed_array<VkSemaphore_T*, 2ul>*, bool)

The new functions are a bit larger than the previous versions, so:
The new GfxDeviceVK::AdvanceImage is placed in the old spot of vk::SwapChain::AcquireNextImage
The new vk::SwapChain::AcquireNextImage is placed an unused area at the end of the executable segment
A thunk is placed in the old spot for GfxDeviceVK::AdvanceImage
The executable segment is extended to include the new code
vk::SwapChain::AcquireNextImage should only ever be called by GfxDeviceVK::AdvanceImage, so this layout is safe