mirror of
https://github.com/utmapp/d3dmetal-native.git
synced 2026-12-01 07:53:19 -10:00
App Review rejects a bundle whose D3DMetal.framework imports private symbols: CoreAnalytics' AnalyticsSendEventLazy (also an LC_LOAD_DYLIB), Metal's MTLSetShaderCachePath / MTLMakeShaderCacheWritableByAllUsers, MTLTextureSwizzleChannelsToKey / KeyToChannels, dyld's _dyld_get_image_uuid / dyld_image_header_containing_address, and the MTLAccelerationStructureAllocationDescriptor class. src/dmn_import_shims.mm implements each with public API under a visible dmn_* / DMN* name. The swizzle key and the image UUIDs feed D3DMetal's shader-cache keys, so those are exact: the key is the channels struct's four bytes, and the UUID comes from the image's LC_UUID via dladdr(). The shader-cache-path pair has no public equivalent and is a no-op, so Metal keeps its default per-process cache; analytics are never sent. The descriptor class has the real one's properties and defaults, which is all Metal reads from it. scripts/patch_d3dmetal_imports.py rewrites a D3DMetal binary to use them, without hiding anything: each import is renamed in place in both the chained-fixups pool and the symbol table and rebound to the library that replaces the CoreAnalytics load command, so nm -u, otool -L and dyld_info -fixups show exactly what it imports. D3DMetal is only ever dlopen'd by this library, so dyld resolves that load command to the already-loaded image by install name. It refuses a replacement longer than the original, a merged string tail in either direction, an unknown fixups format, an already-patched binary, and a provider that does not export every bound name; `check` mode is the CI gate. Patches 1.0 through 4.0b2 (1.0 lacks dyld_image_header_containing_address). tests/import_shims_test compares every replacement against the private original it replaces. Suite against 3.0: patched 50/51, unpatched 49/51, d3d12-atomic64 failing on both. In UTM (hardened runtime, Developer ID), patched 3.0 / 4.0b1 / 4.0b2 match unpatched within noise on Fire Strike, Time Spy and Cyberpunk 2077, and Forspoken, DEATHLOOP and Civilization VI render correctly on patched 3.0. Co-Authored-By: Claude Opus 5.5 <[email protected]>