Skip to content

Commit eae6904

Browse files
committed
GPU (Windows): more method to detect device name
1 parent 102e8fc commit eae6904

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/detection/gpu/gpu_windows.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
6262
gpu->deviceId = 0;
6363
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
6464

65+
unsigned vendorId = 0, deviceId = 0, subSystemId = 0, revId = 0;
66+
if (swscanf(buffer, L"PCI\\VEN_%x&DEV_%x&SUBSYS_%x&REV_%x", &vendorId, &deviceId, &subSystemId, &revId) == 4)
67+
ffStrbufSetStatic(&gpu->vendor, ffGPUGetVendorString(vendorId));
68+
6569
uint32_t pciBus = 0, pciAddr = 0, pciDev = 0, pciFunc = 0;
6670

6771
ULONG pciBufLen = sizeof(pciBus);
@@ -90,9 +94,14 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
9094
FF_HKEY_AUTO_DESTROY hDirectxKey = NULL;
9195
if (ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, regDirectxKey, &hDirectxKey, NULL))
9296
{
93-
uint32_t vendorId = 0;
94-
if(ffRegReadUint(hDirectxKey, L"VendorId", &vendorId, NULL) && vendorId)
95-
ffStrbufSetStatic(&gpu->vendor, ffGPUGetVendorString(vendorId));
97+
if (gpu->vendor.length == 0)
98+
{
99+
uint32_t vendorId = 0;
100+
if(ffRegReadUint(hDirectxKey, L"VendorId", &vendorId, NULL) && vendorId)
101+
ffStrbufSetStatic(&gpu->vendor, ffGPUGetVendorString(vendorId));
102+
}
103+
104+
ffRegReadStrbuf(hDirectxKey, L"Description", &gpu->name, NULL);
96105

97106
ffRegReadUint64(hDirectxKey, L"DedicatedVideoMemory", &gpu->dedicated.total, NULL);
98107
if (ffRegReadUint64(hDirectxKey, L"DedicatedSystemMemory", &gpu->shared.total, NULL))
@@ -127,7 +136,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
127136
}
128137
}
129138

130-
if (gpu->vendor.length == 0)
139+
if (gpu->vendor.length == 0 || gpu->name.length == 0)
131140
{
132141
bufferLen = sizeof(buffer);
133142
if (CM_Get_DevNode_Registry_PropertyW(devInst, CM_DRP_DRIVER, NULL, buffer, &bufferLen, 0) == CR_SUCCESS &&
@@ -137,7 +146,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
137146
FF_HKEY_AUTO_DESTROY hRegDriverKey = NULL;
138147
if (ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, regDriverKey, &hRegDriverKey, NULL))
139148
{
140-
if (ffRegReadStrbuf(hRegDriverKey, L"ProviderName", &gpu->vendor, NULL))
149+
if (gpu->vendor.length == 0 && ffRegReadStrbuf(hRegDriverKey, L"ProviderName", &gpu->vendor, NULL))
141150
{
142151
if (ffStrbufContainS(&gpu->vendor, "Intel"))
143152
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_INTEL);
@@ -146,6 +155,8 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
146155
else if (ffStrbufContainS(&gpu->vendor, "AMD") || ffStrbufContainS(&gpu->vendor, "ATI"))
147156
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD);
148157
}
158+
if (gpu->name.length == 0)
159+
ffRegReadStrbuf(hRegDriverKey, L"DriverDesc", &gpu->name, NULL);
149160
if (gpu->driver.length == 0)
150161
ffRegReadStrbuf(hRegDriverKey, L"DriverVersion", &gpu->driver, NULL);
151162
if (gpu->dedicated.total == FF_GPU_VMEM_SIZE_UNSET)
@@ -166,17 +177,9 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
166177

167178
if (options->driverSpecific && getDriverSpecificDetectionFn(gpu->vendor.chars, &detectFn, &dllName))
168179
{
169-
unsigned vendorId = 0, deviceId = 0, subSystemId = 0, revId = 0;
170-
bufferLen = sizeof(buffer);
171-
if (CM_Get_DevNode_Registry_PropertyW(devInst, CM_DRP_HARDWAREID, NULL, buffer, &bufferLen, 0) == CR_SUCCESS)
172-
{
173-
swscanf(buffer, L"PCI\\VEN_%x&DEV_%x&SUBSYS_%x&REV_%x", &vendorId, &deviceId, &subSystemId, &revId);
174-
ffStrbufSetStatic(&gpu->vendor, ffGPUGetVendorString(vendorId));
175-
}
176-
177180
detectFn(
178181
&(FFGpuDriverCondition) {
179-
.type = FF_GPU_DRIVER_CONDITION_TYPE_DEVICE_ID
182+
.type = (deviceId > 0 ? FF_GPU_DRIVER_CONDITION_TYPE_DEVICE_ID : 0)
180183
| (adapterLuid > 0 ? FF_GPU_DRIVER_CONDITION_TYPE_LUID : 0)
181184
| (pciAddr > 0 ? FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID : 0),
182185
.pciDeviceId = {

0 commit comments

Comments
 (0)