Skip to content

Add Apple GPTK / D3DMetal update & switching tools, shader cache clearing, and MetalFX support - #267

Open
rapheljr wants to merge 4 commits into
NotProtonNot:mainfrom
rapheljr:feat/d3dmetal-gptk-tools
Open

rapheljr wants to merge 4 commits into
NotProtonNot:mainfrom
rapheljr:feat/d3dmetal-gptk-tools

Conversation

@rapheljr

Copy link
Copy Markdown
Contributor

Adds full support for updating, switching, and restoring Apple's DirectX 12 translation layer (D3DMetal / GPTK) directly from Apple disk images, along with DirectX 12 shader cache management and automated MetalFX integration.

What this adds

1-Click D3DMetal Upgrades & Switching

  • Automatic DMG Discovery: Detects mounted Apple GPTK and Evaluation Environment disk images in /Volumes (including nested Evaluation environment...dmg images inside Game Porting Toolkit.dmg), showing a 1-click update action in the CrossOver runner menu.
  • In-Place Version Switching: Automatically caches previous D3DMetal versions (apple_gptk_versions/<version>) so players can switch back and forth between versions (e.g. 3.0 ↔ 4.0b3) in 1 click without needing multiple duplicate runner installs.
  • Restore Stock CrossOver DirectX 12: Easily roll back to the stock D3DMetal binaries bundled with the installed CrossOver copy.
  • Manual DMG/Folder Picker: Supports selecting unmounted .dmg files or extracted folders with automatic non-blocking background mounting and cleanup.

DirectX 12 Shader Cache Management

  • Identifies Darwin user cache d3dm/<game>.exe/shaders.cache.
  • Adds a 1-click "Clear DirectX 12 Shader Cache" action to each game's prefix menu in the Prefixes tab, plus a global "Clear All DirectX 12 Shader Caches" option.
  • Automatically clears stale shader caches upon D3DMetal version updates or switches to prevent startup crashes.

MetalFX Integration & Steam Controls

  • Automatically prepares MetalFX by renaming nvngx-on-metalfx to nvngx and deploying nvngx.dll / nvapi64.dll to prefix system32 directories upon update.
  • Adds install_metalfx_dlls in compat_run.sh to ensure prefix DLLs are present whenever D3DM_ENABLE_METALFX=1 is active.
  • Exposes controls for D3DM_SUPPORT_DXR (DirectX Raytracing), D3DM_MTL4 (Metal 4 toggle), and D3DM_MAX_FPS (frame rate cap) in Steam game panels and defaults.

Safety & Hardening

  • Zero UI-Thread Blocking: All filesystem discovery in /Volumes is synchronous and non-blocking (no subprocess execution during view renders). hdiutil mounting and library copy operations run strictly in background tasks.
  • Atomic File Swaps: Library updates move existing external and wine directories to .old backups first, replacing atomically and restoring backups if any copy error occurs.
  • Runner Execution Guard: Rejects updates and switches while games are actively running from the target runner clone.

Checks

  • swift test: 578 tests across 60 suites passing (9 new tests in D3DMetalToolsTests.swift).
  • All make assertions pass: defaults-check, defaults-drift, envcheck, panel-behavior, settingscheck, routecheck, bridgecheck.
  • Tested live on macOS with CrossOver 26 and GPTK 4.0b3.

@NotProtonNot

Copy link
Copy Markdown
Owner

Will review tomorrow for the release cycle. As far as updating D3DMetal goes, the plugin system (see plugin-pt2 branch) will be the supported way to do that. I still have a bunch of UX work to do there, but it's coming along.

@rapheljr

Copy link
Copy Markdown
Contributor Author

