mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
GPU: change option --gpu-force-vulkan to --gpu-detection-method
This commit is contained in:
+1
-1
@@ -197,7 +197,7 @@ __fastfetch_completion()
|
||||
"--disk-show-subvolumes"
|
||||
"--gpu-hide-integrated"
|
||||
"--gpu-hide-discrete"
|
||||
"--gpu-force-vulkan"
|
||||
"--gpu-force-method"
|
||||
"--disk-show-unknown"
|
||||
"--bluetooth-show-disconnected"
|
||||
)
|
||||
|
||||
+10
-4
@@ -1455,10 +1455,16 @@
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"forceVulkan": {
|
||||
"description": "Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
"detectionMethod": {
|
||||
"description": "Force using a specified method to detect GPUs",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"auto",
|
||||
"pci",
|
||||
"vulkan",
|
||||
"opengl"
|
||||
],
|
||||
"default": "auto"
|
||||
},
|
||||
"hideType": {
|
||||
"description": "Specify the type of GPUs should not be printed",
|
||||
|
||||
+10
-5
@@ -1197,13 +1197,18 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "gpu-force-vulkan",
|
||||
"desc": "Force using vulkan to detect GPUs",
|
||||
"remark": "Vulkan supports video memory usage detection",
|
||||
"long": "gpu-detection-method",
|
||||
"desc": "Force using a specified method to detect GPUs",
|
||||
"arg": {
|
||||
"type": "bool",
|
||||
"type": "enum",
|
||||
"optional": true,
|
||||
"default": false
|
||||
"enum": {
|
||||
"auto": "DRM (Linux only) -> PCI (Linux, FreeBSD and other platform specific methods) -> Vulkan -> OpenGL",
|
||||
"pci": "PCI -> Vulkan -> OpenGL",
|
||||
"vulkan": "Vulkan -> OpenGL",
|
||||
"opengl": "OpenGL"
|
||||
},
|
||||
"default": "auto"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
+26
-24
@@ -46,9 +46,9 @@ const char* detectByOpenGL(FFlist* gpus)
|
||||
{
|
||||
FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus);
|
||||
gpu->type = FF_GPU_TYPE_UNKNOWN;
|
||||
ffStrbufInitMove(&gpu->vendor, &result.vendor);
|
||||
ffStrbufInit(&gpu->vendor);
|
||||
ffStrbufInitMove(&gpu->name, &result.renderer);
|
||||
ffStrbufInit(&gpu->driver);
|
||||
ffStrbufInitMove(&gpu->driver, &result.vendor);
|
||||
ffStrbufInitF(&gpu->platformApi, "OpenGL %s", result.version.chars);
|
||||
gpu->temperature = FF_GPU_TEMP_UNSET;
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
@@ -56,22 +56,18 @@ const char* detectByOpenGL(FFlist* gpus)
|
||||
gpu->dedicated = gpu->shared = (FFGPUMemory){0, 0};
|
||||
gpu->deviceId = 0;
|
||||
|
||||
if (ffStrbufIgnCaseEqualS(&gpu->vendor, "Mesa"))
|
||||
ffStrbufClear(&gpu->vendor);
|
||||
|
||||
if (!gpu->vendor.length)
|
||||
if (ffStrbufContainS(&gpu->name, "Apple"))
|
||||
{
|
||||
if (ffStrbufContainS(&gpu->name, "Apple"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_APPLE);
|
||||
else if (ffStrbufContainS(&gpu->name, "Intel"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_INTEL);
|
||||
else if (ffStrbufContainS(&gpu->name, "AMD") || ffStrbufContainS(&gpu->name, "ATI"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD);
|
||||
else if (ffStrbufContainS(&gpu->name, "NVIDIA"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_NVIDIA);
|
||||
}
|
||||
if (ffStrbufEqualS(&gpu->vendor, FF_GPU_VENDOR_NAME_APPLE))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_APPLE);
|
||||
gpu->type = FF_GPU_TYPE_INTEGRATED;
|
||||
}
|
||||
else if (ffStrbufContainS(&gpu->name, "Intel"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_INTEL);
|
||||
else if (ffStrbufContainS(&gpu->name, "AMD") || ffStrbufContainS(&gpu->name, "ATI"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD);
|
||||
else if (ffStrbufContainS(&gpu->name, "NVIDIA"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_NVIDIA);
|
||||
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&result.version);
|
||||
@@ -83,20 +79,26 @@ const char* detectByOpenGL(FFlist* gpus)
|
||||
|
||||
const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result)
|
||||
{
|
||||
if (!options->forceVulkan)
|
||||
if (options->detectionMethod <= FF_GPU_DETECTION_METHOD_PCI)
|
||||
{
|
||||
const char* error = ffDetectGPUImpl(options, result);
|
||||
if (!error && result->length > 0) return NULL;
|
||||
}
|
||||
FFVulkanResult* vulkan = ffDetectVulkan();
|
||||
if (!vulkan->error && vulkan->gpus.length > 0)
|
||||
if (options->detectionMethod <= FF_GPU_DETECTION_METHOD_VULKAN)
|
||||
{
|
||||
ffListDestroy(result);
|
||||
ffListInitMove(result, &vulkan->gpus);
|
||||
return NULL;
|
||||
FFVulkanResult* vulkan = ffDetectVulkan();
|
||||
if (!vulkan->error && vulkan->gpus.length > 0)
|
||||
{
|
||||
ffListDestroy(result);
|
||||
ffListInitMove(result, &vulkan->gpus);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (options->detectionMethod <= FF_GPU_DETECTION_METHOD_OPENGL)
|
||||
{
|
||||
if (detectByOpenGL(result) == NULL)
|
||||
return NULL;
|
||||
}
|
||||
if (detectByOpenGL(result) == NULL)
|
||||
return NULL;
|
||||
|
||||
return "GPU detection failed";
|
||||
}
|
||||
|
||||
@@ -460,14 +460,16 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus)
|
||||
|
||||
const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
|
||||
{
|
||||
#ifdef FF_HAVE_DIRECTX_HEADERS
|
||||
const char* ffGPUDetectByDirectX(const FFGPUOptions* options, FFlist* gpus);
|
||||
if (ffGPUDetectByDirectX(options, gpus) == NULL)
|
||||
if (options->detectionMethod == FF_GPU_DETECTION_METHOD_AUTO)
|
||||
{
|
||||
#ifdef FF_HAVE_DIRECTX_HEADERS
|
||||
const char* ffGPUDetectByDirectX(const FFGPUOptions* options, FFlist* gpus);
|
||||
if (ffGPUDetectByDirectX(options, gpus) == NULL)
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
if (drmDetectGPUs(options, gpus) == NULL && gpus->length > 0)
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
if (drmDetectGPUs(options, gpus) == NULL && gpus->length > 0)
|
||||
return NULL;
|
||||
|
||||
}
|
||||
return pciDetectGPUs(options, gpus);
|
||||
}
|
||||
|
||||
@@ -234,10 +234,13 @@ static bool printSpecificCommandHelp(const char* command)
|
||||
}
|
||||
}
|
||||
|
||||
yyjson_doc_free(doc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
yyjson_doc_free(doc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+40
-7
@@ -144,9 +144,15 @@ bool ffParseGPUCommandOptions(FFGPUOptions* options, const char* key, const char
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(subKey, "force-vulkan"))
|
||||
if (ffStrEqualsIgnCase(subKey, "detection-method"))
|
||||
{
|
||||
options->forceVulkan = ffOptionParseBoolean(value);
|
||||
options->detectionMethod = ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
|
||||
{ "auto", FF_GPU_DETECTION_METHOD_AUTO },
|
||||
{ "pci", FF_GPU_DETECTION_METHOD_PCI },
|
||||
{ "vulkan", FF_GPU_DETECTION_METHOD_VULKAN },
|
||||
{ "opengl", FF_GPU_DETECTION_METHOD_OPENGL },
|
||||
{},
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -191,9 +197,20 @@ void ffParseGPUJsonObject(FFGPUOptions* options, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "forceVulkan"))
|
||||
if (ffStrEqualsIgnCase(key, "detectionMethod"))
|
||||
{
|
||||
options->forceVulkan = yyjson_get_bool(val);
|
||||
int value;
|
||||
const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) {
|
||||
{ "auto", FF_GPU_DETECTION_METHOD_AUTO },
|
||||
{ "pci", FF_GPU_DETECTION_METHOD_PCI },
|
||||
{ "vulkan", FF_GPU_DETECTION_METHOD_VULKAN },
|
||||
{ "opengl", FF_GPU_DETECTION_METHOD_OPENGL },
|
||||
{},
|
||||
});
|
||||
if (error)
|
||||
ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Invalid %s value: %s", key, error);
|
||||
else
|
||||
options->detectionMethod = (FFGPUDetectionMethod) value;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -230,8 +247,24 @@ void ffGenerateGPUJsonConfig(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
if (options->driverSpecific != defaultOptions.driverSpecific)
|
||||
yyjson_mut_obj_add_bool(doc, module, "driverSpecific", options->driverSpecific);
|
||||
|
||||
if (options->forceVulkan != defaultOptions.forceVulkan)
|
||||
yyjson_mut_obj_add_bool(doc, module, "forceVulkan", options->forceVulkan);
|
||||
if (options->detectionMethod != defaultOptions.detectionMethod)
|
||||
{
|
||||
switch (options->detectionMethod)
|
||||
{
|
||||
case FF_GPU_DETECTION_METHOD_AUTO:
|
||||
yyjson_mut_obj_add_str(doc, module, "detectionMethod", "auto");
|
||||
break;
|
||||
case FF_GPU_DETECTION_METHOD_PCI:
|
||||
yyjson_mut_obj_add_str(doc, module, "detectionMethod", "pci");
|
||||
break;
|
||||
case FF_GPU_DETECTION_METHOD_VULKAN:
|
||||
yyjson_mut_obj_add_str(doc, module, "detectionMethod", "vulkan");
|
||||
break;
|
||||
case FF_GPU_DETECTION_METHOD_OPENGL:
|
||||
yyjson_mut_obj_add_str(doc, module, "detectionMethod", "opengl");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ffTempsGenerateJsonConfig(doc, module, defaultOptions.temp, defaultOptions.tempConfig, options->temp, options->tempConfig);
|
||||
|
||||
@@ -366,7 +399,7 @@ void ffInitGPUOptions(FFGPUOptions* options)
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
|
||||
options->driverSpecific = false;
|
||||
options->forceVulkan = false;
|
||||
options->detectionMethod = FF_GPU_DETECTION_METHOD_AUTO;
|
||||
options->temp = false;
|
||||
options->hideType = FF_GPU_TYPE_UNKNOWN;
|
||||
options->tempConfig = (FFColorRangeConfig) { 60, 80 };
|
||||
|
||||
@@ -12,15 +12,24 @@ typedef enum FFGPUType
|
||||
FF_GPU_TYPE_DISCRETE,
|
||||
} FFGPUType;
|
||||
|
||||
typedef enum FFGPUDetectionMethod
|
||||
{
|
||||
FF_GPU_DETECTION_METHOD_AUTO,
|
||||
FF_GPU_DETECTION_METHOD_PCI,
|
||||
FF_GPU_DETECTION_METHOD_VULKAN,
|
||||
FF_GPU_DETECTION_METHOD_OPENGL,
|
||||
} FFGPUDetectionMethod;
|
||||
|
||||
typedef struct FFGPUOptions
|
||||
{
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
FFGPUType hideType;
|
||||
FFGPUDetectionMethod detectionMethod;
|
||||
bool temp;
|
||||
bool driverSpecific;
|
||||
bool forceVulkan;
|
||||
bool forceMethod;
|
||||
FFColorRangeConfig tempConfig;
|
||||
FFColorRangeConfig percent;
|
||||
} FFGPUOptions;
|
||||
|
||||
Reference in New Issue
Block a user