Skip to content

Commit d12d082

Browse files
committed
tmp
1 parent c1614a8 commit d12d082

File tree

13 files changed

+54
-3
lines changed

13 files changed

+54
-3
lines changed

src/3rdparty/yyjson/yyjson.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6884,6 +6884,16 @@ yyjson_api_inline bool yyjson_mut_obj_add_bool(yyjson_mut_doc *doc,
68846884
});
68856885
}
68866886

6887+
yyjson_api_inline bool yyjson_mut_obj_add_uint8(yyjson_mut_doc *doc,
6888+
yyjson_mut_val *obj,
6889+
const char *_key,
6890+
uint8_t _val) {
6891+
yyjson_mut_obj_add_func({
6892+
val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT;
6893+
val->uni.u64 = _val;
6894+
});
6895+
}
6896+
68876897
yyjson_api_inline bool yyjson_mut_obj_add_uint(yyjson_mut_doc *doc,
68886898
yyjson_mut_val *obj,
68896899
const char *_key,

src/detection/gpu/gpu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const char* detectByOpenGL(FFlist* gpus)
5151
ffStrbufInitMove(&gpu->name, &result.renderer);
5252
ffStrbufInitMove(&gpu->driver, &result.vendor);
5353
ffStrbufInitF(&gpu->platformApi, "OpenGL %s", result.version.chars);
54+
gpu->index = FF_GPU_INDEX_UNSET;
5455
gpu->temperature = FF_GPU_TEMP_UNSET;
5556
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
5657
gpu->frequency = FF_GPU_FREQUENCY_UNSET;

src/detection/gpu/gpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define FF_GPU_VMEM_SIZE_UNSET ((uint64_t)-1)
88
#define FF_GPU_FREQUENCY_UNSET (0/0.0)
99
#define FF_GPU_CORE_UTILIZATION_RATE_UNSET -1
10+
#define FF_GPU_INDEX_UNSET ((uint8_t)-1)
1011

1112
extern const char* FF_GPU_VENDOR_NAME_APPLE;
1213
extern const char* FF_GPU_VENDOR_NAME_AMD;
@@ -26,6 +27,7 @@ typedef struct FFGPUMemory
2627

2728
typedef struct FFGPUResult
2829
{
30+
uint8_t index;
2931
FFGPUType type;
3032
FFstrbuf vendor;
3133
FFstrbuf name;

src/detection/gpu/gpu_apple.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,18 @@
4343
ffStrbufSetStatic(&gpu->platformApi, "Metal Common 1");
4444

4545
gpu->type = device.hasUnifiedMemory ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE;
46+
gpu->index = (uint8_t)device.locationNumber;
4647
#endif
4748

49+
int registryID_string_length = snprintf(NULL, 0, "%llu", device.registryID);
50+
if (registryID_string_length > 0) {
51+
size_t registryID_buffer_size = (size_t)registryID_string_length + 1;
52+
char *registryID_buffer = (char *)malloc(registryID_buffer_size);
53+
snprintf(registryID_buffer, registryID_buffer_size, "%llu", device.registryID);
54+
ffStrbufAppendS(&gpu->uuid, registryID_buffer);
55+
free(registryID_buffer);
56+
}
57+
4858
if (gpu->type == FF_GPU_TYPE_INTEGRATED)
4959
{
5060
gpu->shared.total = device.recommendedMaxWorkingSetSize;

src/detection/gpu/gpu_bsd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
5555
ffStrbufInit(&gpu->name);
5656
ffStrbufInitS(&gpu->driver, pc->pd_name);
5757
ffStrbufInit(&gpu->platformApi);
58+
gpu->index = FF_GPU_INDEX_UNSET;
5859
gpu->temperature = FF_GPU_TEMP_UNSET;
5960
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
6061
gpu->type = FF_GPU_TYPE_UNKNOWN;
@@ -87,6 +88,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
8788
.func = pc->pc_sel.pc_func,
8889
},
8990
}, (FFGpuDriverResult) {
91+
.index = &gpu->index,
9092
.temp = options->temp ? &gpu->temperature : NULL,
9193
.memory = options->driverSpecific ? &gpu->dedicated : NULL,
9294
.coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : NULL,

src/detection/gpu/gpu_driver_specific.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ typedef struct FFGpuDriverCondition
3737
// detect x if not NULL
3838
typedef struct FFGpuDriverResult
3939
{
40-
FFstrbuf *uuid;
40+
uint8_t* index;
41+
FFstrbuf* uuid;
4142
double* temp;
4243
FFGPUMemory* memory;
4344
uint32_t* coreCount;
4445
FFGPUType* type;
4546
double* frequency;
46-
double *coreUtilizationRate;
47+
double* coreUtilizationRate;
4748
} FFGpuDriverResult;
4849

4950
const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName);

src/detection/gpu/gpu_linux.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
203203
ffStrbufInit(&gpu->uuid);
204204
ffStrbufInit(&gpu->driver);
205205
ffStrbufInit(&gpu->platformApi);
206+
gpu->index = FF_GPU_INDEX_UNSET;
206207
gpu->temperature = FF_GPU_TEMP_UNSET;
207208
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
208209
gpu->coreUtilizationRate = FF_GPU_CORE_UTILIZATION_RATE_UNSET;
@@ -272,6 +273,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
272273
},
273274
},
274275
(FFGpuDriverResult){
276+
.index = &gpu->index,
275277
.temp = options->temp ? &gpu->temperature : NULL,
276278
.memory = options->driverSpecific ? &gpu->dedicated : NULL,
277279
.coreCount = options->driverSpecific ? (uint32_t *)&gpu->coreCount : NULL,

src/detection/gpu/gpu_nvidia.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct FFNvmlData {
1616
FF_LIBRARY_SYMBOL(nvmlDeviceGetBrand)
1717
FF_LIBRARY_SYMBOL(nvmlDeviceGetUtilizationRates)
1818
FF_LIBRARY_SYMBOL(nvmlDeviceGetUUID)
19+
FF_LIBRARY_SYMBOL(nvmlDeviceGetIndex)
1920

2021
bool inited;
2122
} nvmlData;
@@ -42,6 +43,7 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
4243
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetBrand)
4344
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetUtilizationRates)
4445
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetUUID)
46+
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetIndex)
4547