Sounds great! I took a look at plugin-pt2 — the declarative variants/*.conf grammar looks really clean and unified. The DMG discovery, background mounting/extraction, and shader cache clearing from this PR can easily feed directly into that variant layout once you wrap up the UX work. Looking forward to your review!

@rapheljr
rapheljr force-pushed the feat/d3dmetal-gptk-tools branch from bada98c to 3b6a62d Compare October 31, 2026 10:46
@rapheljr

Copy link
Copy Markdown
Contributor Author

Rebased cleanly on latest main following the plugin-pt2 merge and adapted D3DMetal support to the declarative runner variant architecture:

  • CLI Tool (tools/install-d3dmetal.sh): Added companion to install-dxmt.sh for D3DMetal and Apple Evaluation Environment trees / DMGs. Supports verification, automatic DMG mounting & extraction, MetalFX preparation (nvngx.dll), variant descriptor generation (variant = D3DMetal, dst = lib64/apple_gptk), listing, removal, and shader cache clearing.
  • Example Variant (examples/variants/d3dmetal-example.conf): Added example descriptor and updated examples/README.md.
  • Swift Variant APIs: Extended D3DMetalTools with installVariant(), installedVariants(), and removeVariant(), preserving the non-blocking DMG discovery and shader cache tools.
  • Tests & Verification: Added lifecycle tests in D3DMetalToolsTests. All 583 Swift unit tests across 60 suites and all 25+ hermetic test suites (runnervariantcheck, confcheck, defaults-check, panel-behavior, envcheck, featcheck, etc.) pass with 0 failures.

@rapheljr

rapheljr commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

Completed full code review, audit, and localization sync:

  • Localization (l10ncheck): Added catalog entries and native translations for all 42 newly introduced strings across German (de), French (fr), Italian (it), and Simplified Chinese (zh-Hans) in Localizable.xcstrings. make -s l10ncheck passes with zero problems.
  • Relative Path Consistency: Standardized src descriptor paths in install-d3dmetal.sh and D3DMetalTools.swift to write paths relative to $HOME (Library/Application Support/notproton/variants/<name>), aligning with np_home_path in compat_run.sh and resolve_home_path in webpatch.c.
  • All Verifications Passing Cleanly:
    • make -s mincheck l10ncheck scriptcheck (29 shell scripts linted with ShellCheck, macOS 15.0 compatibility checked, 500 strings cataloged).
    • All 28+ hermetic C test suites (sigcheck, callscheck, webpatch-fixtures, runnervariantcheck, defaults-check, panel-behavior, seedcheck, etc.) pass with 0 failures.
    • Swift test suite (make -s app-tests): 583 tests across 60 suites passing.
    • Full application build (make app): Clean build, bundling, and ad-hoc code signing.

… shader cache tools

- Support 1-click D3DMetal updates from mounted Apple Game Porting Toolkit and Evaluation Environment DMGs (including nested DMGs).
- Add version caching allowing 1-click switching back and forth between D3DMetal versions (e.g. 3.0 <-> 4.0b3).
- Add 1-click restore to stock CrossOver DirectX 12 libraries.
- Support per-game and global DirectX 12 shader cache clearing (~/Library/Caches/.../d3dm).
- Support automated MetalFX preparation and nvngx.dll / nvapi64.dll injection into prefix system32 directories.
- Add Steam panel controls for DirectX Raytracing (DXR), Metal 4 backend, and FPS limits.
- Add comprehensive unit tests covering DMG resolution, version parsing, and shader cache management.
@rapheljr
rapheljr force-pushed the feat/d3dmetal-gptk-tools branch from ab9bfd3 to 0d7f275 Compare November 3, 2026 04:05
@rapheljr

rapheljr commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on latest upstream main (4df944f Merge #282: DXMT frame rate limit):

  • Resolved merge conflicts cleanly across dylib/feats/defaults.c, dylib/feats/webpatch.c, and the panel behavior suites. Both DXMT frame rate limit (DXMT_CONFIG=d3d11.preferredMaxFrameRate=...) and D3DMetal frame rate limit (D3DM_MAX_FPS) now co-exist seamlessly with isolated settings validation (g_fps vs g_d3dm_fps).
  • Verified all validation gates:
    • make -s mincheck l10ncheck scriptcheck: Clean pass (500 localized strings, 29 shell scripts linted, macOS 15.0 compatibility checked).
    • All 28+ hermetic C test suites passing with 0 failures (panel-behavior, defaults-check, defaults-drift, confcheck, runnervariantcheck, seedcheck, etc.).
    • Swift unit tests (make -s app-tests): 583 tests across 60 suites passing.
    • App release build (make app): Clean build, packaging, and code signing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants