Skip to content

Commit

Permalink
sys_patch: Drop Metal downgrade for AMD Legacy GCN
Browse files Browse the repository at this point in the history
  • Loading branch information
khronokernel committed Oct 16, 2022
1 parent f45559a commit 1a262c6
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 23 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -36,7 +36,8 @@
- Relies on N-1 system for when matching KDK is not present
- Delete unused KDKs in `/Library/Developer/KDKs` during root patching
- Resolve Power Management support for Ivy Bridge and older
- Drop AMFI requirement for Nvidia Kepler
- Drop AMFI requirement for Nvidia Kepler and AMD GCN 1-3
- Resolve numerous AMD GCN 1-3 issues (ex. Photos.app, Screen Saver, etc.)
- Add work-around to Catalyst Buttons not responding on non-Metal in macOS Monterey
- Increment Binaries:
- OpenCorePkg 0.8.5 release
Expand Down
2 changes: 1 addition & 1 deletion data/sys_patch_dict.py
Expand Up @@ -377,7 +377,7 @@ def SystemPatchDictionary(os_major, os_minor, non_metal_os_support):
},
},

# In Ventura, Apple added AVX2.0 code to the OpenCL/GL compilers
# In Ventura, Apple added AVX2.0 code to AMD's OpenCL/GL compilers
"AMD OpenCL": {
"Display Name": "",
"OS Support": {
Expand Down
2 changes: 1 addition & 1 deletion resources/constants.py
Expand Up @@ -13,7 +13,7 @@ class Constants:
def __init__(self):
# Patcher Versioning
self.patcher_version = "0.5.0" # OpenCore-Legacy-Patcher
self.patcher_support_pkg_version = "0.6.9" # PatcherSupportPkg
self.patcher_support_pkg_version = "0.7.0" # PatcherSupportPkg
self.url_patcher_support_pkg = "https://github.com/dortania/PatcherSupportPkg/releases/download/"
self.nightly_url_patcher_support_pkg = "https://nightly.link/dortania/PatcherSupportPkg/workflows/build/master/"
self.discord_link = "https://discord.gg/rqdPgH8xSN"
Expand Down
12 changes: 3 additions & 9 deletions resources/defaults.py
Expand Up @@ -217,14 +217,6 @@ def gpu_probe(self):
self.constants.secure_status = False
self.constants.disable_cs_lv = True

if gpu in [
device_probe.AMD.Archs.Legacy_GCN_7000,
device_probe.AMD.Archs.Legacy_GCN_8000,
device_probe.AMD.Archs.Legacy_GCN_9000,
device_probe.AMD.Archs.Polaris,
]:
self.constants.disable_amfi = True

# Non-Metal Logic
elif gpu in [
device_probe.Intel.Archs.Iron_Lake,
Expand All @@ -239,7 +231,9 @@ def gpu_probe(self):
self.constants.sip_status = False
self.constants.secure_status = False
self.constants.disable_cs_lv = True
self.constants.disable_amfi = True
if os_data.os_data.ventura in self.constants.legacy_accel_support:
# Only disable AMFI if we officially support Ventura
self.constants.disable_amfi = True

if self.host_is_target:
self.constants.host_is_non_metal = True
Expand Down
12 changes: 10 additions & 2 deletions resources/kdk_handler.py
Expand Up @@ -24,7 +24,11 @@ def get_available_kdks(self):

print("- Fetching available KDKs")

results = utilities.SESSION.get(KDK_API_LINK, headers={"User-Agent": f"OCLP/{self.constants.patcher_version}"})
try:
results = utilities.SESSION.get(KDK_API_LINK, headers={"User-Agent": f"OCLP/{self.constants.patcher_version}"})
except (requests.exceptions.Timeout, requests.exceptions.TooManyRedirects, requests.exceptions.ConnectionError):
print("- Could not contact KDK API")
return None

if results.status_code != 200:
print("- Could not fetch KDK list")
Expand All @@ -45,7 +49,11 @@ def get_closest_match_legacy(self, host_version: str, host_build: str):

print(f"- Checking closest match for: {host_version} build {host_build}")

results = utilities.SESSION.get(OS_DATABASE_LINK)
try:
results = utilities.SESSION.get(OS_DATABASE_LINK)
except (requests.exceptions.Timeout, requests.exceptions.TooManyRedirects, requests.exceptions.ConnectionError):
print("- Could not contact AppleDB")
return None, "", ""

if results.status_code != 200:
print("- Could not fetch database")
Expand Down
4 changes: 3 additions & 1 deletion resources/sys_patch.py
Expand Up @@ -293,7 +293,7 @@ def create_new_apfs_snapshot(self):
print("Reason for snapshot failure:")
print(bless.stdout.decode())
if "Can't use last-sealed-snapshot or create-snapshot on non system volume" in bless.stdout.decode():
print("- This is an APFS bug with Monterey! Perform a clean installation to ensure your APFS volume is built correctly")
print("- This is an APFS bug with Monterey and newer! Perform a clean installation to ensure your APFS volume is built correctly")
return False
self.unmount_drive()
return True
Expand Down Expand Up @@ -488,6 +488,8 @@ def execute_patchset(self, required_patches):
else:
print(f"- Running Process:\n{process}")
utilities.process_status(subprocess.run(process, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True))
if "AMD Legacy GCN" in required_patches:
sys_patch_helpers.sys_patch_helpers(self.constants).disable_window_server_caching()
self.write_patchset(required_patches)

def preflight_checks(self, required_patches, source_files_path):
Expand Down
21 changes: 13 additions & 8 deletions resources/sys_patch_detect.py
Expand Up @@ -64,7 +64,8 @@ def detect_gpus(self):
if self.constants.detected_os > non_metal_os:
self.nvidia_tesla = True
self.amfi_must_disable = True
self.amfi_shim_bins = True
if os_data.os_data.ventura in self.constants.legacy_accel_support:
self.amfi_shim_bins = True
self.legacy_keyboard_backlight = self.check_legacy_keyboard_backlight()
self.requires_root_kc = True
elif gpu.arch == device_probe.NVIDIA.Archs.Kepler and self.constants.force_nv_web is False:
Expand Down Expand Up @@ -94,20 +95,23 @@ def detect_gpus(self):
if self.constants.detected_os > os_data.os_data.mojave:
self.nvidia_web = True
self.amfi_must_disable = True
self.amfi_shim_bins = True
if os_data.os_data.ventura in self.constants.legacy_accel_support:
self.amfi_shim_bins = True
self.needs_nv_web_checks = True
self.requires_root_kc = True
elif gpu.arch == device_probe.AMD.Archs.TeraScale_1:
if self.constants.detected_os > non_metal_os:
self.amd_ts1 = True
self.amfi_must_disable = True
self.amfi_shim_bins = True
if os_data.os_data.ventura in self.constants.legacy_accel_support:
self.amfi_shim_bins = True
self.requires_root_kc = True
elif gpu.arch == device_probe.AMD.Archs.TeraScale_2:
if self.constants.detected_os > non_metal_os:
self.amd_ts2 = True
self.amfi_must_disable = True
self.amfi_shim_bins = True
if os_data.os_data.ventura in self.constants.legacy_accel_support:
self.amfi_shim_bins = True
self.requires_root_kc = True
elif gpu.arch in [
device_probe.AMD.Archs.Legacy_GCN_7000,
Expand All @@ -129,19 +133,20 @@ def detect_gpus(self):
self.supports_metal = True
self.requires_root_kc = True
self.amfi_must_disable = True
self.amfi_shim_bins = True
elif gpu.arch == device_probe.Intel.Archs.Iron_Lake:
if self.constants.detected_os > non_metal_os:
self.iron_gpu = True
self.amfi_must_disable = True
self.amfi_shim_bins = True
if os_data.os_data.ventura in self.constants.legacy_accel_support:
self.amfi_shim_bins = True
self.legacy_keyboard_backlight = self.check_legacy_keyboard_backlight()
self.requires_root_kc = True
elif gpu.arch == device_probe.Intel.Archs.Sandy_Bridge:
if self.constants.detected_os > non_metal_os:
self.sandy_gpu = True
self.amfi_must_disable = True
self.amfi_shim_bins = True
if os_data.os_data.ventura in self.constants.legacy_accel_support:
self.amfi_shim_bins = True
self.legacy_keyboard_backlight = self.check_legacy_keyboard_backlight()
self.requires_root_kc = True
elif gpu.arch == device_probe.Intel.Archs.Ivy_Bridge:
Expand Down Expand Up @@ -510,7 +515,7 @@ def generate_patchset(self, hardware_details):
# Additionally, AMDRadeonX3000 requires IOAccelerator downgrade which is not installed without 'Non-Metal IOAccelerator Common'
del(required_patches["AMD TeraScale 2"]["Install"]["/System/Library/Extensions"]["AMDRadeonX3000.kext"])
if hardware_details["Graphics: AMD Legacy GCN"] is True:
required_patches.update({"Metal Common": all_hardware_patchset["Graphics"]["Metal Common"]})
required_patches.update({"Revert Metal Downgrade": all_hardware_patchset["Graphics"]["Revert Metal Downgrade"]})
required_patches.update({"Monterey GVA": all_hardware_patchset["Graphics"]["Monterey GVA"]})
required_patches.update({"Monterey OpenCL": all_hardware_patchset["Graphics"]["Monterey OpenCL"]})
required_patches.update({"AMD Legacy GCN": all_hardware_patchset["Graphics"]["AMD Legacy GCN"]})
Expand Down
12 changes: 12 additions & 0 deletions resources/sys_patch_helpers.py
Expand Up @@ -130,3 +130,15 @@ def determine_kdk_present(self, match_closest=False, override_build=None):
if (kdk_folder / Path("System/Library/Extensions/System.kext/PlugIns/Libkern.kext/Libkern")).exists():
return kdk_folder
return None


def disable_window_server_caching(self):
# On legacy GCN GPUs, the WindowServer cache generated creates
# corrupted Opaque shaders.
# To work-around this, we disable WindowServer caching
# And force macOS into properly generating the Opaque shaders
print("- Disabling WindowServer Caching")
# Invoke via 'bash -c' to resolve pathing
utilities.elevated(["bash", "-c", "rm -rf /private/var/folders/*/*/*/WindowServer/com.apple.WindowServer"])
# Disable writing to WindowServer folder
utilities.elevated(["bash", "-c", "chflags uchg /private/var/folders/*/*/*/WindowServer"])

0 comments on commit 1a262c6

Please sign in to comment.