Skip to content

Commit 842ba9f

Browse files
committed
GPU: use driver reported adapter name if available
1 parent 5058a93 commit 842ba9f

File tree

5 files changed

+30
-21
lines changed

5 files changed

+30
-21
lines changed

src/detection/gpu/gpu_amd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,8 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
6868
if (result.index)
6969
*result.type = (uint32_t) device->adlAdapterIndex;
7070

71+
if (result.name)
72+
ffStrbufSetS(result.name, device->adapterString);
73+
7174
return NULL;
7275
}

src/detection/gpu/gpu_bsd.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,6 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
4949
gpu->deviceId = (pc->pc_sel.pc_domain * 100000ull) + (pc->pc_sel.pc_bus * 1000ull) + (pc->pc_sel.pc_dev * 10ull) + pc->pc_sel.pc_func;
5050
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
5151

52-
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD)
53-
{
54-
char query[32];
55-
snprintf(query, sizeof(query), "%X,\t%X,", (unsigned) pc->pc_device, (unsigned) pc->pc_revid);
56-
ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name);
57-
}
58-
59-
if (gpu->name.length == 0)
60-
{
61-
ffGPUFillVendorAndName(pc->pc_subclass, pc->pc_vendor, pc->pc_device, gpu);
62-
}
63-
6452
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA && (options->temp || options->driverSpecific))
6553
{
6654
ffDetectNvidiaGpuInfo(&(FFGpuDriverCondition) {
@@ -79,10 +67,22 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
7967
.type = &gpu->type,
8068
.frequency = &gpu->frequency,
8169
.coreUsage = &gpu->coreUsage,
82-
.name = options->driverSpecific ? &gpu->name : NULL,
70+
.name = &gpu->name,
8371
}, "libnvidia-ml.so");
8472
}
8573

74+
if (gpu->name.length == 0)
75+
{
76+
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD)
77+
{
78+
char query[32];
79+
snprintf(query, sizeof(query), "%X,\t%X,", (unsigned) pc->pc_device, (unsigned) pc->pc_revid);
80+
ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name);
81+
}
82+
if (gpu->name.length == 0)
83+
ffGPUFillVendorAndName(pc->pc_subclass, pc->pc_vendor, pc->pc_device, gpu);
84+
}
85+
8686
if (gpu->type == FF_GPU_TYPE_UNKNOWN)
8787
{
8888
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA)

src/detection/gpu/gpu_intel.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,5 +195,8 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
195195
}
196196
}
197197

198+
if (result.name)
199+
ffStrbufSetS(result.name, properties.name);
200+
198201
return NULL;
199202
}

src/detection/gpu/gpu_linux.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,6 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
302302

303303
if (drmKey) ffStrbufSetF(&gpu->platformApi, "DRM (%s)", drmKey);
304304

305-
if (gpu->name.length == 0)
306-
{
307-
ffGPUFillVendorAndName(subclassId, (uint16_t) vendorId, (uint16_t) deviceId, gpu);
308-
}
309-
310305
pciDetectDriver(&gpu->driver, deviceDir, buffer, drmKey);
311306
ffStrbufSubstrBefore(deviceDir, drmDirPathLength);
312307

@@ -367,7 +362,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
367362
.coreUsage = options->driverSpecific ? &gpu->coreUsage : NULL,
368363
.type = &gpu->type,
369364
.frequency = options->driverSpecific ? &gpu->frequency : NULL,
370-
.name = options->driverSpecific ? &gpu->name : NULL,
365+
.name = &gpu->name,
371366
}, soName);
372367
}
373368

@@ -388,6 +383,9 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
388383
}
389384
}
390385

386+
if (gpu->name.length == 0)
387+
ffGPUFillVendorAndName(subclassId, (uint16_t) vendorId, (uint16_t) deviceId, gpu);
388+
391389
return NULL;
392390
}
393391

src/detection/gpu/gpu_windows.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
5757
}
5858

5959
wchar_t buffer[256];
60-
if (SetupDiGetDeviceRegistryPropertyW(hdev, &did, SPDRP_DEVICEDESC, NULL, (PBYTE) buffer, sizeof(buffer), NULL))
61-
ffStrbufSetWS(&gpu->name, buffer);
6260

6361
uint64_t adapterLuid = 0;
6462

@@ -175,11 +173,18 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
175173
.coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : NULL,
176174
.coreUsage = options->driverSpecific ? &gpu->coreUsage : NULL,
177175
.type = &gpu->type,
176+
.name = &gpu->name,
178177
.frequency = options->driverSpecific ? &gpu->frequency : NULL,
179178
},
180179
dllName
181180
);
182181
}
182+
183+
if (!gpu->name.length)
184+
{
185+
if (SetupDiGetDeviceRegistryPropertyW(hdev, &did, SPDRP_DEVICEDESC, NULL, (PBYTE) buffer, sizeof(buffer), NULL))
186+
ffStrbufSetWS(&gpu->name, buffer);
187+
}
183188
}
184189

185190
return NULL;

0 commit comments

Comments
 (0)