4648
if (ffnvmlInit_v2() != NVML_SUCCESS)
4749
{
@@ -107,6 +109,14 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
107109
}
108110
}
109111

112+
if (result.index)
113+
{
114+
unsigned int value;
115+
if (nvmlData.ffnvmlDeviceGetIndex(device, &value) == NVML_SUCCESS)
116+
*result.index = (uint8_t)value;
117+
}
118+
119+
110120
if (result.temp)
111121
{
112122
uint32_t value;

src/detection/gpu/gpu_sunos.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
5757
ffStrbufInit(&gpu->name);
5858
ffStrbufInit(&gpu->driver);
5959
ffStrbufInit(&gpu->platformApi);
60+
gpu->index = FF_GPU_INDEX_UNSET;
6061
gpu->temperature = FF_GPU_TEMP_UNSET;
6162
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
6263
gpu->type = FF_GPU_TYPE_UNKNOWN;

src/detection/gpu/gpu_windows.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
8181
ffStrbufInit(&gpu->uuid);
8282
ffStrbufInit(&gpu->driver);
8383
ffStrbufInitStatic(&gpu->platformApi, "Direct3D");
84+
gpu->index = FF_GPU_INDEX_UNSET;
8485
gpu->temperature = FF_GPU_TEMP_UNSET;
8586
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
8687
gpu->type = FF_GPU_TYPE_UNKNOWN;
@@ -160,6 +161,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
160161
.luid = gpu->deviceId,
161162
},
162163
(FFGpuDriverResult){
164+
.index = &gpu->index,
163165
.temp = options->temp ? &gpu->temperature : NULL,
164166
.memory = options->driverSpecific ? &gpu->dedicated : NULL,
165167
.coreCount = options->driverSpecific ? (uint32_t *)&gpu->coreCount : NULL,

0 commit comments

Comments
 (0)