diff --git a/src/detection/gpu/gpu.h b/src/detection/gpu/gpu.h index 6e999d6ee..9737b4bfb 100644 --- a/src/detection/gpu/gpu.h +++ b/src/detection/gpu/gpu.h @@ -47,5 +47,5 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus); const char* ffGetGPUVendorString(unsigned vendorId); #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) -void ffGPUParsePciIds(FFstrbuf* content, uint8_t subclass, uint16_t vendor, uint16_t device, FFGPUResult* gpu); +void ffGPUParsePciIds(FFstrbuf* content, uint8_t subclass, uint16_t vendor, uint16_t device, FFGPUResult* gpu, FFstrbuf* coreName); #endif diff --git a/src/detection/gpu/gpu_bsd.c b/src/detection/gpu/gpu_bsd.c index 519263556..fbc5b4a29 100644 --- a/src/detection/gpu/gpu_bsd.c +++ b/src/detection/gpu/gpu_bsd.c @@ -70,11 +70,12 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name); } + FF_STRBUF_AUTO_DESTROY coreName = ffStrbufCreate(); if (gpu->name.length == 0) { if (pciids.length == 0) loadPciIds(&pciids); - ffGPUParsePciIds(&pciids, pc->pc_subclass, pc->pc_vendor, pc->pc_device, gpu); + ffGPUParsePciIds(&pciids, pc->pc_subclass, pc->pc_vendor, pc->pc_device, gpu, &coreName); } if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA && (options->temp || options->driverSpecific)) @@ -114,7 +115,12 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) } else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_INTEL) { - gpu->type = ffStrbufStartsWithIgnCaseS(&gpu->name, "Arc ") ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED; + if ((coreName->chars[0] == 'D' || coreName->chars[0] == 'S') && + coreName->chars[1] == 'G' && + ffCharIsDigit(coreName->chars[2])) + gpu->type = FF_GPU_TYPE_DISCRETE; // DG1 / DG2 / SG1 + else + gpu->type = FF_GPU_TYPE_INTEGRATED; } } } diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index f111f3de6..b2e766b09 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -199,14 +199,20 @@ static void pciDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult* gpu, } } -static void pciDetectIntelSpecific(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer) +static void pciDetectIntelSpecific(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer, const FFstrbuf* coreName) { // Works for Intel GPUs // https://patchwork.kernel.org/project/intel-gfx/patch/1422039866-11572-3-git-send-email-ville.syrjala@linux.intel.com/ if (ffStrbufStartsWithS(&gpu->name, "Intel ")) - ffStrbufSubstrAfter(&gpu->name, (uint32_t) strlen("Intel")); - gpu->type = ffStrbufStartsWithIgnCaseS(&gpu->name, "Arc ") ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED; + ffStrbufSubstrAfter(&gpu->name, (uint32_t) strlen("Intel ")); + + if ((coreName->chars[0] == 'D' || coreName->chars[0] == 'S') && + coreName->chars[1] == 'G' && + ffCharIsDigit(coreName->chars[2])) + gpu->type = FF_GPU_TYPE_DISCRETE; // DG1 / DG2 / SG1 + else + gpu->type = FF_GPU_TYPE_INTEGRATED; if (ffStrbufEqualS(&gpu->driver, "xe")) { @@ -322,6 +328,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf ffStrbufSubstrBefore(deviceDir, drmDirPathLength); } + FF_STRBUF_AUTO_DESTROY coreName = ffStrbufCreate(); if (gpu->name.length == 0) { static FFstrbuf pciids; @@ -330,7 +337,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf ffStrbufInit(&pciids); loadPciIds(&pciids); } - ffGPUParsePciIds(&pciids, subclassId, (uint16_t) vendorId, (uint16_t) deviceId, gpu); + ffGPUParsePciIds(&pciids, subclassId, (uint16_t) vendorId, (uint16_t) deviceId, gpu, &coreName); } pciDetectDriver(gpu, deviceDir, buffer, drmKey); @@ -343,7 +350,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf } else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_INTEL) { - pciDetectIntelSpecific(gpu, deviceDir, buffer); + pciDetectIntelSpecific(gpu, deviceDir, buffer, &coreName); ffStrbufSubstrBefore(deviceDir, drmDirPathLength); } else diff --git a/src/detection/gpu/gpu_pci.c b/src/detection/gpu/gpu_pci.c index c4b1e56ff..b865d8af9 100644 --- a/src/detection/gpu/gpu_pci.c +++ b/src/detection/gpu/gpu_pci.c @@ -1,6 +1,6 @@ #include "gpu.h" -void ffGPUParsePciIds(FFstrbuf* content, uint8_t subclass, uint16_t vendor, uint16_t device, FFGPUResult* gpu) +void ffGPUParsePciIds(FFstrbuf* content, uint8_t subclass, uint16_t vendor, uint16_t device, FFGPUResult* gpu, FFstrbuf* coreName) { if (content->length) { @@ -50,7 +50,14 @@ void ffGPUParsePciIds(FFstrbuf* content, uint8_t subclass, uint16_t vendor, uint openingBracket++; char* closingBracket = memchr(openingBracket, ']', (uint32_t) (end - openingBracket)); if (closingBracket) + { ffStrbufSetNS(&gpu->name, (uint32_t) (closingBracket - openingBracket), openingBracket); + if (coreName) + { + ffStrbufSetNS(coreName, (uint32_t) (closingBracket - openingBracket), start); + ffStrbufTrimRight(coreName, ' '); + } + } } if (!gpu->name.length) ffStrbufSetNS(&gpu->name, (uint32_t) (end - start), start); diff --git a/src/detection/gpu/gpu_sunos.c b/src/detection/gpu/gpu_sunos.c index 168cfaac1..442d87ce8 100644 --- a/src/detection/gpu/gpu_sunos.c +++ b/src/detection/gpu/gpu_sunos.c @@ -76,7 +76,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* { if (pciids.length == 0) ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/usr/share/hwdata/pci.ids", &pciids); - ffGPUParsePciIds(&pciids, (uint8_t) subclass, (uint16_t) vendorId, (uint16_t) deviceId, gpu); + ffGPUParsePciIds(&pciids, (uint8_t) subclass, (uint16_t) vendorId, (uint16_t) deviceId, gpu, NULL); } }