Skip to content

About

Standalone native Metal to Adreno 740 GPU driver (AIR -> NIR -> IR3, PM4, macOS Metal bundle)

Resources

Stars

19 stars

Watchers

0 watching

Forks

Repository files navigation

NativeMetal

Standalone native Metal → Adreno 740 GPU driver for Xiaomi Pad 6S Pro (sheng, Qualcomm SM8550, Adreno 740 chip_id = 0x43050a01, 3048×2032 @ 120 Hz) running macOS on UniXNU — with zero metal2vulkan, Vulkan/Turnip runtime, or libLLVM dependency.

Architecture

macOS Metal API (WindowServer / QuartzCore / RenderBox / CoreImage / MPS / Apps)
        │
        ▼
objc/NativeAdrenoMetalV2/        arm64e Objective-C++ Metal frontend bundle (+ PAC trampoline)
        │
        ├──► cpp/air-to-nir/     Direct Apple AIR 2.9 → Mesa NIR → Adreno 740 IR3 compiler + atomic Format-v3 disk cache
        │
        ▼
rust/native-metal-v2-ffi/        Checked C ABI bridge (offset-based batch serialization, zero raw pointers)
        │
        ▼
rust/metal-plan/                 Platform-agnostic render-pass / GMEM / UBWC4 / hazard / residency / fence planner
        │
        ├──► cpp/pm4-a740/       Adreno 740 PM4 command-stream emitter (pinned upstream Mesa XML register headers)
        │
        ├──► rust/backend-xnu-adreno/   macOS/XNU NativeAdrenoABI v2 (`AGXAccelerator`) + `GopFramebuffer` scanout backend
        └──► rust/backend-linux-msm/    Linux `/dev/dri/renderD128` (`drm/msm`) hardware test backend

Repository Layout

  • schema/: Cross-language binary contracts (command_batch.schema, resource_contract.schema, fence_contract.schema, rpc_protocol.schema) and verified C/C++ + Rust ABI headers.
  • manifests/: Reproducible hardware, register, and Mesa pin manifests (mesa_pin.json, xnu_mesa_audit.json, rd_170_manifest.json).
  • rust/metal-plan/: Platform-agnostic Metal execution planner, O(1) hazard tracker, aliasing domains, GMEM tile planner, and fence/retirement state machine.
  • rust/native-metal-v2-ffi/: FFI glue between the macOS Metal bundle, metal-plan, pm4-a740, and backend-xnu-adreno.
  • rust/backend-xnu-adreno/: XNU NativeAdrenoABI v2 kernel transport and GopFramebuffer presentation backend.
  • rust/backend-linux-msm/: Linux drm/msm ioctl backend plus devfreq/OPP/thermal/performance-counter readers for direct silicon verification.
  • rust/runner-tablet/: Static musl BusyBox executor (pm4-runner) for live Adreno 740 hardware tests.
  • rust/harness-host/: Host-side hardware regression and microbenchmark harness (smoke-3d, smoke-frame2, GMEM/FP16 probes).
  • cpp/pm4-a740/: Adreno 740 PM4 emitter (Sysmem, GMEM, UBWC4, MSAA 4×, multi-MRT, indirect draws, primitive restart, per-tile state management) using pinned upstream Mesa headers (85fda3b36405).
  • cpp/air-to-nir/: Direct Apple AIR bitcode → Mesa NIR → Adreno 740 IR3 compiler (air-to-nir-v9), stitching graph lowering, and atomic POSIX disk cache.
  • cpp/compiler-shim/: Thin C ABI shader compilation shim.
  • objc/NativeAdrenoMetalV2/: macOS arm64e Metal bundle (MTLDevice, queues, command buffers, render/compute/blit encoders, IOSurface import + 32B-pitch GPU shadow backing, RustPacBoundary.c).
  • linux-busybox/: Minimal BusyBox initramfs and scripts for RAM-only live Linux drm/msm silicon testing.
  • tools/: Offline ABI/schema checkers, C++ ASan/UBSan + Mesa cffdump runners, and Rust↔C++ end-to-end verification scripts.

Offline Verification

python3 tools/verify_schemas.py
python3 tools/run_cpp_tests.py
RUSTFLAGS="-D warnings" cargo test --workspace
python3 tools/verify_rust_cpp_e2e.py
python3 cpp/air-to-nir/tools/run_air_tests.py
python3 tools/run_objc_tests.py   # macOS only: ObjC++ runtime against the host-mock FFI

Design Principles

  1. Zero translation runtime: No metal2vulkan, Vulkan ICD/Turnip runtime, or libLLVM in any runtime crate, library, or macOS bundle.
  2. Checked cross-language boundaries: No raw pointers across Rust ↔ C++ or Host ↔ Tablet boundaries; all batch/resource/fence tables use checked relative offsets and generation-tagged GPU addresses.
  3. Hardware-first verification: Register layouts are pinned directly to upstream Mesa Adreno XML and validated via Mesa cffdump, live Linux drm/msm silicon regressions, and macOS desktop runs on sheng.

About

Standalone native Metal to Adreno 740 GPU driver (AIR -> NIR -> IR3, PM4, macOS Metal bundle)

Resources

Stars

19 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages