Skip to content

Commit c6e9a0f

Browse files
committed
GPU: fix hiding unknown GPUs
The hide-type option now actually hides any unknown GPUs by default (hide-type == "unknown"). The old behavior (not hiding any GPUs) can be restored with "none".
1 parent 0c30590 commit c6e9a0f

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

doc/json_schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2053,9 +2053,10 @@
20532053
"enum": [
20542054
"integrated",
20552055
"discrete",
2056+
"unknown",
20562057
"none"
20572058
],
2058-
"default": "none"
2059+
"default": "unknown"
20592060
},
20602061
"key": {
20612062
"$ref": "#/$defs/key"

src/data/help.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,9 +1145,10 @@
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
},
1150-
"default": "none"
1151+
"default": "unknown"
11511152
}
11521153
},
11531154
{

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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
typedef enum __attribute__((__packed__)) FFGPUType
99
{
10+
FF_GPU_TYPE_NONE,
1011
FF_GPU_TYPE_UNKNOWN,
1112
FF_GPU_TYPE_INTEGRATED,
1213
FF_GPU_TYPE_DISCRETE,

0 commit comments

Comments
 (0)