mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
GPU: clean up GPU index detection code
This commit is contained in:
@@ -28,7 +28,7 @@ typedef struct FFGPUMemory
|
||||
|
||||
typedef struct FFGPUResult
|
||||
{
|
||||
uint8_t index;
|
||||
uint32_t index;
|
||||
FFGPUType type;
|
||||
FFstrbuf vendor;
|
||||
FFstrbuf name;
|
||||
|
||||
@@ -65,5 +65,8 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
|
||||
if (result.type)
|
||||
*result.type = device->isAPU ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE;
|
||||
|
||||
if (result.index)
|
||||
*result.type = (uint32_t) device->adlAdapterIndex;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ const char* ffGpuDetectMetal(FFlist* gpus)
|
||||
ffStrbufSetStatic(&gpu->platformApi, "Metal Common 1");
|
||||
|
||||
gpu->type = device.hasUnifiedMemory ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE;
|
||||
gpu->index = (uint8_t)device.locationNumber;
|
||||
gpu->index = (uint32_t) device.locationNumber;
|
||||
#endif
|
||||
}
|
||||
return NULL;
|
||||
|
||||
@@ -37,7 +37,7 @@ typedef struct FFGpuDriverCondition
|
||||
// detect x if not NULL
|
||||
typedef struct FFGpuDriverResult
|
||||
{
|
||||
uint8_t* index;
|
||||
uint32_t* index;
|
||||
double* temp;
|
||||
FFGPUMemory* memory;
|
||||
uint32_t* coreCount;
|
||||
|
||||
@@ -138,7 +138,7 @@ const char *ffDetectMthreadsGpuInfo(const FFGpuDriverCondition *cond, FFGpuDrive
|
||||
{
|
||||
unsigned int value;
|
||||
if (mtmlData.ffmtmlDeviceGetIndex(device, &value) == MTML_SUCCESS)
|
||||
*result.index = (uint8_t)value;
|
||||
*result.index = value;
|
||||
}
|
||||
|
||||
if (result.temp)
|
||||
|
||||
@@ -111,9 +111,9 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
|
||||
{
|
||||
unsigned int value;
|
||||
if (nvmlData.ffnvmlDeviceGetIndex(device, &value) == NVML_SUCCESS)
|
||||
*result.index = (uint8_t)value;
|
||||
*result.index = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (result.temp)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FF_GPU_NUM_FORMAT_ARGS 12
|
||||
#define FF_GPU_NUM_FORMAT_ARGS 13
|
||||
|
||||
static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResult* gpu)
|
||||
{
|
||||
@@ -103,6 +103,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
FF_FORMAT_ARG(sUsed, "shared-used"),
|
||||
FF_FORMAT_ARG(gpu->platformApi, "platform-api"),
|
||||
FF_FORMAT_ARG(frequency, "frequency"),
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -323,13 +324,10 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
{
|
||||
yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr);
|
||||
|
||||
if (gpu->index != FF_GPU_INDEX_UNSET){
|
||||
yyjson_mut_obj_add_uint(doc, obj, "index", (uint64_t)gpu->index);
|
||||
}
|
||||
if (gpu->index != FF_GPU_INDEX_UNSET)
|
||||
yyjson_mut_obj_add_uint(doc, obj, "index", gpu->index);
|
||||
else
|
||||
{
|
||||
yyjson_mut_obj_add_null(doc, obj, "index");
|
||||
}
|
||||
|
||||
if (gpu->coreCount != FF_GPU_CORE_COUNT_UNSET)
|
||||
yyjson_mut_obj_add_int(doc, obj, "coreCount", gpu->coreCount);
|
||||
@@ -411,6 +409,7 @@ void ffPrintGPUHelpFormat(void)
|
||||
"GPU used shared memory - shared-used",
|
||||
"The platform API used when detecting the GPU - platform-api",
|
||||
"Current frequency in GHz - frequency",
|
||||
"GPU vendor specific index - index",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user