mirror of
https://github.com/lucannez64/darling-lol.git
synced 2026-10-26 19:47:42 +00:00
Report the MacBookPro16,1 GPU name for Riot on AMD and Intel hosts
With DARLING_METAL_MAC_GPU_NAME=1, MTLDevice.name is the GPU the MacBookPro16,1 that IOKit reports shipped with, from the host's vendor: "AMD Radeon Pro 5500M" (vendor 0x1002) or "Intel UHD Graphics 630" (0x8086). NVIDIA keeps its own name so the game never takes another vendor's driver paths. recommendedMaxWorkingSetSize and every other value stay the host's, which was the risky part of #61's identity. The Riot launcher turns it on by default (0 or empty turns it off); other Darling apps keep the host name. DARLING_METAL_GPU_NAME still wins. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
3752d9e812
commit
59327fa9f0
5 files changed
+60
-15
No files matched your search
@@ -387,6 +387,13 @@ Both can be overridden per launch:
|
||||
DARLING_METAL_GPU_NAME='AMD Radeon Pro 5500M' DARLING_METAL_VRAM_MB=4096 ./scripts/run.sh
|
||||
```
|
||||
|
||||
The Riot launcher sets `DARLING_METAL_MAC_GPU_NAME=1`: the name becomes the GPU that
|
||||
the MacBookPro16,1 IOKit reports shipped with, from the host's vendor: `AMD Radeon Pro 5500M`
|
||||
on AMD and `Intel UHD Graphics 630` on Intel. NVIDIA GPUs keep their own name, so the game
|
||||
never takes AMD or Intel driver paths on an NVIDIA card. The working set is still the host's.
|
||||
`DARLING_METAL_MAC_GPU_NAME=0 ./scripts/run.sh` reports the host name instead; other Darling
|
||||
apps report it unless they set the variable. `DARLING_METAL_GPU_NAME` wins over both.
|
||||
|
||||
`registryID` is a fixed non-zero value, as on a real Mac.
|
||||
|
||||
### Host-side checks
|
||||
|
||||
+36
-14
@@ -1134,7 +1134,7 @@ index 2a57796..0cbedf2 100644
|
||||
-
|
||||
@end
|
||||
diff --git a/src/Metal/MTLDevice.mm b/src/Metal/MTLDevice.mm
|
||||
index f58184a..ed918ed 100644
|
||||
index f58184a..2c45608 100644
|
||||
--- a/src/Metal/MTLDevice.mm
|
||||
+++ b/src/Metal/MTLDevice.mm
|
||||
@@ -2,14 +2,32 @@
|
||||
@@ -1218,7 +1218,7 @@ index f58184a..ed918ed 100644
|
||||
}
|
||||
|
||||
@synthesize device = _device;
|
||||
@@ -116,6 +168,44 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
@@ -116,6 +168,50 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
[_threadExitCondition unlock];
|
||||
}
|
||||
|
||||
@@ -1228,21 +1228,27 @@ index f58184a..ed918ed 100644
|
||||
+ // Overrides are read once per process.
|
||||
+ static const char* const nameOverride = getenv("DARLING_METAL_GPU_NAME");
|
||||
+ static const uint64_t vramOverride = MTLDeviceInfo::parseMegabytes(getenv("DARLING_METAL_VRAM_MB"));
|
||||
+ static const bool macName = [] {
|
||||
+ const char* value = getenv("DARLING_METAL_MAC_GPU_NAME");
|
||||
+ return value && value[0] == '1' && value[1] == '\0';
|
||||
+ }();
|
||||
+
|
||||
+ auto priv = dynamic_cast<Indium::PrivateDevice*>(_device.get());
|
||||
+ std::string vulkanName;
|
||||
+ try {
|
||||
+ vulkanName = _device ? _device->name() : "";
|
||||
+ } catch (...) {
|
||||
+ vulkanName = "";
|
||||
+ }
|
||||
+ _name = [[NSString alloc] initWithUTF8String: MTLDeviceInfo::resolveName(nameOverride, vulkanName.c_str()).c_str()];
|
||||
+ const char* mac = macName && priv ? MTLDeviceInfo::macGpuName(priv->properties().vendorID) : nullptr;
|
||||
+ _name = [[NSString alloc] initWithUTF8String: MTLDeviceInfo::resolveName(nameOverride, vulkanName.c_str(), mac).c_str()];
|
||||
+ if (_name == nil) {
|
||||
+ _name = [[NSString alloc] initWithUTF8String: MTLDeviceInfo::kFallbackName];
|
||||
+ }
|
||||
+
|
||||
+ uint64_t workingSet = 0;
|
||||
+ _sharesSystemMemory = NO;
|
||||
+ if (auto priv = dynamic_cast<Indium::PrivateDevice*>(_device.get())) {
|
||||
+ if (priv) {
|
||||
+ const VkPhysicalDeviceType type = priv->properties().deviceType;
|
||||
+ _sharesSystemMemory = type == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU || type == VK_PHYSICAL_DEVICE_TYPE_CPU;
|
||||
+ const VkPhysicalDeviceMemoryProperties memory = priv->memoryProperties();
|
||||
@@ -1263,7 +1269,7 @@ index f58184a..ed918ed 100644
|
||||
- (instancetype)initWithDevice: (std::shared_ptr<Indium::Device>)device
|
||||
{
|
||||
self = [super init];
|
||||
@@ -123,6 +213,7 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
@@ -123,6 +219,7 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
_device = device;
|
||||
_threadExitCondition = [NSCondition new];
|
||||
_threadIsRunning = NO;
|
||||
@@ -1271,7 +1277,7 @@ index f58184a..ed918ed 100644
|
||||
_pollingThread = [[NSThread alloc] initWithTarget: self selector: @selector(pollingLoop) object: nil];
|
||||
[_pollingThread start];
|
||||
}
|
||||
@@ -133,6 +224,7 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
@@ -133,6 +230,7 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
{
|
||||
[_pollingThread release];
|
||||
[_threadExitCondition release];
|
||||
@@ -1279,7 +1285,7 @@ index f58184a..ed918ed 100644
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
@@ -153,12 +245,60 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
@@ -153,12 +251,60 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
[_threadExitCondition unlock];
|
||||
}
|
||||
|
||||
@@ -1341,7 +1347,7 @@ index f58184a..ed918ed 100644
|
||||
if (!pso) {
|
||||
if (error) {
|
||||
// TODO: better error and/or match what the official Metal method does
|
||||
@@ -166,6 +306,7 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
@@ -166,6 +312,7 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
@@ -1349,7 +1355,7 @@ index f58184a..ed918ed 100644
|
||||
return [[MTLComputePipelineStateInternal alloc] initWithState: pso device: self label: descriptor.label];
|
||||
}
|
||||
|
||||
@@ -183,7 +324,13 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
@@ -183,7 +330,13 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
reflection: (MTLAutoreleasedComputePipelineReflection*)reflection
|
||||
error: (NSError**)error
|
||||
{
|
||||
@@ -1364,7 +1370,7 @@ index f58184a..ed918ed 100644
|
||||
if (!pso) {
|
||||
if (error) {
|
||||
// TODO: better error and/or match what the official Metal method does
|
||||
@@ -191,13 +338,44 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
@@ -191,13 +344,44 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
@@ -1410,7 +1416,7 @@ index f58184a..ed918ed 100644
|
||||
if (!pso) {
|
||||
if (error) {
|
||||
// TODO: better error and/or match what the official Metal method does
|
||||
@@ -205,7 +383,118 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
@@ -205,7 +389,118 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
@@ -1530,7 +1536,7 @@ index f58184a..ed918ed 100644
|
||||
}
|
||||
|
||||
- (id<MTLCommandQueue>)newCommandQueue
|
||||
@@ -275,8 +564,21 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
@@ -275,8 +570,21 @@ void MTLRemoveDeviceObserver(id<NSObject> observer) {
|
||||
- (id<MTLLibrary>)newLibraryWithData: (dispatch_data_t)data
|
||||
error: (NSError**)error
|
||||
{
|
||||
@@ -3482,7 +3488,7 @@ diff --git a/private-include/Metal/MTLDeviceInfo.h b/private-include/Metal/MTLDe
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/private-include/Metal/MTLDeviceInfo.h
|
||||
@@ -0,0 +1,150 @@
|
||||
@@ -0,0 +1,166 @@
|
||||
+// SPDX-FileCopyrightText: 2026 Darling Developers
|
||||
+// SPDX-License-Identifier: MPL-2.0
|
||||
+
|
||||
@@ -3582,10 +3588,26 @@ new file mode 100644
|
||||
+}
|
||||
+
|
||||
+// DARLING_METAL_GPU_NAME (used verbatim when non-empty) wins over the Vulkan name.
|
||||
+static inline std::string resolveName(const char* overrideName, const char* vulkanName) {
|
||||
+// With DARLING_METAL_MAC_GPU_NAME=1: the GPU from the host's vendor that the MacBookPro16,1
|
||||
+// iokitd reports shipped with, by Vulkan vendor ID. nullptr for other vendors (NVIDIA), which
|
||||
+// keep their own name so apps never take another vendor's driver paths.
|
||||
+static inline const char* macGpuName(uint32_t vendorID) {
|
||||
+ switch (vendorID) {
|
||||
+ case 0x1002: return "AMD Radeon Pro 5500M";
|
||||
+ case 0x8086: return "Intel UHD Graphics 630";
|
||||
+ default: return nullptr;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+// DARLING_METAL_GPU_NAME wins, then the Mac GPU name (when enabled and known), then the
|
||||
+// cleaned Vulkan name.
|
||||
+static inline std::string resolveName(const char* overrideName, const char* vulkanName, const char* macName = nullptr) {
|
||||
+ if (overrideName && overrideName[0] != '\0') {
|
||||
+ return overrideName;
|
||||
+ }
|
||||
+ if (macName && macName[0] != '\0') {
|
||||
+ return macName;
|
||||
+ }
|
||||
+ return metalNameFromVulkanName(vulkanName);
|
||||
+}
|
||||
+
|
||||
|
||||
@@ -40,6 +40,7 @@ class MetalDeviceInfoTests(unittest.TestCase):
|
||||
self.assertEqual(result.returncode, 0, result.stdout)
|
||||
self.assertIn('METAL_DEVICE_INFO failures=0 pass=1', result.stdout)
|
||||
self.assertIn('PASS registry ID is non-zero', result.stdout)
|
||||
self.assertIn('PASS Mac GPU name', result.stdout)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -29,7 +29,9 @@ unset RCLOL_APP_ARG3 RCLOL_APP_ARG3_SLOT RCLOL_UX_ARG1 RCLOL_UX_ARG1_SLOT
|
||||
unset RCLOL_UX_ARG2 RCLOL_UX_ARG2_SLOT
|
||||
# The paired runtime presents completed GPU textures without CPU readback.
|
||||
# Explicit 0 or an empty value selects the CPU fallback for diagnostics.
|
||||
for option in RCLOL_GPU_DIRECT_PRESENT RCLOL_GPU_DIRECT_ASYNC RCLOL_GPU_DIRECT_VSYNC DARLING_CA_PRESENT_AT_COMMIT DARLING_CA_SKIP_LOCAL_IOSURFACE_RENDER RCLOL_FORWARD_MOUSE_MOVED RCLOL_MOUSE_CONFINEMENT; do
|
||||
# DARLING_METAL_MAC_GPU_NAME reports the MacBookPro16,1 GPU of the host vendor (AMD or Intel) as
|
||||
# MTLDevice.name, matching the model IOKit reports; memory figures stay the host's.
|
||||
for option in RCLOL_GPU_DIRECT_PRESENT RCLOL_GPU_DIRECT_ASYNC RCLOL_GPU_DIRECT_VSYNC DARLING_CA_PRESENT_AT_COMMIT DARLING_CA_SKIP_LOCAL_IOSURFACE_RENDER RCLOL_FORWARD_MOUSE_MOVED RCLOL_MOUSE_CONFINEMENT DARLING_METAL_MAC_GPU_NAME; do
|
||||
eval 'value=${'"$option"'-1}'
|
||||
case "$value" in 0|'') unset "$option";; *) export "$option=$value";; esac
|
||||
done
|
||||
|
||||
@@ -65,6 +65,19 @@ int main() {
|
||||
std::printf("%s name override\n", ok ? "PASS" : "FAIL");
|
||||
}
|
||||
|
||||
// DARLING_METAL_MAC_GPU_NAME: MacBookPro16,1 GPUs for AMD and Intel hosts; NVIDIA keeps its name.
|
||||
{
|
||||
using MTLDeviceInfo::macGpuName;
|
||||
bool ok = std::string(macGpuName(0x1002)) == "AMD Radeon Pro 5500M"
|
||||
&& std::string(macGpuName(0x8086)) == "Intel UHD Graphics 630"
|
||||
&& macGpuName(0x10de) == nullptr
|
||||
&& MTLDeviceInfo::resolveName(nullptr, "AMD Radeon RX 6600 (RADV NAVI23)", macGpuName(0x1002)) == "AMD Radeon Pro 5500M"
|
||||
&& MTLDeviceInfo::resolveName(nullptr, "NVIDIA GeForce GTX 1060 6GB", macGpuName(0x10de)) == "NVIDIA GeForce GTX 1060 6GB"
|
||||
&& MTLDeviceInfo::resolveName("My GPU", "AMD Radeon RX 6600 (RADV NAVI23)", macGpuName(0x1002)) == "My GPU";
|
||||
failures += !ok;
|
||||
std::printf("%s Mac GPU name\n", ok ? "PASS" : "FAIL");
|
||||
}
|
||||
|
||||
// DARLING_METAL_VRAM_MB parsing: positive decimal integer only.
|
||||
const unsigned long long MiB = 1024ull * 1024ull;
|
||||
expectBytes("vram \"8192\"", MTLDeviceInfo::parseMegabytes("8192"), 8192 * MiB);
|
||||
|
||||
Reference in new issue
Block a user