Skip to content

Commit cc246ea

Browse files
committed
GPU: prepare for memory type & shared memory usage detection
1 parent 0ae5fce commit cc246ea

File tree

10 files changed

+21
-7
lines changed

10 files changed

+21
-7
lines changed

src/detection/gpu/gpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ typedef struct FFGPUResult
3434
FFstrbuf name;
3535
FFstrbuf driver;
3636
FFstrbuf platformApi;
37+
FFstrbuf memoryType;
3738
double temperature;
3839
double coreUsage;
3940
int32_t coreCount;

src/detection/gpu/gpu_apple.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
103103

104104
FFGPUResult* gpu = ffListAdd(gpus);
105105

106+
ffStrbufInit(&gpu->memoryType);
106107
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
107108
gpu->type = FF_GPU_TYPE_UNKNOWN;
108109
gpu->frequency = FF_GPU_FREQUENCY_UNSET;

src/detection/gpu/gpu_bsd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
4040
ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString(pc->pc_vendor));
4141
ffStrbufInit(&gpu->name);
4242
ffStrbufInitS(&gpu->driver, pc->pd_name);
43-
ffStrbufInit(&gpu->platformApi);
43+
ffStrbufInitStatic(&gpu->platformApi, "/dev/pci");
44+
ffStrbufInit(&gpu->memoryType);
4445
gpu->index = FF_GPU_INDEX_UNSET;
4546
gpu->temperature = FF_GPU_TEMP_UNSET;
4647
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;

src/detection/gpu/gpu_general.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
3333
ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString(dev->vendor_id));
3434
ffStrbufInit(&gpu->name);
3535
ffStrbufInit(&gpu->driver);
36-
ffStrbufInit(&gpu->platformApi);
36+
ffStrbufInitStatic(&gpu->platformApi, "libpciaccess");
37+
ffStrbufInit(&gpu->memoryType);
3738
gpu->temperature = FF_GPU_TEMP_UNSET;
3839
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
3940
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;

src/detection/gpu/gpu_haiku.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
2323
ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString(dev.vendor_id));
2424
ffStrbufInit(&gpu->name);
2525
ffStrbufInit(&gpu->driver);
26-
ffStrbufInit(&gpu->platformApi);
26+
ffStrbufInitStatic(&gpu->platformApi, POKE_DEVICE_FULLNAME);
27+
ffStrbufInit(&gpu->memoryType);
2728
gpu->temperature = FF_GPU_TEMP_UNSET;
2829
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
2930
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;

src/detection/gpu/gpu_linux.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
438438
ffStrbufInit(&gpu->name);
439439
ffStrbufInit(&gpu->driver);
440440
ffStrbufInit(&gpu->platformApi);
441+
ffStrbufInit(&gpu->memoryType);
441442
gpu->index = FF_GPU_INDEX_UNSET;
442443
gpu->temperature = FF_GPU_TEMP_UNSET;
443444
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
@@ -632,6 +633,7 @@ static const char* detectOf(FFlist* gpus, FFstrbuf* buffer, FFstrbuf* drmDir, co
632633
ffStrbufInit(&gpu->name);
633634
ffStrbufInit(&gpu->vendor);
634635
ffStrbufInit(&gpu->driver);
636+
ffStrbufInit(&gpu->memoryType);
635637
ffStrbufInitF(&gpu->platformApi, "DRM (%s)", drmKey);
636638
gpu->temperature = FF_GPU_TEMP_UNSET;
637639
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;

src/detection/gpu/gpu_sunos.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
99

1010
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
1111
const char* error = ffProcessAppendStdOut(&buffer, (char* const[]) {
12-
"scanpci",
12+
"/usr/bin/scanpci",
1313
"-v",
1414
NULL,
1515
});
@@ -51,9 +51,10 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
5151

5252
FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
5353
ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString(vendorId));
54+
ffStrbufInit(&gpu->memoryType);
5455
ffStrbufInit(&gpu->name);
5556
ffStrbufInit(&gpu->driver);
56-
ffStrbufInit(&gpu->platformApi);
57+
ffStrbufInitStatic(&gpu->platformApi, "/usr/bin/scanpci");
5758
gpu->index = FF_GPU_INDEX_UNSET;
5859
gpu->temperature = FF_GPU_TEMP_UNSET;
5960
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;

src/detection/gpu/gpu_windows.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
3737
ffStrbufInit(&gpu->vendor);
3838
ffStrbufInit(&gpu->name);
3939
ffStrbufInit(&gpu->driver);
40+
ffStrbufInit(&gpu->memoryType);
4041
ffStrbufInitStatic(&gpu->platformApi, "SetupAPI");
4142
gpu->index = FF_GPU_INDEX_UNSET;
4243
gpu->temperature = FF_GPU_TEMP_UNSET;

src/detection/gpu/gpu_wsl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const char* ffGPUDetectByDirectX(FF_MAYBE_UNUSED const FFGPUOptions* options, FF
7070

7171
FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus);
7272
ffStrbufInitS(&gpu->name, desc);
73+
ffStrbufInit(&gpu->memoryType);
7374
gpu->index = FF_GPU_INDEX_UNSET;
7475
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
7576
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;

src/modules/gpu/gpu.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
153153
FF_FORMAT_ARG(sPercentBar, "shared-percentage-bar"),
154154
FF_FORMAT_ARG(coreUsageNum, "core-usage-num"),
155155
FF_FORMAT_ARG(coreUsageBar, "core-usage-bar"),
156+
FF_FORMAT_ARG(gpu->memoryType, "memory-type"),
156157
}));
157158
}
158159
}
@@ -411,6 +412,8 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
411412
else
412413
yyjson_mut_obj_add_null(doc, sharedObj, "used");
413414

415+
yyjson_mut_obj_add_strbuf(doc, obj, "memoryType", &gpu->memoryType);
416+
414417
if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET
415418
yyjson_mut_obj_add_real(doc, obj, "temperature", gpu->temperature);
416419
else
@@ -469,8 +472,9 @@ static FFModuleBaseInfo ffModuleInfo = {
469472
{"Dedicated memory usage percentage bar", "dedicated-percentage-bar"},
470473
{"Shared memory usage percentage num", "shared-percentage-num"},
471474
{"Shared memory usage percentage bar", "shared-percentage-bar"},
472-
{"Core usage percentage num (supports Nvidia & Apple GPU only)", "core-usage-num"},
473-
{"Core usage percentage bar (supports Nvidia & Apple GPU only)", "core-usage-bar"},
475+
{"Core usage percentage num", "core-usage-num"},
476+
{"Core usage percentage bar", "core-usage-bar"},
477+
{"Memory type (Windows only)", "memory-type"},
474478
})),
475479
};
476480

0 commit comments

Comments
 (0)