mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-14 04:38:20 +10:00
Enable GPU Accel on legacy GPUs by default
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
- Fix USB kernel panics on iMac7,1
|
||||
- Fix AppleALC support in Mojave
|
||||
- Fix TeraScale 1 GPU detection
|
||||
- Enable Graphics Acceleration on legacy GPUs by default
|
||||
|
||||
## 0.1.0
|
||||
- Fix crash on iMacs with Metal GPUs
|
||||
|
||||
@@ -70,7 +70,7 @@ class Constants:
|
||||
self.detected_os = 0
|
||||
self.boot_efi = False
|
||||
self.drm_support = False
|
||||
self.legacy_acceleration_patch = False
|
||||
self.legacy_acceleration_patch = True
|
||||
self.assume_legacy = False
|
||||
|
||||
# OS Versions
|
||||
@@ -95,6 +95,11 @@ class Constants:
|
||||
self.pci_broadcom = "14E4"
|
||||
self.pci_atheros = "168C"
|
||||
|
||||
# Nvidia GPU Architecture
|
||||
self.arch_tesla = "NV50"
|
||||
self.arch_fermi = "GF100"
|
||||
self.arch_kepler = "GK100"
|
||||
|
||||
# External Files
|
||||
self.url_apple_binaries = "https://github.com/dortania/Apple-Binaries-OCLP/archive/refs/tags/"
|
||||
|
||||
@@ -267,11 +272,15 @@ class Constants:
|
||||
@property
|
||||
def legacy_nvidia_path(self): return self.legacy_graphics / Path("Nvidia-Tesla-Fermi")
|
||||
@property
|
||||
def legacy_nvidia_kepler_path(self): return self.legacy_graphics / Path("Nvidia-Kepler")
|
||||
@property
|
||||
def legacy_amd_path(self): return self.legacy_graphics / Path("AMD-ATI")
|
||||
@property
|
||||
def legacy_intel_gen1_path(self): return self.legacy_graphics / Path("Intel-Gen5-Ironlake")
|
||||
@property
|
||||
def legacy_intel_gen2_path(self): return self.legacy_graphics / Path("Intel-Gen6-SandyBridge")
|
||||
@property
|
||||
def legacy_intel_gen3_path(self): return self.legacy_graphics / Path("Intel-Gen7-IvyBridge")
|
||||
|
||||
@property
|
||||
def legacy_brightness(self): return self.payload_apple_kexts_path / Path("Brightness-Control")
|
||||
|
||||
@@ -951,13 +951,17 @@ AddNvidiaAccel11 = [
|
||||
"IOSurface.kext",
|
||||
]
|
||||
|
||||
AddNvidiaBrightness11 = [
|
||||
"GeForceGA.bundle",
|
||||
"GeForceTesla.kext",
|
||||
"GeForceTeslaGLDriver.bundle",
|
||||
"GeForceTeslaVADriver.bundle",
|
||||
"NVDANV50HalTesla.kext",
|
||||
"NVDAResmanTesla.kext",
|
||||
AddNvidiaKeplerAccel11 = [
|
||||
"GeForce.kext",
|
||||
"GeForceAIRPlugin.bundle",
|
||||
"GeForceGLDriver.bundle",
|
||||
"GeForceMTLDriver.bundle",
|
||||
"GeForceVADriver.bundle",
|
||||
"NVDAGF100Hal.kext",
|
||||
"NVDAGK100Hal.kext",
|
||||
"NVDAResman.kext",
|
||||
"NVDAStartup.kext",
|
||||
"NVSMU.kext",
|
||||
]
|
||||
|
||||
AddAMDAccel11 = [
|
||||
@@ -984,20 +988,6 @@ AddAMDAccel11 = [
|
||||
"IOSurface.kext",
|
||||
]
|
||||
|
||||
AddAMDTeraScale1Brightness11 = [
|
||||
"AMD2400Controller.kext",
|
||||
"AMD2600Controller.kext",
|
||||
"AMD3800Controller.kext",
|
||||
"AMD4600Controller.kext",
|
||||
"AMD4800Controller.kext",
|
||||
"AMDLegacyFramebuffer.kext",
|
||||
"AMDLegacySupport.kext",
|
||||
"ATIRadeonX2000.kext",
|
||||
"ATIRadeonX2000GA.plugin",
|
||||
"ATIRadeonX2000GLDriver.bundle",
|
||||
"ATIRadeonX2000VADriver.bundle",
|
||||
]
|
||||
|
||||
AddAMDTeraScale2Brightness11 = [
|
||||
"AMD5000Controller.kext",
|
||||
"AMD6000Controller.kext",
|
||||
@@ -1019,16 +1009,6 @@ AddIntelGen1Accel = [
|
||||
"IOSurface.kext",
|
||||
]
|
||||
|
||||
AddIntelGen1Brightness = [
|
||||
"AppleIntelFramebufferAzul.kext",
|
||||
"AppleIntelFramebufferCapri.kext",
|
||||
"AppleIntelHDGraphics.kext",
|
||||
"AppleIntelHDGraphicsFB.kext",
|
||||
"AppleIntelHDGraphicsGA.plugin",
|
||||
"AppleIntelHDGraphicsGLDriver.bundle",
|
||||
"AppleIntelHDGraphicsVADriver.bundle",
|
||||
]
|
||||
|
||||
AddIntelGen2Accel = [
|
||||
"AppleIntelHD3000Graphics.kext",
|
||||
"AppleIntelHD3000GraphicsGA.plugin",
|
||||
@@ -1039,13 +1019,12 @@ AddIntelGen2Accel = [
|
||||
"IOSurface.kext",
|
||||
]
|
||||
|
||||
AddIntelGen2Brightness = [
|
||||
"AppleIntelHD3000Graphics.kext",
|
||||
"AppleIntelHD3000GraphicsGA.plugin",
|
||||
"AppleIntelHD3000GraphicsGLDriver.bundle",
|
||||
"AppleIntelHD3000GraphicsVADriver.bundle",
|
||||
"AppleIntelSNBGraphicsFB.kext",
|
||||
"AppleIntelSNBVA.bundle",
|
||||
AddIntelGen3Accel = [
|
||||
"AppleIntelFramebufferCapri.kext",
|
||||
"AppleIntelHD4000Graphics.kext",
|
||||
"AppleIntelHD4000GraphicsGLDriver.bundle",
|
||||
"AppleIntelHD4000GraphicsMTLDriver.bundle",
|
||||
"AppleIntelHD4000GraphicsVADriver.bundle",
|
||||
]
|
||||
|
||||
DeleteBrightness = [
|
||||
@@ -1140,3 +1119,11 @@ SandyBridgepiciid = [
|
||||
"0102",
|
||||
"0126",
|
||||
]
|
||||
|
||||
IvyBridgepciid = [
|
||||
"0152",
|
||||
"0156",
|
||||
"0162",
|
||||
"0166",
|
||||
]
|
||||
|
||||
|
||||
@@ -45,8 +45,14 @@ class PatchSysVolume:
|
||||
if print_status is True:
|
||||
print(f"- {current_sip_bit}\t {temp}")
|
||||
i = i + 1
|
||||
# TODO: Fix this garbage when I have more sanity
|
||||
if ((self.constants.csr_values["CSR_ALLOW_UNTRUSTED_KEXTS "] is True) and (self.constants.csr_values["CSR_ALLOW_UNRESTRICTED_FS "] is True) and (self.constants.csr_values["CSR_ALLOW_UNRESTRICTED_DTRACE "] is True) and (self.constants.csr_values["CSR_ALLOW_UNRESTRICTED_NVRAM "] is True) and (self.constants.csr_values["CSR_ALLOW_DEVICE_CONFIGURATION "] is True) and (self.constants.csr_values["CSR_ALLOW_UNAPPROVED_KEXTS "] is True) and (self.constants.csr_values["CSR_ALLOW_EXECUTABLE_POLICY_OVERRIDE"] is True) and (self.constants.csr_values["CSR_ALLOW_UNAUTHENTICATED_ROOT "] is True)):
|
||||
if ((self.constants.csr_values["CSR_ALLOW_UNTRUSTED_KEXTS "] is True) \
|
||||
and (self.constants.csr_values["CSR_ALLOW_UNRESTRICTED_FS "] is True) \
|
||||
and (self.constants.csr_values["CSR_ALLOW_UNRESTRICTED_DTRACE "] is True) \
|
||||
and (self.constants.csr_values["CSR_ALLOW_UNRESTRICTED_NVRAM "] is True) \
|
||||
and (self.constants.csr_values["CSR_ALLOW_DEVICE_CONFIGURATION "] is True) \
|
||||
and (self.constants.csr_values["CSR_ALLOW_UNAPPROVED_KEXTS "] is True) \
|
||||
and (self.constants.csr_values["CSR_ALLOW_EXECUTABLE_POLICY_OVERRIDE"] is True) \
|
||||
and (self.constants.csr_values["CSR_ALLOW_UNAUTHENTICATED_ROOT "] is True)):
|
||||
self.sip_patch_status = False
|
||||
else:
|
||||
self.sip_patch_status = True
|
||||
@@ -132,6 +138,10 @@ class PatchSysVolume:
|
||||
self.dgpu_devices = [i for i in self.dgpu_devices if i["class-code"] == binascii.unhexlify("00000300")]
|
||||
self.dgpu_vendor = self.hexswap(binascii.hexlify(self.dgpu_devices[0]["vendor-id"]).decode()[:4])
|
||||
self.dgpu_device = self.hexswap(binascii.hexlify(self.dgpu_devices[0]["device-id"]).decode()[:4])
|
||||
try:
|
||||
self.nvidia_arch = self.dgpu_devices[0]["NVArch"]
|
||||
except ValueError:
|
||||
self.nvidia_arch = ""
|
||||
print(f"- Detected dGPU: {self.dgpu_vendor}:{self.dgpu_device}")
|
||||
except ValueError:
|
||||
print("- No dGPU detected")
|
||||
@@ -140,9 +150,13 @@ class PatchSysVolume:
|
||||
def gpu_accel_patches_11(self):
|
||||
if self.dgpu_devices:
|
||||
if self.dgpu_vendor == self.constants.pci_nvidia:
|
||||
print("- Merging legacy Nvidia Kexts and Bundles")
|
||||
self.delete_old_binaries(ModelArray.DeleteNvidiaAccel11)
|
||||
self.add_new_binaries(ModelArray.AddNvidiaAccel11, self.constants.legacy_nvidia_path)
|
||||
if self.nvidia_arch == self.constants.arch_kepler and self.constants.assume_legacy is True and self.constants.detected_os > self.constants.big_sur:
|
||||
print("- Merging legacy Nvidia Kepler Kexts and Bundles")
|
||||
self.add_new_binaries(ModelArray.AddNvidiaKeplerAccel11, self.constants.legacy_nvidia_kepler_path)
|
||||
else:
|
||||
print("- Merging legacy Nvidia Telsa and Fermi Kexts and Bundles")
|
||||
self.delete_old_binaries(ModelArray.DeleteNvidiaAccel11)
|
||||
self.add_new_binaries(ModelArray.AddNvidiaAccel11, self.constants.legacy_nvidia_path)
|
||||
elif self.dgpu_vendor == self.constants.pci_amd_ati:
|
||||
print("- Merging legacy AMD Kexts and Bundles")
|
||||
self.delete_old_binaries(ModelArray.DeleteAMDAccel11)
|
||||
@@ -161,6 +175,11 @@ class PatchSysVolume:
|
||||
# Swap custom AppleIntelSNBGraphicsFB-AMD.kext, required to fix linking
|
||||
# subprocess.run(f"sudo rm -R {self.mount_extensions}/AppleIntelSNBGraphicsFB.kext".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()
|
||||
# subprocess.run(f"sudo cp -R {self.constants.legacy_amd_path}/AMD-Link/AppleIntelSNBGraphicsFB.kext {self.mount_extensions}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()
|
||||
|
||||
# Code for when Ivy Bridge binares are presumably removed from macOS 12, code currently
|
||||
#elif self.igpu_device in ModelArray.IvyBridgepciid:
|
||||
# print("- Merging legacy Intel 3rd Gen Kexts and Bundles")
|
||||
# self.add_new_binaries(ModelArray.AddIntelGen3Accel, self.constants.legacy_intel_gen3_path)
|
||||
elif self.igpu_vendor == self.constants.pci_nvidia:
|
||||
if not self.dgpu_devices:
|
||||
# Avoid patching twice, as Nvidia iGPUs will only have Nvidia dGPUs
|
||||
@@ -199,8 +218,6 @@ class PatchSysVolume:
|
||||
# TODO: Create Backup of S*/L*/Extensions, Frameworks and PrivateFramework to easily revert changes
|
||||
# APFS snapshotting seems to ignore System Volume changes inconcistently, would like a backup to avoid total brick
|
||||
# Perhaps a basic py2 script to run in recovery to restore
|
||||
print("- Creating backup snapshot of user data (This may take some time)")
|
||||
subprocess.run("tmutil snapshot".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()
|
||||
# Ensures no .DS_Stores got in
|
||||
print("- Preparing Files")
|
||||
subprocess.run(f"sudo find {self.constants.payload_apple_root_path} -name '.DS_Store' -delete".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()
|
||||
@@ -212,41 +229,8 @@ class PatchSysVolume:
|
||||
elif self.dgpu_devices and self.dgpu_vendor == self.constants.pci_nvidia and self.dgpu_device in ModelArray.NVIDIAMXMGPUs:
|
||||
print("- Detected Metal-based Nvidia GPU, skipping legacy patches")
|
||||
else:
|
||||
if self.constants.legacy_acceleration_patch is True:
|
||||
print("- Detected legacy GPU, attempting legacy acceleration patches")
|
||||
self.gpu_accel_patches_11()
|
||||
else:
|
||||
if self.dgpu_devices:
|
||||
if self.dgpu_vendor == self.constants.pci_nvidia:
|
||||
print("- Adding Nvidia Brightness Control patches")
|
||||
self.add_new_binaries(ModelArray.AddNvidiaBrightness11, self.constants.legacy_nvidia_path)
|
||||
elif self.dgpu_vendor == self.constants.pci_amd_ati:
|
||||
if self.dgpu_device in ModelArray.TeraScale1pciid:
|
||||
print("- Adding AMD/ATI TeraScale 1 Brightness Control patches")
|
||||
self.add_new_binaries(ModelArray.AddAMDTeraScale1Brightness11, self.constants.legacy_amd_path)
|
||||
#elif self.dgpu_device in ModelArray.TeraScale2pciid:
|
||||
#print("- Adding AMD/ATI TeraScale 2 Brightness Control patches")
|
||||
#self.add_new_binaries(ModelArray.AddAMDTeraScale2Brightness11, self.constants.legacy_amd_path)
|
||||
else:
|
||||
print("- Could not find supported Legacy AMD/ATI GPU")
|
||||
if self.igpu_devices:
|
||||
if self.igpu_vendor == self.constants.pci_intel:
|
||||
if self.igpu_device in ModelArray.IronLakepciid:
|
||||
print("- Adding Intel Ironlake Brightness Control patches")
|
||||
self.add_new_binaries(ModelArray.AddIntelGen1Brightness, self.constants.legacy_intel_gen1_path)
|
||||
elif self.igpu_device in ModelArray.SandyBridgepiciid:
|
||||
print("- Adding Intel Sandy Bridge Brightness Control patches")
|
||||
self.add_new_binaries(ModelArray.AddIntelGen2Brightness, self.constants.legacy_intel_gen2_path)
|
||||
#if self.dgpu_devices and self.dgpu_vendor == self.constants.pci_amd_ati and self.dgpu_device in ModelArray.TeraScale2pciid:
|
||||
# Swap custom AppleIntelSNBGraphicsFB-AMD.kext, required to fix linking
|
||||
# subprocess.run(f"sudo rm -R {self.mount_extensions}/AppleIntelSNBGraphicsFB.kext".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()
|
||||
# subprocess.run(f"sudo cp -R {self.constants.legacy_intel_gen2_path}/AMD-Link/AppleIntelSNBGraphicsFB.kext {self.mount_extensions}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()
|
||||
elif self.igpu_vendor == self.constants.pci_nvidia and not self.dgpu_devices:
|
||||
# Avoid patching twice, as Nvidia iGPUs will only have Nvidia dGPUs
|
||||
print("- Adding Nvidia Brightness Control patches")
|
||||
self.add_new_binaries(ModelArray.AddNvidiaBrightness11, self.constants.legacy_nvidia_path)
|
||||
if self.model in ModelArray.LegacyBrightness:
|
||||
self.add_brightness_patch()
|
||||
print("- Detected legacy GPU, attempting legacy acceleration patches")
|
||||
self.gpu_accel_patches_11()
|
||||
rebuild_required = True
|
||||
|
||||
if rebuild_required is True:
|
||||
|
||||
Reference in New Issue
Block a user