You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Settings -> Video -> Output "GPU Index" entry was missing when
running under the Metal video driver, despite being present for
Vulkan and D3D10/11/12. The menu displaylist unconditionally tries
to parse VIDEO_GPU_INDEX, but the CONFIG_INT was only registered for
Vulkan/D3D, so the entry silently dropped out on Metal.
Wire Metal into the existing GPU-index plumbing:
- configuration.{h,c}, config.def.h: add metal_gpu_index settings
int, DEFAULT_METAL_GPU_INDEX, and SETTING_INT binding for config
persistence. All gated on HAVE_METAL.
- gfx/video_driver.c: add GFX_CTX_METAL_API slot to gpu_map so
video_driver_{set,get}_gpu_api_devices() can store/retrieve the
Metal device list.
- menu/menu_setting.c: register CONFIG_INT for metal_gpu_index when
the active driver is "metal", mirroring the vulkan/d3dN pattern.
- menu/cbs/menu_cbs_{left,right}.c: add GFX_CTX_METAL_API wraparound
branches so left/right cycles the selected device.
- gfx/drivers/metal.m: enumerate adapters and publish the device
list to the frontend.
Platform split inside metal.m:
- macOS: use MTLCopyAllDevices() to enumerate every adapter, honour
settings->ints.metal_gpu_index when in range, and fall back to
MTLCreateSystemDefaultDevice() with a RARCH_WARN otherwise (same
bounds-check + fallback pattern as d3d10.c).
- iOS/tvOS: MTLCopyAllDevices() is explicitly API_UNAVAILABLE(ios)
and these platforms only ever expose one GPU. Gated behind
!defined(HAVE_COCOATOUCH); the CocoaTouch path keeps the existing
MTLCreateSystemDefaultDevice() call and publishes a one-element
list so the menu entry still renders sensibly.
Nothing added raises the minimum deployment target (iOS 6.0 Cocoa
TUs don't include metal.m at all; MTLDevice.name and the two device
APIs used have been available since the Metal floor of each
platform).
The GPU list is stored as a plain C struct string_list on a new
_gpu_list ivar, so it crosses the ARC/MRC TU boundary safely.
MTLCopyAllDevices() and MTLCreateSystemDefaultDevice() are both
NS_RETURNS_RETAINED and handled correctly by ARC in metal.m (which
is always compiled -fobjc-arc per the per-file Makefile override);
string_list_append() strdup's its input so the autoreleased NSString
backing -[MTLDevice name].UTF8String is not captured past its
lifetime. dealloc frees the list and clears the frontend slot with
video_driver_set_gpu_api_devices(GFX_CTX_METAL_API, NULL) before
freeing, so a driver reinit can't chase a dangling pointer.
Existing retroarch.cfg files without a metal_gpu_index key default
to 0 (system default device) and keep their previous behaviour.
0 commit comments