diff --git a/mac-manual/content/12-hardware.md b/mac-manual/content/12-hardware.md index 9821ebf2..6e05f4db 100644 --- a/mac-manual/content/12-hardware.md +++ b/mac-manual/content/12-hardware.md @@ -62,7 +62,7 @@ This is the status on the reference Macs. works i | Battery, lid, power profiles | works | | | External displays | works | HDMI on models that have it, USB4 and DisplayPort alt-mode through the Aurora kernel. Five displays on the M2 Max. A third and fourth display rely on an aquamarine fix carried until Hyprland releases it. | | Variable refresh rate, camera (ISP), always-on processor | works | Aurora kernel | -| Hardware video decode | in progress | VA-API decoding of H.264, HEVC Main and Main10, and VP9 8 and 10-bit, tested on a 13" M1 MacBook Pro; 8-bit H.264, HEVC and VP9 also on a 16" M2 Max with the Aurora kernel. mpv uses it by default for H.264, HEVC and VP9, at about a quarter of the CPU of software decoding at 1080p; `hwdec=no` in `~/.config/mpv/mpv.conf` turns it off. To change the system default, edit `/etc/mpv/mpv.conf` rather than deleting it, since a deleted copy comes back at the next boot. An unedited copy of the earlier default, which lacks `gpu-sw=yes`, is the one exception: setup replaces it with the current default, which lets mpv play on Macs whose GPU has no driver yet. An upgrade alone does not run setup, so on a Mac that already had the earlier default, run `sudo omarchy-mac-setup-system`, or rerun hardware setup, to apply it. Browser acceleration is still open. No hardware encoding. | +| Hardware video decode | in progress | VA-API decoding of H.264, HEVC Main and Main10, and VP9 8 and 10-bit, tested on a 13" M1 MacBook Pro; 8-bit H.264, HEVC and VP9 also on a 16" M2 Max with the Aurora kernel. mpv uses it by default for H.264, HEVC and VP9, at about a quarter of the CPU of software decoding at 1080p, drawing with `vo=gpu-next` over OpenGL (`gpu-api=opengl`) with Wayland colorspace hints enabled; `hwdec=no` in `~/.config/mpv/mpv.conf` turns hardware decode off and `vo=gpu` restores the legacy OpenGL renderer. To change the system default and keep your choice across upgrades, edit `/etc/mpv/mpv.conf` rather than deleting it, since a deleted copy comes back at the next boot. An unedited copy of an earlier released default is the one exception: `omarchy-mac`'s pacman hook (on install or upgrade on a booted system) and `omarchy-mac-setup-system` replace it automatically with the current default while leaving edited copies and symlinks alone. Browser acceleration is still open. No hardware encoding. | | Screen recording | works | Encoded on the CPU through `wf-recorder`, because the Apple GPU has no supported hardware video encoder | | Widevine DRM in browsers | works | When the package is available from the Asahi repositories | | Steam | works | Optional, native 4K-page Steam (`user4k=on`) with Aurora FEX and x86 Aurora Mesa on channels carrying `omarchy-steam-fex` 1.0.0-5 or newer. Legacy `muvm` GPU passthrough is deprecated on Aurora 7.3+ kernels and is not pulled in by default. Macs upgraded from `[asahi-alarm]` that still hold Asahi's `steam 20241231-4` shim should switch to Omarchy's native client with `sudo pacman -S omarchy/steam`. | diff --git a/omarchy-mac/README.md b/omarchy-mac/README.md index 5155d4ce..584c1fce 100644 --- a/omarchy-mac/README.md +++ b/omarchy-mac/README.md @@ -12,7 +12,7 @@ Runtime dependencies: `omarchy` (the `omarchy-hw-platform` detector and its Appl Upgrade the matching runtime, settings and add-on candidates in one pacman transaction. Their transferred commands and user unit must have only one owner. A fresh Apple Silicon install takes two transactions before `omarchy-apply-system`: first one that installs the settings package, then one that installs the platform's default set (`omarchy-pkg-defaults aarch64-apple`: the base, aarch64 and Apple lists, this add-on included). The settings package's pacman platform guard checks only transactions that start after it is installed, so no Apple package may share a transaction with it; the runtime can go in either. The recipe must tag this package with `groups=('omarchy-platform-apple-silicon')`; the desktop's `docs/platform-guard.md` has the contract. The desktop's last hardware leaf runs this package's system setup through the dispatcher, and offline setup never downloads it: a Mac without it keeps Omarchy's generic setup. -Run `omarchy-mac-setup-system` as root on the target hardware (inside its target chroot for offline provisioning). An optional absolute root argument supports staging against the same target hardware without a bus. It exits without changes unless the runtime's Apple predicate `omarchy-hw-apple-silicon` holds (`omarchy-hw-platform` reports `aarch64-apple`, or `apple-silicon` on a runtime from before the platform rename), and fails if the detector does. It removes the Intel Mac Broadcom quirk (`options brcmfmac feature_disable=0x82000`, which breaks Apple Silicon Wi-Fi) from `/etc/modprobe.d/brcmfmac.conf` wherever an unguarded runtime migration appended it: only that exact line, with the comment block and blank line written right above it, goes; the file goes when nothing but blank lines is left, a link is left alone with the manual fix, and the initramfs rebuild it owes is recorded under `/var/lib/omarchy/migrations/1789172112-initramfs-pending`, which the runtime's migration finishes. It replaces `/etc/mpv/mpv.conf` with the current mpv default only while it is a regular file byte-identical to the earlier default, which lacks `gpu-sw=yes`; an edited copy or a link stays. It enables resume recovery only for BCM4378, BCM4387 and BCM4388 on Apple Silicon; Intel/T2 Macs are excluded. It is the only enabler of `speakersafetyd`, without which the kernel keeps the speakers muted: it applies the package's `80-omarchy-mac-audio.preset` once speakersafetyd is installed, so `/etc` presets that sort before it or replace it by name, masks and later explicit disables win, and image builders that apply presets get the same result. A live run also restarts a speakersafetyd left dead by a start-limit. The package's drop-in `speakersafetyd.service.d/50-omarchy-mac-profile.conf` gates the unit on `/usr/lib/omarchy-mac/speaker-safety-profile`, an `ExecCondition=` that skips it instead of letting it crash-loop unless `omarchy-hw-apple-silicon` holds and `/usr/share/speakersafetyd//.conf` exists for the first compatible less its trailing letters; on such a Mac the live restart is a skip and the speakers stay muted. No NetworkManager restart or driver reload occurs during setup. The backend applies when NetworkManager next starts; notch changes apply when appledrm next loads. A live run gives iwd a profile for each Wi-Fi network NetworkManager saved with its key before the switch, as NetworkManager itself does for a new connection, so saved networks keep connecting instead of reading as a wrong password. The greeter drop-ins need no setup: from the next start of `sddm`, or of `greetd`, which shows the login screen since omacom/omarchy#20404, they hold the greeter, for at most 10 s, until Apple's display controller has replaced the boot framebuffer. On a J514C/T6031 boot whose loader handed the GPU and display over (and without `apple_t6031_display.enable=0`) it instead waits up to 30 s for an `apple-drm` card and an `asahi-g15` render device, then settles udev for at most 10 s and rechecks them. This avoids opening the autologin VT during the framebuffer handoff. Missing devices or a settle timeout never fail the login screen; the wait enables no driver and changes no owner settings. Other boards retain their existing display wait. +Run `omarchy-mac-setup-system` as root on the target hardware (inside its target chroot for offline provisioning). An optional absolute root argument supports staging against the same target hardware without a bus. It exits without changes unless the runtime's Apple predicate `omarchy-hw-apple-silicon` holds (`omarchy-hw-platform` reports `aarch64-apple`, or `apple-silicon` on a runtime from before the platform rename), and fails if the detector does. It removes the Intel Mac Broadcom quirk (`options brcmfmac feature_disable=0x82000`, which breaks Apple Silicon Wi-Fi) from `/etc/modprobe.d/brcmfmac.conf` wherever an unguarded runtime migration appended it: only that exact line, with the comment block and blank line written right above it, goes; the file goes when nothing but blank lines is left, a link is left alone with the manual fix, and the initramfs rebuild it owes is recorded under `/var/lib/omarchy/migrations/1789172112-initramfs-pending`, which the runtime's migration finishes. It delegates `/etc/mpv/mpv.conf` updates to `/usr/lib/omarchy-mac/mpv-default-sync` (also called by `92-omarchy-mac-mpv-default.hook` on package install or upgrade on a booted system), replacing `/etc/mpv/mpv.conf` with the current mpv default only while it is a regular file byte-identical to an earlier released default; an edited copy or a link stays. It enables resume recovery only for BCM4378, BCM4387 and BCM4388 on Apple Silicon; Intel/T2 Macs are excluded. It is the only enabler of `speakersafetyd`, without which the kernel keeps the speakers muted: it applies the package's `80-omarchy-mac-audio.preset` once speakersafetyd is installed, so `/etc` presets that sort before it or replace it by name, masks and later explicit disables win, and image builders that apply presets get the same result. A live run also restarts a speakersafetyd left dead by a start-limit. The package's drop-in `speakersafetyd.service.d/50-omarchy-mac-profile.conf` gates the unit on `/usr/lib/omarchy-mac/speaker-safety-profile`, an `ExecCondition=` that skips it instead of letting it crash-loop unless `omarchy-hw-apple-silicon` holds and `/usr/share/speakersafetyd//.conf` exists for the first compatible less its trailing letters; on such a Mac the live restart is a skip and the speakers stay muted. No NetworkManager restart or driver reload occurs during setup. The backend applies when NetworkManager next starts; notch changes apply when appledrm next loads. A live run gives iwd a profile for each Wi-Fi network NetworkManager saved with its key before the switch, as NetworkManager itself does for a new connection, so saved networks keep connecting instead of reading as a wrong password. The greeter drop-ins need no setup: from the next start of `sddm`, or of `greetd`, which shows the login screen since omacom/omarchy#20404, they hold the greeter, for at most 10 s, until Apple's display controller has replaced the boot framebuffer. On a J514C/T6031 boot whose loader handed the GPU and display over (and without `apple_t6031_display.enable=0`) it instead waits up to 30 s for an `apple-drm` card and an `asahi-g15` render device, then settles udev for at most 10 s and rechecks them. This avoids opening the autologin VT during the framebuffer handoff. Missing devices or a settle timeout never fail the login screen; the wait enables no driver and changes no owner settings. Other boards retain their existing display wait. Run `omarchy-mac-setup-user` as each target user with their HOME/XDG directories. It enables the vendor unit without a session bus. It writes nothing into the user's Hyprland files; a block an earlier version appended to `input.lua` or `looknfeel.lua` stays, as the user's. With a live bus, reached only through XDG_RUNTIME_DIR (which `sudo -i` clears), it reloads the user manager, reports the effective unit and starts the mapper. The mapper makes the microphone a typed stereo source, `omarchy_asahi_mic` ("MacBook Microphone"): pipewire-pulse's `module-remap-source` records asahi-audio's mono DSP source (its AUX0 or MONO port), which WirePlumber links to the left side and the mapper to the right, or to a single MONO capture port when PipeWire negotiates one, and offers an `Audio/Source` with front-left and front-right, the shape of a stock microphone, so the desktop's audio panel drives its volume, mute and level meter as it does any other. It makes that source the default input only if a brief sample finds signal, and hands a silent one back to the DSP source. A muted mapping is the user's microphone mute and is left alone. On upgrade from 0.1.2 the mapper replaces 0.1.2's virtual source of the same name (an `Audio/Source/Virtual`, which the panel gives no level meter), keeping its gain, mute and selection. pacman restarts no user service, so a running mapper watches its own file: once an upgrade has replaced it and the transaction has ended, it runs the new file in place, within a few seconds, and that reconciles the live session. At session start the mapper subscribes to audio events before its first pass, so a DSP microphone that appears after it starts is mapped and made the default input at once. Provisioning and first run call setup; subsequent session starts only start the enabled unit, without reloading the user manager or repeating setup. The first desktop session does not depend on a bus existing during installation. Custom fragments, masks, activation links and headset or speaker policies are preserved; setup markers preserve explicit disables after initial setup. User gain state remains in `omarchy/asahi-mic-gain.json` under XDG_STATE_HOME. The desktop saves that state before restarting audio. @@ -41,9 +41,9 @@ Vendor defaults use NetworkManager's `/usr/lib/NetworkManager/conf.d`, systemd's ## Video decode in mpv -mpv has no vendor configuration directory and decodes in software unless told otherwise. The package ships its Apple default as `/usr/share/omarchy-mac/mpv/mpv.conf` and a systemd-tmpfiles rule that copies it to `/etc/mpv/mpv.conf` only when that file is missing. pacman's systemd hook applies the rule when the package is installed or upgraded, and boot applies it again. An existing `/etc/mpv/mpv.conf` is never overwritten, with one exception: `omarchy-mac-setup-system` replaces a regular file byte-identical to the earlier default, which lacks `gpu-sw=yes`, with the current default, and leaves an edited copy or a link alone. An upgrade alone does not apply this, because neither `omarchy update` nor a pacman upgrade runs setup: run `sudo omarchy-mac-setup-system`, or rerun hardware setup, to apply it. So edit it rather than delete it to change the system default; each user's `~/.config/mpv/mpv.conf` is read after it and wins, and `hwdec=no` there decodes in software. +mpv has no vendor configuration directory and decodes in software unless told otherwise. The package ships its Apple default as `/usr/share/omarchy-mac/mpv/mpv.conf` and a systemd-tmpfiles rule that copies it to `/etc/mpv/mpv.conf` only when that file is missing. pacman's systemd hook applies the rule when the package is installed or upgraded, and boot applies it again. An existing `/etc/mpv/mpv.conf` is never overwritten, with one exception: `/usr/lib/omarchy-mac/mpv-default-sync`, invoked both by `omarchy-mac-setup-system` and by `92-omarchy-mac-mpv-default.hook` after an `omarchy-mac` install or upgrade on a booted system, replaces a regular file byte-identical to an earlier released default (`0.1.0`–`0.2.2` without `gpu-sw=yes`, `0.2.3-1`, or `0.2.3-2`–`0.2.12` with `vo=gpu`) with the current default, and leaves an edited copy or a link alone. So edit `/etc/mpv/mpv.conf` rather than delete it to change the system default and opt out of default upgrades; each user's `~/.config/mpv/mpv.conf` is read after it and wins (`hwdec=no` decodes in software, `vo=gpu` restores the legacy OpenGL renderer). -The default decodes H.264, HEVC and VP9 on the Apple Video Decoder with copy-back (`hwdec=vaapi-copy`, `hwdec-codecs=h264,hevc,vp9`) and draws with the OpenGL renderer (`vo=gpu`, `gpu-api=opengl`). On an M2 Max, copy-back is bit-exact against software decoding, and 1080p playback falls from about 55% to 13% of a core. Zero-copy (`hwdec=vaapi`) is not used: Asahi's Vulkan driver reads the imported chroma plane from the wrong offset, so gpu-next shows green frames, and `libva-v4l2_request` invalidates the frames of a decoder it closes, which copy-back has already copied out. gpu-next also costs about three times the CPU of OpenGL to upload copied frames. `libva-v4l2_request-avd` and `avd-fw` provide the decoder; without them mpv falls back to software. +The default decodes H.264, HEVC and VP9 on the Apple Video Decoder with copy-back (`hwdec=vaapi-copy`, `hwdec-codecs=h264,hevc,vp9`) and draws with libplacebo over OpenGL (`vo=gpu-next`, `gpu-api=opengl`, `target-colorspace-hint=yes`, `target-colorspace-hint-mode=source`). On an M2 Max, copy-back is bit-exact against software decoding, and 1080p playback falls from about 55% to 13% of a core. Zero-copy (`hwdec=vaapi`) is not used: Asahi's Vulkan driver reads the imported chroma plane from the wrong offset, so Vulkan zero-copy shows green frames, and `libva-v4l2_request` invalidates the frames of a decoder it closes, which copy-back has already copied out. Earlier M2 measurements saw `gpu-next` take about three times the CPU of `vo=gpu` on Vulkan, but over OpenGL the cost matches `vo=gpu`: on a 16" M4 Pro (J616s, mpv 0.42.0, fullscreen 3456×2234, median of 3×30 s runs, mpv CPU as % of one core), `vo=gpu` vs `vo=gpu-next` over OpenGL measured 1.9% vs 2.2% on H.264 1080p30 (VA-API), 7.2% vs 6.9% on H.264 2160p60 (VA-API), 19.5% vs 17.2% on HEVC 1080p60 (SW), 72.9% vs 69.0% on HEVC 2160p60 (SW), and 45.4% vs 43.5% on HEVC 2160p30 PQ (SW), with zero dropped frames in all runs and BT.2020/PQ Wayland surface tagging on the HDR clip. `libva-v4l2_request-avd` and `avd-fw` provide the decoder; without them mpv falls back to software. On a Mac whose GPU has no driver yet, such as the M3 Max, the only OpenGL renderer is Mesa's software one: llvmpipe, or softpipe where Mesa is built without LLVM. mpv rejects a software renderer while probing, and mpv 0.41 then aborts with `vo_x11_init: Assertion '!vo->x11' failed`: its Wayland context does not clean up after a failed init, and the X11 context it tries next asserts on the leftover (fixed upstream in mpv-player/mpv@a58dd8ac41, not yet in a release). `gpu-sw=yes` lets mpv draw on llvmpipe or softpipe there instead. It changes nothing where the context mpv picks has a hardware renderer. diff --git a/omarchy-mac/bin/omarchy-mac-setup-system b/omarchy-mac/bin/omarchy-mac-setup-system index 808aded7..4b0ebce3 100755 --- a/omarchy-mac/bin/omarchy-mac-setup-system +++ b/omarchy-mac/bin/omarchy-mac-setup-system @@ -51,19 +51,10 @@ elif [[ -f $brcmfmac ]] && grep -Fxq -- "$quirk" "$brcmfmac"; then echo "Removed the Intel Mac Broadcom quirk from $brcmfmac; it stops applying at the next reboot" fi -# The earlier mpv default lacks gpu-sw, so mpv aborts where the GPU has no -# driver, and tmpfiles never replaces the copy it made. Only a regular file -# byte-identical to that copy takes the new default; edits and links stay. -mpv="$root/etc/mpv/mpv.conf" -released_mpv_sum=9e186dd88be483b3666795b805e780921adecd1051ae85986857c22152a2d818 -if [[ -f $mpv && ! -L $mpv ]] && [[ $(sha256sum <"$mpv") == "$released_mpv_sum -" ]]; then - updated=$(mktemp "$root/etc/mpv/.mpv.conf.XXXXXX") - cp -- "$root/usr/share/omarchy-mac/mpv/mpv.conf" "$updated" || { rm -f -- "$updated"; exit 1; } - chown --reference="$mpv" "$updated" - chmod --reference="$mpv" "$updated" - mv -- "$updated" "$mpv" - echo "Updated $mpv to the current omarchy-mac default, which lets mpv draw in software where the GPU has no driver" -fi +# Earlier mpv defaults lack gpu-sw (0.1.0-0.2.2) or Wayland colorspace hints +# (0.2.3-0.2.12), and tmpfiles never replaces the copy it made. +# Delegate to mpv-default-sync so setup and the pacman hook share one list. +"$root/usr/lib/omarchy-mac/mpv-default-sync" "${root:-/}" unit=omarchy-wifi-resume-fix.service marker="$root/var/lib/omarchy-mac/wifi-configured" diff --git a/omarchy-mac/lib/mpv-default-sync b/omarchy-mac/lib/mpv-default-sync new file mode 100755 index 00000000..5202f06c --- /dev/null +++ b/omarchy-mac/lib/mpv-default-sync @@ -0,0 +1,24 @@ +#!/bin/bash +# Replace an untouched earlier omarchy-mac /etc/mpv/mpv.conf copy with the +# current vendor default. Administrator edits, symlinks and missing files stay. +# Optional root permits offline provisioning and tests. +set -euo pipefail +root=${1:-/} +root=${root%/} +[[ -z $root || $root == /* ]] || exit 2 +omarchy-hw-apple-silicon || exit 0 + +mpv="$root/etc/mpv/mpv.conf" +vendor="$root/usr/share/omarchy-mac/mpv/mpv.conf" +[[ -f $vendor ]] || exit 0 + +# Released defaults: 0.1.0-0.2.2 (no gpu-sw), 0.2.3-1, and 0.2.3-2 to 0.2.12 (vo=gpu). +released_mpv_sums=" 9e186dd88be483b3666795b805e780921adecd1051ae85986857c22152a2d818 0822424277cfdecb4cacae13840a4f1d857602248dfaddf4e09246d6b81c891d 3875d4bd3d4e64c8ffb95429d4029c5e4b47a94f36ae9d4132dfca95ba3c0a67 " +if [[ -f $mpv && ! -L $mpv ]] && [[ $released_mpv_sums == *" $(sha256sum <"$mpv" | cut -d' ' -f1) "* ]]; then + updated=$(mktemp "$root/etc/mpv/.mpv.conf.XXXXXX") + cp -- "$vendor" "$updated" || { rm -f -- "$updated"; exit 1; } + chown --reference="$mpv" "$updated" + chmod --reference="$mpv" "$updated" + mv -- "$updated" "$mpv" + echo "Updated $mpv to the current omarchy-mac default, which uses gpu-next over OpenGL with Wayland colorspace hints" +fi diff --git a/omarchy-mac/share/libalpm/hooks/92-omarchy-mac-mpv-default.hook b/omarchy-mac/share/libalpm/hooks/92-omarchy-mac-mpv-default.hook new file mode 100644 index 00000000..4cb4108d --- /dev/null +++ b/omarchy-mac/share/libalpm/hooks/92-omarchy-mac-mpv-default.hook @@ -0,0 +1,13 @@ +# Update an untouched earlier omarchy-mac /etc/mpv/mpv.conf default after an +# omarchy-mac install or upgrade. Administrator edits and symlinks are preserved. +[Trigger] +Type = Package +Operation = Install +Operation = Upgrade +Target = omarchy-mac + +[Action] +Description = Updating untouched omarchy-mac mpv default... +When = PostTransaction +# Skipped in a chroot or an unbooted root; never fails the transaction. +Exec = /usr/bin/sh -c 'systemd-detect-virt --quiet --chroot || ! systemd-notify --booted || /usr/lib/omarchy-mac/mpv-default-sync || true' diff --git a/omarchy-mac/share/omarchy-mac/mpv/mpv.conf b/omarchy-mac/share/omarchy-mac/mpv/mpv.conf index 73bceb4d..62416d8c 100644 --- a/omarchy-mac/share/omarchy-mac/mpv/mpv.conf +++ b/omarchy-mac/share/omarchy-mac/mpv/mpv.conf @@ -1,22 +1,25 @@ # Omarchy on Apple Silicon: mpv decodes H.264, HEVC and VP9 on the Apple Video -# Decoder and draws with the OpenGL renderer. +# Decoder and draws with libplacebo (gpu-next) over OpenGL. # # vaapi-copy returns each decoded frame to memory, bit for bit what software -# decoding gives. Zero-copy (hwdec=vaapi) turns green through gpu-next, whose -# Vulkan import on Asahi reads the colour plane from the wrong offset, and it -# keeps frames the VA driver invalidates when its decoder closes. OpenGL draws -# the copied frames for about a third of the CPU gpu-next needs here. +# decoding gives. Zero-copy (hwdec=vaapi) turns green through Vulkan import on +# Asahi and keeps frames the VA driver invalidates when its decoder closes. +# Over OpenGL, gpu-next matched vo=gpu on a 16" M4 Pro across H.264 and HEVC up +# to 4K60 (the earlier ~3x overhead figure did not hold on OpenGL) while letting +# Wayland source colorspace hints tag HDR surfaces for the compositor. # # systemd-tmpfiles copies this file from /usr/share/omarchy-mac/mpv/mpv.conf when # /etc/mpv/mpv.conf is missing, and never overwrites it. The one exception: -# omarchy-mac-setup-system replaces an unedited copy of the earlier default, -# which lacked gpu-sw, with this one. Your own ~/.config/mpv/mpv.conf is read -# after it and wins: hwdec=no decodes in software, vo=gpu-next with gpu-api=auto -# restores mpv's default renderer. +# omarchy-mac-setup-system and 92-omarchy-mac-mpv-default.hook replace an +# unedited copy of an earlier released default with this one. Edit /etc/mpv/mpv.conf +# or use ~/.config/mpv/mpv.conf (read after it, so it wins) to keep your own +# settings: hwdec=no decodes in software, vo=gpu restores the legacy OpenGL VO. hwdec=vaapi-copy hwdec-codecs=h264,hevc,vp9 -vo=gpu +vo=gpu-next gpu-api=opengl +target-colorspace-hint=yes +target-colorspace-hint-mode=source # A Mac whose GPU has no driver yet renders on llvmpipe or softpipe; mpv 0.41 # rejects either and then aborts in its X11 fallback. Where the context mpv # picks has a hardware renderer, this changes nothing. diff --git a/omarchy-mac/test/mpv-0.2.12.conf b/omarchy-mac/test/mpv-0.2.12.conf new file mode 100644 index 00000000..73bceb4d --- /dev/null +++ b/omarchy-mac/test/mpv-0.2.12.conf @@ -0,0 +1,23 @@ +# Omarchy on Apple Silicon: mpv decodes H.264, HEVC and VP9 on the Apple Video +# Decoder and draws with the OpenGL renderer. +# +# vaapi-copy returns each decoded frame to memory, bit for bit what software +# decoding gives. Zero-copy (hwdec=vaapi) turns green through gpu-next, whose +# Vulkan import on Asahi reads the colour plane from the wrong offset, and it +# keeps frames the VA driver invalidates when its decoder closes. OpenGL draws +# the copied frames for about a third of the CPU gpu-next needs here. +# +# systemd-tmpfiles copies this file from /usr/share/omarchy-mac/mpv/mpv.conf when +# /etc/mpv/mpv.conf is missing, and never overwrites it. The one exception: +# omarchy-mac-setup-system replaces an unedited copy of the earlier default, +# which lacked gpu-sw, with this one. Your own ~/.config/mpv/mpv.conf is read +# after it and wins: hwdec=no decodes in software, vo=gpu-next with gpu-api=auto +# restores mpv's default renderer. +hwdec=vaapi-copy +hwdec-codecs=h264,hevc,vp9 +vo=gpu +gpu-api=opengl +# A Mac whose GPU has no driver yet renders on llvmpipe or softpipe; mpv 0.41 +# rejects either and then aborts in its X11 fallback. Where the context mpv +# picks has a hardware renderer, this changes nothing. +gpu-sw=yes diff --git a/omarchy-mac/test/mpv-0.2.3-1.conf b/omarchy-mac/test/mpv-0.2.3-1.conf new file mode 100644 index 00000000..6af03174 --- /dev/null +++ b/omarchy-mac/test/mpv-0.2.3-1.conf @@ -0,0 +1,23 @@ +# Omarchy on Apple Silicon: mpv decodes H.264, HEVC and VP9 on the Apple Video +# Decoder and draws with the OpenGL renderer. +# +# vaapi-copy returns each decoded frame to memory, bit for bit what software +# decoding gives. Zero-copy (hwdec=vaapi) turns green through gpu-next, whose +# Vulkan import on Asahi reads the colour plane from the wrong offset, and it +# keeps frames the VA driver invalidates when its decoder closes. OpenGL draws +# the copied frames for about a third of the CPU gpu-next needs here. +# +# systemd-tmpfiles copies this file from /usr/share/omarchy-mac/mpv/mpv.conf when +# /etc/mpv/mpv.conf is missing, and never overwrites it. The one exception: +# omarchy-mac-setup-system replaces an unedited copy from omarchy-mac 0.2.2 or +# earlier with this one. Your own ~/.config/mpv/mpv.conf is read after it and +# wins: hwdec=no decodes in software, vo=gpu-next with gpu-api=auto restores +# mpv's default renderer. +hwdec=vaapi-copy +hwdec-codecs=h264,hevc,vp9 +vo=gpu +gpu-api=opengl +# A Mac whose GPU has no driver yet renders on llvmpipe or softpipe; mpv 0.41 +# rejects either and then aborts in its X11 fallback. Where the context mpv +# picks has a hardware renderer, this changes nothing. +gpu-sw=yes diff --git a/omarchy-mac/test/mpv-test.sh b/omarchy-mac/test/mpv-test.sh index 0a5f3b41..ee247460 100755 --- a/omarchy-mac/test/mpv-test.sh +++ b/omarchy-mac/test/mpv-test.sh @@ -16,11 +16,13 @@ cmp -s "$work/fresh/etc/mpv/mpv.conf" "$work/fresh/usr/share/omarchy-mac/mpv/mpv fail 'mpv decodes on AVD with copy-back, never zero-copy' "$(setting "$work/fresh" hwdec)" [[ $(setting "$work/fresh" hwdec-codecs) == "h264,hevc,vp9" ]] || fail 'mpv asks AVD only for the codecs it decodes' "$(setting "$work/fresh" hwdec-codecs)" -[[ $(setting "$work/fresh" vo) == "gpu" && $(setting "$work/fresh" gpu-api) == "opengl" ]] || - fail 'mpv draws copied frames with the OpenGL renderer' +[[ $(setting "$work/fresh" vo) == "gpu-next" && $(setting "$work/fresh" gpu-api) == "opengl" ]] || + fail 'mpv draws copied frames with gpu-next over OpenGL' +[[ $(setting "$work/fresh" target-colorspace-hint) == "yes" && $(setting "$work/fresh" target-colorspace-hint-mode) == "source" ]] || + fail 'mpv sends source colorspace hints for Wayland HDR' [[ $(setting "$work/fresh" gpu-sw) == "yes" ]] || fail 'mpv draws in software on a Mac whose GPU has no driver yet' "$(setting "$work/fresh" gpu-sw)" -pass 'a fresh install decodes H.264, HEVC and VP9 on AVD in mpv, with copy-back and OpenGL, and draws in software without a GPU driver' +pass 'a fresh install decodes H.264, HEVC and VP9 on AVD in mpv, with copy-back, gpu-next over OpenGL, Wayland colorspace hints and software fallback' # An upgraded Mac already has /etc/mpv from mpv-mpris. "$ROOT"/install "$work/upgrade" @@ -122,3 +124,44 @@ rm -r "$work/other/etc/mpv" setup "$work/other" [[ ! -e $work/other/etc/mpv ]] || fail 'setup creates no mpv.conf where none exists' pass 'an edited or linked mpv default, another machine and a missing one are left to tmpfiles and the administrator' + +# omarchy-mac 0.2.3-1 (60d03b7) and 0.2.3-2..0.2.12 copied defaults with vo=gpu; +# setup and mpv-default-sync replace them while untouched and leave edits alone. +for release in 0.2.3-1 0.2.12; do + fixture="$ROOT/test/mpv-$release.conf" + released "$work/v$release" + install -m644 "$fixture" "$work/v$release/etc/mpv/mpv.conf" + setup "$work/v$release" + cmp -s "$work/v$release/etc/mpv/mpv.conf" "$work/v$release/usr/share/omarchy-mac/mpv/mpv.conf" || + fail "setup replaces an untouched $release mpv default" + [[ $(setting "$work/v$release" vo) == "gpu-next" && $(setting "$work/v$release" target-colorspace-hint) == "yes" ]] || + fail "the replaced $release default enables gpu-next and target-colorspace-hint" + released "$work/v${release}e" + install -m644 "$fixture" "$work/v${release}e/etc/mpv/mpv.conf" + printf 'vo=gpu\n' >>"$work/v${release}e/etc/mpv/mpv.conf" + cp "$work/v${release}e/etc/mpv/mpv.conf" "$work/expected" + setup "$work/v${release}e" + cmp -s "$work/v${release}e/etc/mpv/mpv.conf" "$work/expected" || fail "an edited $release default stays" +done +pass 'untouched 0.2.3-1 and 0.2.12 mpv defaults take gpu-next over OpenGL at setup; edited ones stay' + +# Pacman hook and direct mpv-default-sync helper: staged properly, gated on +# Apple Silicon, and chroot/unbooted-root safe. +hook="$work/fresh/usr/share/libalpm/hooks/92-omarchy-mac-mpv-default.hook" +helper="$work/fresh/usr/lib/omarchy-mac/mpv-default-sync" +[[ -f $hook && ! -L $hook ]] || fail 'stages the mpv default sync pacman hook' +[[ -x $helper && $(stat -c %a "$helper") == "755" ]] || fail 'stages the mpv default sync helper executable' +grep -Fxq 'Target = omarchy-mac' "$hook" || fail 'hook triggers on omarchy-mac' +grep -Fxq 'When = PostTransaction' "$hook" || fail 'hook runs PostTransaction' +grep -Fq 'systemd-detect-virt --quiet --chroot' "$hook" || fail 'hook skips chroots' +grep -Fq '! systemd-notify --booted' "$hook" || fail 'hook skips unbooted roots' +grep -Fq '/usr/lib/omarchy-mac/mpv-default-sync' "$hook" || fail 'hook invokes mpv-default-sync' +released "$work/hook-sync" +install -m644 "$ROOT/test/mpv-0.2.12.conf" "$work/hook-sync/etc/mpv/mpv.conf" +PLATFORM=x86 "$work/hook-sync/usr/lib/omarchy-mac/mpv-default-sync" "$work/hook-sync" +cmp -s "$work/hook-sync/etc/mpv/mpv.conf" "$ROOT/test/mpv-0.2.12.conf" || + fail 'mpv-default-sync does nothing off Apple Silicon' +"$work/hook-sync/usr/lib/omarchy-mac/mpv-default-sync" "$work/hook-sync" >/dev/null +cmp -s "$work/hook-sync/etc/mpv/mpv.conf" "$work/hook-sync/usr/share/omarchy-mac/mpv/mpv.conf" || + fail 'mpv-default-sync replaces an untouched 0.2.12 mpv default on Apple Silicon' +pass 'pacman hook and mpv-default-sync update untouched defaults on Apple Silicon only' diff --git a/omarchy-mac/test/setup-test.sh b/omarchy-mac/test/setup-test.sh index e8401f43..587a182b 100644 --- a/omarchy-mac/test/setup-test.sh +++ b/omarchy-mac/test/setup-test.sh @@ -173,7 +173,7 @@ pass 'user setup skips the user bus when sudo cleared XDG_RUNTIME_DIR' # running or disabled one alone. mkdir -p "$work/live" "$work/live-bin" "$stage/usr/lib/systemd/system" touch "$stage/usr/lib/systemd/system/speakersafetyd.service" -sed -e "s|\$root/|$stage/|g" -e "s|-d /run/systemd/system|-d $work/live|" "$setup" >"$work/live-setup" +sed -e "s|\$root/|$stage/|g" -e "s|\${root:-/}|$stage|g" -e "s|-d /run/systemd/system|-d $work/live|" "$setup" >"$work/live-setup" chmod +x "$work/live-setup" cat >"$work/live-bin/systemctl" <<'STUB' #!/bin/bash