Skip to content

Fix Metal startup when default device is unavailable#92

Open
ppkuchta wants to merge 1 commit into
antirez:mainfrom
ppkuchta:metal-enumerated-device-fallback
Open

Fix Metal startup when default device is unavailable#92
ppkuchta wants to merge 1 commit into
antirez:mainfrom
ppkuchta:metal-enumerated-device-fallback

Conversation

@ppkuchta
Copy link
Copy Markdown

Summary

Some macOS systems can enumerate a usable Metal device via MTLCopyAllDevices() while MTLCreateSystemDefaultDevice() still returns nil. In that state ds4 aborts during startup with:

ds4: Metal device not available
ds4: metal backend unavailable; aborting startup

This change keeps the existing default-device path, but if it returns nil, falls back to the first device returned by MTLCopyAllDevices(). When that fallback is used, ds4 logs the selected device name before continuing normal Metal initialization.

Why

On an Apple M3 Max machine, system_profiler reported Metal support and a standalone probe showed:

device count: 1
default: nil

Before this patch, ds4 could not start because it only used MTLCreateSystemDefaultDevice(). After the patch, the same machine starts successfully:

ds4: default Metal device unavailable; using enumerated device Apple M3 Max
ds4: Metal device Apple M3 Max, 64.00 GiB RAM

Validation

  • Rebuilt ds4, ds4-server, and ds4-bench with make
  • Ran ./ds4 --ctx 4096 --inspect successfully on the affected M3 Max machine

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.

1 participant