From 372ad31d83c0d45fce0712081fad1c19fad1caab Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com> Date: Sun, 5 Sep 2021 10:48:46 -0600 Subject: [PATCH] Adjust patcher settings --- CHANGELOG.md | 2 ++ OpenCore-Patcher.command | 14 ++++++++------ Resources/CliMenu.py | 35 +++++++++++++++++++++++++++++++++-- Resources/Constants.py | 1 + Resources/SysPatch.py | 34 +++++++++++++++++++++------------- 5 files changed, 65 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e6d6591d..ac3802310 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ - Allow iGPU/dGPU switching in Windows - Applicable to MacBook Pros with Intel iGPU and Nvidia/AMD dGPU - Clean up Patcher Settings +- Allow disabling of TeraScale 2 Acceleration during root volume patch + - Use for MacBookPro8,x with heavily degraded dGPUs ## 0.2.4 diff --git a/OpenCore-Patcher.command b/OpenCore-Patcher.command index 0ac4bdfea..d8092bcba 100755 --- a/OpenCore-Patcher.command +++ b/OpenCore-Patcher.command @@ -119,6 +119,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier' ["SMBIOS Settings", self.patcher_settings_smbios], ["Boot Volume Settings", self.patcher_settings_boot], ["Miscellaneous Settings", self.patcher_settings_misc], + ["Dump detected hardware", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).dump_hardware], [ f"Allow Accel on Mojave/Catalina:\tCurrently {self.constants.moj_cat_accel}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_moj_cat_patch, @@ -208,8 +209,8 @@ system_profiler SPHardwareDataType | grep 'Model Identifier' title = ["Adjust Bootable Volume Settings"] menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True) options = [ - [f"Allow FireWire Boot:\tCurrently {self.constants.firewire_boot}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_firewire], - [f"Allow NVMe Boot:\t\tCurrently {self.constants.nvme_boot}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_nvme], + [f"Set FireWire Boot:\tCurrently {self.constants.firewire_boot}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_firewire], + [f"Set NVMe Boot:\tCurrently {self.constants.nvme_boot}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_nvme], ] for option in options: @@ -224,8 +225,9 @@ system_profiler SPHardwareDataType | grep 'Model Identifier' menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True) options = [ [f"Set ShowPicker Mode:\tCurrently {self.constants.showpicker}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_showpicker], - [f"Allow Wake on WLAN:\t\tCurrently {self.constants.enable_wake_on_wlan}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_wowl], - [f"Allow Ivy iMac iGPU:\tCurrently {self.constants.allow_ivy_igpu}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_ivy], + [f"Set Wake on WLAN:\t\tCurrently {self.constants.enable_wake_on_wlan}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_wowl], + [f"Set Ivy iMac iGPU:\t\tCurrently {self.constants.allow_ivy_igpu}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_ivy], + [f"Set TeraScale 2 Accel:\tCurrently {self.constants.allow_ts2_accel}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).terascale_2_accel], [ f"Disable Thunderbolt:\tCurrently {self.constants.disable_thunderbolt}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).disable_thunderbolt, @@ -243,8 +245,8 @@ system_profiler SPHardwareDataType | grep 'Model Identifier' title = ["Adjust Advanced Patcher Settings, for developers ONLY"] menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True) options = [ - [f"Assume Metal GPU Always:\t\tCurrently {self.constants.imac_vendor}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_metal], - [f"DRM Preferences:\t\t\tCurrently {self.constants.drm_support}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).drm_setting], + [f"Set Metal GPU Status:\t\tCurrently {self.constants.imac_vendor}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_metal], + [f"Set DRM Preferences:\t\tCurrently {self.constants.drm_support}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).drm_setting], [f"Set Generic Bootstrap:\t\tCurrently {self.constants.boot_efi}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).bootstrap_setting], [ f"Disable CPU Friend:\t\t\tCurrently {self.constants.disallow_cpufriend}", diff --git a/Resources/CliMenu.py b/Resources/CliMenu.py index f5c9e7af0..9570d4f57 100644 --- a/Resources/CliMenu.py +++ b/Resources/CliMenu.py @@ -180,7 +180,7 @@ Q. Return to previous menu print("Returning to previous menu") else: self.change_sip() - + def change_sbm(self): Utilities.cls() Utilities.header(["Set SecureBootModel"]) @@ -546,7 +546,6 @@ Q. Return to previous menu else: self.latebloom_settings() - def allow_moj_cat_patch(self): Utilities.cls() Utilities.header(["Allow Root Patching on Mojave/Catalina"]) @@ -600,3 +599,35 @@ other devices that benefit from this fix. print("Returning to previous menu") else: self.disable_thunderbolt() + + def terascale_2_accel(self): + Utilities.cls() + Utilities.header(["Set TeraScale 2 Acceleration"]) + print( + """ +By default this patcher will install TeraScale 2 acceleration, however +for some laptops this may be undesired due to how degraded their dGPU +is. + +Disabling TeraScale 2 acceleration will instead install basic framebuffer +support allowing for basic brightness control and let the HD3000 iGPU +handle acceleration tasks. + """ + ) + + change_menu = input("Allow TeraScale 2 Acceleration?(y/n/q): ") + if change_menu in {"y", "Y", "yes", "Yes"}: + self.constants.allow_ts2_accel = True + elif change_menu in {"n", "N", "no", "No"}: + self.constants.allow_ts2_accel = False + elif change_menu in {"q", "Q", "Quit", "quit"}: + print("Returning to previous menu") + else: + self.terascale_2_accel() + + def dump_hardware(self): + Utilities.cls() + Utilities.header(["Dumping detected hardware"]) + print("") + print(self.constants.computer) + input("\nPress [ENTER] to exit: ") diff --git a/Resources/Constants.py b/Resources/Constants.py index fb076bca3..56e9d9b55 100644 --- a/Resources/Constants.py +++ b/Resources/Constants.py @@ -97,6 +97,7 @@ class Constants: self.latebloom_debug = 0 self.validate = False self.disable_thunderbolt = False + self.allow_ts2_accel = True # OS Versions self.tiger = 8 diff --git a/Resources/SysPatch.py b/Resources/SysPatch.py index 18cd996d2..5a1f30247 100644 --- a/Resources/SysPatch.py +++ b/Resources/SysPatch.py @@ -24,6 +24,7 @@ class PatchSysVolume: self.sbm_enabled = True self.amfi_enabled = True self.fv_enabled = True + self.dosdude_patched = True self.nvidia_legacy = False self.amd_ts1 = False self.amd_ts2 = False @@ -37,8 +38,12 @@ class PatchSysVolume: self.check_board_id = False self.bad_board_id = False self.no_patch = True + self.validate = False - if self.constants.detected_os > self.constants.catalina: + if (Path.home() / "Desktop/OCLP-Test/").exists: + self.mount_location = Path.home() / "Desktop/OCLP-Test" + self.validate = True + elif self.constants.detected_os > self.constants.catalina: # Big Sur and newer use APFS snapshots self.mount_location = "/System/Volumes/Update/mnt1" else: @@ -57,7 +62,7 @@ class PatchSysVolume: def find_mount_root_vol(self, patch): self.root_mount_path = Utilities.get_disk_path() if self.root_mount_path.startswith("disk"): - if self.constants.detected_os == self.constants.catalina: + if self.constants.detected_os == self.constants.catalina and self.validate is False: print("- Mounting Catalina Root Volume as writable") self.elevated(["mount", "-uw", f"{self.mount_location}/"], stdout=subprocess.PIPE).stdout.decode().strip().encode() print(f"- Found Root Volume at: {self.root_mount_path}") @@ -180,7 +185,8 @@ class PatchSysVolume: else: print(f"- Failed to find {location_zip}, unable to unpatch") - self.rebuild_snapshot() + if self.validate is False: + self.rebuild_snapshot() else: print("- Could not find Extensions.zip, cannot manually unpatch root volume") @@ -328,11 +334,11 @@ set million colour before rebooting""" self.add_new_binaries(SysPatchArray.AddAMDBrightness, self.constants.legacy_amd_path) def gpu_accel_legacy_ts2_master(self): - if self.constants.detected_os in [self.constants.mojave, self.constants.catalina]: + if self.constants.detected_os in [self.constants.mojave, self.constants.catalina] and self.constants.allow_ts2_accel is True: print("- Installing TeraScale 2 Acceleration Kext patches for Mojave/Catalina") self.gpu_accel_legacy() self.add_new_binaries(SysPatchArray.AddAMDAccelLegacy, self.constants.legacy_amd_path) - elif self.constants.detected_os == self.constants.big_sur: + elif self.constants.detected_os == self.constants.big_sur and self.constants.allow_ts2_accel is True: print("- Installing TeraScale 2 Acceleration Kext patches for Big Sur") self.delete_old_binaries(SysPatchArray.DeleteAMDAccel11) self.delete_old_binaries(SysPatchArray.DeleteAMDAccel11TS2) @@ -375,8 +381,9 @@ set million colour before rebooting""" if self.constants.detected_os == self.constants.monterey: print("- Installing IvyBridge Acceleration Kext patches for Monterey") self.add_new_binaries(SysPatchArray.AddIntelGen3Accel, self.constants.legacy_intel_gen3_path) - print("- Fixing Acceleration in CoreMedia") - Utilities.process_status(subprocess.run(["defaults", "write", "com.apple.coremedia", "hardwareVideoDecoder", "-string", "enable"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) + if self.validate is False: + print("- Fixing Acceleration in CoreMedia") + Utilities.process_status(subprocess.run(["defaults", "write", "com.apple.coremedia", "hardwareVideoDecoder", "-string", "enable"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) print("- Merging Ivy Bridge Frameworks") self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_frameworks_path_accel_ivy}/", self.mount_frameworks], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) print("- Merging Ivy Bridge PrivateFrameworks") @@ -405,8 +412,9 @@ set million colour before rebooting""" print("- Merging TeraScale 2 PrivateFrameworks") self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_accel_ts2}/", self.mount_private_frameworks], stdout=subprocess.PIPE) - print("- Fixing Acceleration in CMIO") - Utilities.process_status(subprocess.run(["defaults", "write", "com.apple.cmio", "CMIO_Unit_Input_ASC.DoNotUseOpenCL", "-bool", "true"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) + if self.validate is False: + print("- Fixing Acceleration in CMIO") + Utilities.process_status(subprocess.run(["defaults", "write", "com.apple.cmio", "CMIO_Unit_Input_ASC.DoNotUseOpenCL", "-bool", "true"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) def patch_root_vol(self): print(f"- Running patches for {self.model}") @@ -464,13 +472,13 @@ set million colour before rebooting""" print("- Detected unsupported OS, installing Basic Framebuffer") self.gpu_framebuffer_ivybridge_master() - if self.amd_ts2 is True and self.constants.detected_os in self.constants.legacy_accel_support: + if self.amd_ts2 is True and self.constants.detected_os in self.constants.legacy_accel_support and self.constants.allow_ts2_accel is True: # TeraScale 2 patches must be installed after Intel HD3000 self.add_new_binaries(SysPatchArray.AddAMDAccel11TS2, self.constants.legacy_amd_path_ts2) if self.added_legacy_kexts is True and self.constants.detected_os in self.constants.legacy_accel_support: self.gpu_accel_legacy_extended() - if self.amd_ts2 is True: + if self.amd_ts2 is True and self.constants.allow_ts2_accel is True: self.gpu_accel_legacy_extended_ts2() # Misc patches @@ -481,8 +489,8 @@ set million colour before rebooting""" if self.legacy_audio is True: print("- Fixing Volume Control Support") self.add_audio_patch() - - self.rebuild_snapshot() + if self.validate is False: + self.rebuild_snapshot() def check_files(self): if Path(self.constants.payload_apple_root_path).exists():