Chore: run clang-format

```bash
find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) ! -path "src/3rdparty/*" -print0 | xargs -0 clang-format -i
```
This commit is contained in:
李通洲
2026-03-29 09:28:49 +08:00
parent cdd4cee968
commit e0eba8ce21
690 changed files with 28093 additions and 30062 deletions
+67 -57
View File
@@ -23,34 +23,57 @@ const char* FF_GPU_VENDOR_NAME_JINGJIA_MICRO = "Jingjia Micro";
const char* FF_GPU_VENDOR_NAME_HUAWEI = "Huawei";
const char* FF_GPU_VENDOR_NAME_ZHAOXIN = "Zhaoxin";
const char* ffGPUGetVendorString(unsigned vendorId)
{
const char* ffGPUGetVendorString(unsigned vendorId) {
// https://devicehunt.com/all-pci-vendors
switch (vendorId)
{
case 0x106b: return FF_GPU_VENDOR_NAME_APPLE;
case 0x1002: case 0x1022: case 0x1dd8: return FF_GPU_VENDOR_NAME_AMD;
case 0x8086: case 0x8087: case 0x03e7: return FF_GPU_VENDOR_NAME_INTEL;
case 0x0955: case 0x10de: case 0x12d2: return FF_GPU_VENDOR_NAME_NVIDIA;
case 0x1ed5: return FF_GPU_VENDOR_NAME_MTHREADS;
case 0x17cb: case 0x5143: return FF_GPU_VENDOR_NAME_QUALCOMM;
case 0x14c3: return FF_GPU_VENDOR_NAME_MTK;
case 0x15ad: return FF_GPU_VENDOR_NAME_VMWARE;
case 0x1af4: return FF_GPU_VENDOR_NAME_REDHAT;
case 0x1ab8: return FF_GPU_VENDOR_NAME_PARALLEL;
case 0x1414: return FF_GPU_VENDOR_NAME_MICROSOFT;
case 0x108e: return FF_GPU_VENDOR_NAME_ORACLE;
case 0x182f: case 0x14e4: return FF_GPU_VENDOR_NAME_BROADCOM;
case 0x0014: return FF_GPU_VENDOR_NAME_LOONGSON;
case 0x0731: return FF_GPU_VENDOR_NAME_JINGJIA_MICRO;
case 0x19e5: return FF_GPU_VENDOR_NAME_HUAWEI;
case 0x1d17: return FF_GPU_VENDOR_NAME_ZHAOXIN;
default: return NULL;
switch (vendorId) {
case 0x106b:
return FF_GPU_VENDOR_NAME_APPLE;
case 0x1002:
case 0x1022:
case 0x1dd8:
return FF_GPU_VENDOR_NAME_AMD;
case 0x8086:
case 0x8087:
case 0x03e7:
return FF_GPU_VENDOR_NAME_INTEL;
case 0x0955:
case 0x10de:
case 0x12d2:
return FF_GPU_VENDOR_NAME_NVIDIA;
case 0x1ed5:
return FF_GPU_VENDOR_NAME_MTHREADS;
case 0x17cb:
case 0x5143:
return FF_GPU_VENDOR_NAME_QUALCOMM;
case 0x14c3:
return FF_GPU_VENDOR_NAME_MTK;
case 0x15ad:
return FF_GPU_VENDOR_NAME_VMWARE;
case 0x1af4:
return FF_GPU_VENDOR_NAME_REDHAT;
case 0x1ab8:
return FF_GPU_VENDOR_NAME_PARALLEL;
case 0x1414:
return FF_GPU_VENDOR_NAME_MICROSOFT;
case 0x108e:
return FF_GPU_VENDOR_NAME_ORACLE;
case 0x182f:
case 0x14e4:
return FF_GPU_VENDOR_NAME_BROADCOM;
case 0x0014:
return FF_GPU_VENDOR_NAME_LOONGSON;
case 0x0731:
return FF_GPU_VENDOR_NAME_JINGJIA_MICRO;
case 0x19e5:
return FF_GPU_VENDOR_NAME_HUAWEI;
case 0x1d17:
return FF_GPU_VENDOR_NAME_ZHAOXIN;
default:
return NULL;
}
}
const char* detectByOpenGL(FFlist* gpus)
{
const char* detectByOpenGL(FFlist* gpus) {
FF_DEBUG("Starting OpenGL GPU detection fallback");
FFOpenGLResult result;
@@ -65,8 +88,7 @@ const char* detectByOpenGL(FFlist* gpus)
const char* error = ffDetectOpenGL(&options, &result);
FF_DEBUG("OpenGL detection returns: %s", error ?: "success");
if (!error)
{
if (!error) {
FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus);
gpu->type = FF_GPU_TYPE_UNKNOWN;
ffStrbufInitMove(&gpu->vendor, &result.vendor);
@@ -79,7 +101,7 @@ const char* detectByOpenGL(FFlist* gpus)
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
gpu->dedicated = gpu->shared = (FFGPUMemory){0, 0};
gpu->dedicated = gpu->shared = (FFGPUMemory) {0, 0};
gpu->deviceId = 0;
FF_DEBUG("OpenGL reported renderer='%s', vendor='%s', version='%s'",
@@ -87,25 +109,23 @@ const char* detectByOpenGL(FFlist* gpus)
gpu->vendor.chars,
result.version.chars);
if (ffStrbufContainS(&gpu->name, "Apple"))
{
if (ffStrbufContainS(&gpu->name, "Apple")) {
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_APPLE);
gpu->type = FF_GPU_TYPE_INTEGRATED;
}
else if (ffStrbufContainS(&gpu->name, "Intel"))
} else if (ffStrbufContainS(&gpu->name, "Intel")) {
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_INTEL);
else if (ffStrbufContainS(&gpu->name, "AMD") || ffStrbufContainS(&gpu->name, "ATI"))
} else if (ffStrbufContainS(&gpu->name, "AMD") || ffStrbufContainS(&gpu->name, "ATI")) {
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD);
else if (ffStrbufContainS(&gpu->name, "NVIDIA"))
} else if (ffStrbufContainS(&gpu->name, "NVIDIA")) {
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_NVIDIA);
else if (ffStrbufContainS(&gpu->name, "MTT"))
} else if (ffStrbufContainS(&gpu->name, "MTT")) {
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_MTHREADS);
}
FF_DEBUG("OpenGL fallback produced GPU: name='%s', vendor='%s', type=%u",
gpu->name.chars,
gpu->vendor.chars,
gpu->type);
}
ffStrbufDestroy(&result.version);
@@ -116,16 +136,13 @@ const char* detectByOpenGL(FFlist* gpus)
return error;
}
const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result)
{
const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) {
FF_DEBUG("Starting GPU detection with method=%d", (int) options->detectionMethod);
if (options->detectionMethod <= FF_GPU_DETECTION_METHOD_PCI)
{
if (options->detectionMethod <= FF_GPU_DETECTION_METHOD_PCI) {
FF_DEBUG("Trying PCI/native GPU detection");
const char* error = ffDetectGPUImpl(options, result);
if (!error && result->length > 0)
{
if (!error && result->length > 0) {
FF_DEBUG("PCI/native GPU detection succeeded with %u GPU(s)", result->length);
return NULL;
}
@@ -134,24 +151,21 @@ const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result)
error ?: "none",
result->length);
}
if (options->detectionMethod <= FF_GPU_DETECTION_METHOD_VULKAN)
{
if (options->detectionMethod <= FF_GPU_DETECTION_METHOD_VULKAN) {
FF_DEBUG("Trying Vulkan GPU detection fallback");
FFVulkanResult* vulkan = ffDetectVulkan();
if (!vulkan->error && vulkan->gpus.length > 0)
{
if (!vulkan->error && vulkan->gpus.length > 0) {
FF_DEBUG("Vulkan detection succeeded with %u GPU(s)", vulkan->gpus.length);
ffListDestroy(result);
ffListInitMove(result, &vulkan->gpus);
#ifdef __ANDROID__
#ifdef __ANDROID__
double ffGPUDetectTempFromTZ(void);
if (options->temp && result->length == 1)
{
if (options->temp && result->length == 1) {
FF_DEBUG("Applying Android thermal-zone temperature to single Vulkan GPU");
FF_LIST_GET(FFGPUResult, *result, 0)->temperature = ffGPUDetectTempFromTZ();
}
#endif
#endif
return NULL;
}
@@ -160,12 +174,10 @@ const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result)
vulkan->error ?: "none",
vulkan->gpus.length);
}
if (options->detectionMethod <= FF_GPU_DETECTION_METHOD_OPENCL)
{
if (options->detectionMethod <= FF_GPU_DETECTION_METHOD_OPENCL) {
FF_DEBUG("Trying OpenCL GPU detection fallback");
FFOpenCLResult* opencl = ffDetectOpenCL();
if (!opencl->error && opencl->gpus.length > 0)
{
if (!opencl->error && opencl->gpus.length > 0) {
FF_DEBUG("OpenCL detection succeeded with %u GPU(s)", opencl->gpus.length);
ffListDestroy(result);
ffListInitMove(result, &opencl->gpus);
@@ -176,12 +188,10 @@ const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result)
opencl->error ?: "none",
opencl->gpus.length);
}
if (options->detectionMethod <= FF_GPU_DETECTION_METHOD_OPENGL)
{
if (options->detectionMethod <= FF_GPU_DETECTION_METHOD_OPENGL) {
FF_DEBUG("Trying OpenGL GPU detection fallback");
const char* error = detectByOpenGL(result);
if (error == NULL)
{
if (error == NULL) {
FF_DEBUG("OpenGL fallback succeeded with %u GPU(s)", result->length);
return NULL;
}