GPU: clean up GPU index detection code

This commit is contained in:
李通洲
2024-09-19 15:38:43 +08:00
parent 503a8d51ab
commit 0bcbae90e9
7 changed files with 14 additions and 12 deletions
+5 -6
View File
@@ -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",
}));
}