Skip to content

Commit 484e05e

Browse files
authored
GPU: optionally hide unknown GPUs (#1742)
The current default behavior of not hiding any GPUs is retained. The new feature of hiding unknown or unrecognized GPUs can be enabled with hide-type = "unknown".
1 parent 5d3fb98 commit 484e05e

4 files changed

Lines changed: 16 additions & 5 deletions

File tree

doc/json_schema.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,7 @@
20532053
"enum": [
20542054
"integrated",
20552055
"discrete",
2056+
"unknown",
20562057
"none"
20572058
],
20582059
"default": "none"

src/data/help.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,12 +1139,13 @@
11391139
},
11401140
{
11411141
"long": "gpu-hide-type",
1142-
"desc": "Specify which types of GPUs should not be displayed",
1142+
"desc": "Specify which types of GPUs should not be displayed (default: all GPUs are shown, regardless of recognition)",
11431143
"arg": {
11441144
"type": "enum",
11451145
"enum": {
11461146
"integrated": "Hide integrated GPUs",
11471147
"discrete": "Hide discrete GPUs",
1148+
"unknown": "Hide unknown (unrecognized) GPUs",
11481149
"none": "Do not hide any GPUs"
11491150
},
11501151
"default": "none"

src/modules/gpu/gpu.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ void ffPrintGPU(FFGPUOptions* options)
173173

174174
FF_LIST_FOR_EACH(FFGPUResult, gpu, gpus)
175175
{
176+
if(gpu->type == FF_GPU_TYPE_UNKNOWN && options->hideType == FF_GPU_TYPE_UNKNOWN)
177+
continue;
178+
176179
if(gpu->type == FF_GPU_TYPE_INTEGRATED && options->hideType == FF_GPU_TYPE_INTEGRATED)
177180
continue;
178181

@@ -230,7 +233,8 @@ bool ffParseGPUCommandOptions(FFGPUOptions* options, const char* key, const char
230233
if (ffStrEqualsIgnCase(subKey, "hide-type"))
231234
{
232235
options->hideType = (FFGPUType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
233-
{ "none", FF_GPU_TYPE_UNKNOWN },
236+
{ "none", FF_GPU_TYPE_NONE },
237+
{ "unknown", FF_GPU_TYPE_UNKNOWN },
234238
{ "integrated", FF_GPU_TYPE_INTEGRATED },
235239
{ "discrete", FF_GPU_TYPE_DISCRETE },
236240
{},
@@ -288,7 +292,8 @@ void ffParseGPUJsonObject(FFGPUOptions* options, yyjson_val* module)
288292
{
289293
int value;
290294
const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) {
291-
{ "none", FF_GPU_TYPE_UNKNOWN },
295+
{ "none", FF_GPU_TYPE_NONE },
296+
{ "unknown", FF_GPU_TYPE_UNKNOWN },
292297
{ "integrated", FF_GPU_TYPE_INTEGRATED },
293298
{ "discrete", FF_GPU_TYPE_DISCRETE },
294299
{},
@@ -345,9 +350,12 @@ void ffGenerateGPUJsonConfig(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
345350
{
346351
switch (options->hideType)
347352
{
348-
case FF_GPU_TYPE_UNKNOWN:
353+
case FF_GPU_TYPE_NONE:
349354
yyjson_mut_obj_add_str(doc, module, "hideType", "none");
350355
break;
356+
case FF_GPU_TYPE_UNKNOWN:
357+
yyjson_mut_obj_add_str(doc, module, "hideType", "unknown");
358+
break;
351359
case FF_GPU_TYPE_INTEGRATED:
352360
yyjson_mut_obj_add_str(doc, module, "hideType", "integrated");
353361
break;

src/modules/gpu/option.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
typedef enum __attribute__((__packed__)) FFGPUType
99
{
10-
FF_GPU_TYPE_UNKNOWN,
10+
FF_GPU_TYPE_NONE, // Indicates no specific GPU type. Useful as a hide filter only.
11+
FF_GPU_TYPE_UNKNOWN, // Indicates an unknown or unrecognized GPU type.
1112
FF_GPU_TYPE_INTEGRATED,
1213
FF_GPU_TYPE_DISCRETE,
1314
} FFGPUType;

0 commit comments

Comments
 (0)