GPU selection options

#379
This commit is contained in:
Linus Dierheimer
2023-01-12 11:41:07 +01:00
parent 7f97725d7f
commit 670cf6fe90
13 changed files with 102 additions and 11 deletions
+8
View File
@@ -12,8 +12,16 @@
#define FF_GPU_VENDOR_NAME_INTEL "Intel"
#define FF_GPU_VENDOR_NAME_NVIDIA "NVIDIA"
typedef enum FFGpuType
{
FF_GPU_TYPE_INTEGRATED,
FF_GPU_TYPE_DISCRETE,
FF_GPU_TYPE_UNKNOWN
} FFGpuType;
typedef struct FFGPUResult
{
FFGpuType type;
FFstrbuf vendor;
FFstrbuf name;
FFstrbuf driver;
+2
View File
@@ -59,6 +59,8 @@ const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance)
FFGPUResult* gpu = ffListAdd(gpus);
gpu->type = FF_GPU_TYPE_UNKNOWN;
ffStrbufInitA(&gpu->vendor, 0);
ffStrbufInit(&gpu->driver);
+23 -1
View File
@@ -61,7 +61,7 @@ static void pciDetectVendorName(FFGPUResult* gpu, PCIData* pci, struct pci_dev*
static void drmDetectDeviceName(const FFinstance* instance, FFGPUResult* gpu, PCIData* pci, struct pci_dev* device)
{
u8 revId;
bool revIdSet = false;;
bool revIdSet = false;
#if PCI_LIB_VERSION >= 0x030800
revIdSet = pci->ffpci_fill_info(device, PCI_FILL_CLASS_EXT) & PCI_FILL_CLASS_EXT;
@@ -167,6 +167,24 @@ static void pciDetectTemperatur(const FFinstance* instance, FFGPUResult* gpu, st
}
}
static void detectType(FFGPUResult* gpu, const PCIData* pci, struct pci_dev* device)
{
//There is no straightforward way to detect the type of a GPU.
//The approach taken here is to look at the memory sizes of the device.
//Since integrated GPUs usually use the system ram, they don't have expansive ROMs
if(!(pci->ffpci_fill_info(device, PCI_FILL_SIZES) & PCI_FILL_SIZES))
{
gpu->type = FF_GPU_TYPE_UNKNOWN;
return;
}
if(device->rom_size > 0)
gpu->type = FF_GPU_TYPE_DISCRETE;
else
gpu->type = FF_GPU_TYPE_INTEGRATED;
}
static void pciHandleDevice(const FFinstance* instance, FFlist* results, PCIData* pci, struct pci_dev* device)
{
pci->ffpci_fill_info(device, PCI_FILL_CLASS);
@@ -175,7 +193,9 @@ static void pciHandleDevice(const FFinstance* instance, FFlist* results, PCIData
pci->ffpci_lookup_name(pci->access, class, sizeof(class) - 1, PCI_LOOKUP_CLASS, device->device_class);
if(
//https://pci-ids.ucw.cz/read/PD/03
strcasecmp("VGA compatible controller", class) != 0 &&
strcasecmp("XGA compatible controller", class) != 0 &&
strcasecmp("3D controller", class) != 0 &&
strcasecmp("Display controller", class) != 0
) return;
@@ -193,6 +213,8 @@ static void pciHandleDevice(const FFinstance* instance, FFlist* results, PCIData
ffStrbufInit(&gpu->driver);
pciDetectDriverName(gpu, pci, device);
detectType(gpu, pci, device);
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
gpu->temperature = FF_GPU_TEMP_UNSET;
+4
View File
@@ -26,6 +26,8 @@ static const char* detectWithDxgi(FFlist* gpus)
FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
gpu->type = FF_GPU_TYPE_UNKNOWN;
if(wmemchr((const wchar_t[]) {0x1002, 0x1022}, (wchar_t)desc.VendorId, 2))
ffStrbufInitS(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD);
else if(wmemchr((const wchar_t[]) {0x03e7, 0x8086, 0x8087}, (wchar_t)desc.VendorId, 3))
@@ -65,6 +67,8 @@ static const char* detectWithWmi(FFlist* gpus)
{
FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
gpu->type = FF_GPU_TYPE_UNKNOWN;
ffStrbufInit(&gpu->vendor);
record.getString(L"AdapterCompatibility", &gpu->vendor);
if(ffStrbufStartsWithS(&gpu->vendor, "Intel "))