mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-28 07:44:06 +01:00
Global: replaces NULL to nullptr
This commit is contained in:
+10
-10
@@ -73,7 +73,7 @@ const char* ffGPUGetVendorString(unsigned vendorId) {
|
||||
case 0x1234: // https://admin.pci-ids.ucw.cz/read/PC/1234
|
||||
return FF_GPU_VENDOR_NAME_QEMU;
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ const char* detectByEglext(FFlist* result) {
|
||||
|
||||
const char* name = ffeglQueryDeviceStringEXT(device, EGL_RENDERER_EXT);
|
||||
if (!name) {
|
||||
FF_DEBUG("eglQueryDeviceStringEXT() returned NULL name for device %d, skipping", i);
|
||||
FF_DEBUG("eglQueryDeviceStringEXT() returned nullptr name for device %d, skipping", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ const char* detectByEglext(FFlist* result) {
|
||||
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
|
||||
gpu->pcieSpeed = FF_GPU_PCIE_SPEED_UNSET;
|
||||
|
||||
ffeglQueryDeviceBinaryEXT(device, EGL_DEVICE_UUID_EXT, sizeof(gpu->deviceId), &gpu->deviceId, NULL);
|
||||
ffeglQueryDeviceBinaryEXT(device, EGL_DEVICE_UUID_EXT, sizeof(gpu->deviceId), &gpu->deviceId, nullptr);
|
||||
|
||||
if (!normalizeVendorName(gpu)) {
|
||||
ffStrbufSetS(&gpu->vendor, ffeglQueryDeviceStringEXT(device, EGL_VENDOR));
|
||||
@@ -234,7 +234,7 @@ const char* detectByEglext(FFlist* result) {
|
||||
FF_DEBUG("eglQueryDevicesEXT() returned EGL_FALSE");
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -249,7 +249,7 @@ const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) {
|
||||
const char* error = ffDetectGPUImpl(options, result);
|
||||
if (!error && result->length > 0) {
|
||||
FF_DEBUG("PCI/native GPU detection succeeded with %u GPU(s)", result->length);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FF_DEBUG("PCI/native GPU detection did not produce results (error=%s, gpuCount=%u)",
|
||||
@@ -272,7 +272,7 @@ const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) {
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FF_DEBUG("Vulkan detection did not produce results (error=%s, gpuCount=%u)",
|
||||
@@ -286,7 +286,7 @@ const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) {
|
||||
FF_DEBUG("OpenCL detection succeeded with %u GPU(s)", opencl->gpus.length);
|
||||
ffListDestroy(result);
|
||||
ffListInitMove(result, &opencl->gpus);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FF_DEBUG("OpenCL detection did not produce results (error=%s, gpuCount=%u)",
|
||||
@@ -299,7 +299,7 @@ const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) {
|
||||
const char* error = detectByEglext(result);
|
||||
if (!error && result->length > 0) {
|
||||
FF_DEBUG("EGL_EXT GPU detection succeeded with %u GPU(s)", result->length);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FF_DEBUG("EGL_EXT GPU detection did not produce results (error=%s, gpuCount=%u)",
|
||||
@@ -312,9 +312,9 @@ const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) {
|
||||
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 == nullptr) {
|
||||
FF_DEBUG("OpenGL fallback succeeded with %u GPU(s)", result->length);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FF_DEBUG("OpenGL fallback failed: %s", error);
|
||||
|
||||
@@ -64,8 +64,8 @@ typedef struct FFGPUResult {
|
||||
uint64_t deviceId;
|
||||
} FFGPUResult;
|
||||
|
||||
static_assert(sizeof(((FFGPUResult*) NULL)->pcieSpeed) == 8, "pcieSpeed is not 8 bytes");
|
||||
static_assert(sizeof(((FFGPUResult*) NULL)->psMax) == 4, "psMax has padding");
|
||||
static_assert(sizeof(((FFGPUResult*) nullptr)->pcieSpeed) == 8, "pcieSpeed is not 8 bytes");
|
||||
static_assert(sizeof(((FFGPUResult*) nullptr)->psMax) == 4, "psMax has padding");
|
||||
|
||||
const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result);
|
||||
const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus);
|
||||
|
||||
@@ -72,7 +72,7 @@ static void shutdownAdl() {
|
||||
if (adlData.apiHandle) {
|
||||
FF_DEBUG("Destroying ADL context");
|
||||
adlData.ffADL2_Main_Control_Destroy(adlData.apiHandle);
|
||||
adlData.apiHandle = NULL;
|
||||
adlData.apiHandle = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
|
||||
}
|
||||
|
||||
atexit(shutdownAdl);
|
||||
atiadl = NULL; // don't close atiadl
|
||||
atiadl = nullptr; // don't close atiadl
|
||||
FF_DEBUG("ADL initialization complete");
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
|
||||
return "ffADL2_Main_Control_Create() failed";
|
||||
}
|
||||
|
||||
FF_AUTO_FREE AdapterInfo* devices = NULL;
|
||||
FF_AUTO_FREE AdapterInfo* devices = nullptr;
|
||||
int numDevices = 0;
|
||||
int adapterResult = adlData.ffADL2_Adapter_AdapterInfoX3_Get(adlData.apiHandle, -1, &numDevices, &devices);
|
||||
FF_DEBUG("ADL2_Adapter_AdapterInfoX3_Get returned %s (%d)", ffAdlStatusToString(adapterResult), adapterResult);
|
||||
@@ -131,7 +131,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
|
||||
return "ffADL2_Adapter_AdapterInfoX3_Get() failed";
|
||||
}
|
||||
|
||||
const AdapterInfo* device = NULL;
|
||||
const AdapterInfo* device = nullptr;
|
||||
for (int iDev = 0; iDev < numDevices; iDev++) {
|
||||
if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID) {
|
||||
FF_DEBUG("Checking device %d: bus=%d, device=%d, func=%d against requested bus=%u, device=%u, func=%u",
|
||||
@@ -492,5 +492,5 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
|
||||
return "Unknown Overdrive version";
|
||||
}
|
||||
FF_DEBUG("AMD GPU detection complete - returning success");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ double ffGPUDetectTempFromTZ(void) {
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
int dfd = dirfd(dirp);
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ const char* ffGpuDetectDriverVersion(FFlist* gpus);
|
||||
|
||||
static double detectGpuTemp(const FFstrbuf* gpuName) {
|
||||
double result = 0;
|
||||
const char* error = NULL;
|
||||
const char* error = nullptr;
|
||||
|
||||
if (ffStrbufStartsWithS(gpuName, "Apple M")) {
|
||||
switch (strtol(gpuName->chars + strlen("Apple M"), NULL, 10)) {
|
||||
switch (strtol(gpuName->chars + strlen("Apple M"), nullptr, 10)) {
|
||||
case 0:
|
||||
error = "Invalid Apple Silicon GPU";
|
||||
break;
|
||||
@@ -88,7 +88,7 @@ static const char* detectFrequency(FFGPUResult* gpu) {
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -123,27 +123,27 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) {
|
||||
ffStrbufInit(&gpu->driver); // Ok for both Apple and Intel
|
||||
ffCfDictGetString(properties, CFSTR("CFBundleIdentifier"), &gpu->driver);
|
||||
|
||||
if (ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount) != NULL) { // For Apple
|
||||
if (ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount) != nullptr) { // For Apple
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
}
|
||||
|
||||
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
|
||||
CFDictionaryRef perfStatistics = NULL;
|
||||
CFDictionaryRef perfStatistics = nullptr;
|
||||
uint64_t vramUsed = 0, vramTotal = 0;
|
||||
if (ffCfDictGetDict(properties, CFSTR("PerformanceStatistics"), &perfStatistics) == NULL) {
|
||||
if (ffCfDictGetDict(properties, CFSTR("PerformanceStatistics"), &perfStatistics) == nullptr) {
|
||||
int64_t utilization;
|
||||
if (ffCfDictGetInt64(perfStatistics, CFSTR("Device Utilization %"), &utilization) == NULL) {
|
||||
if (ffCfDictGetInt64(perfStatistics, CFSTR("Device Utilization %"), &utilization) == nullptr) {
|
||||
gpu->coreUsage = (double) utilization;
|
||||
} else if (ffCfDictGetInt64(perfStatistics, CFSTR("GPU Core Utilization"), &utilization) == NULL) {
|
||||
} else if (ffCfDictGetInt64(perfStatistics, CFSTR("GPU Core Utilization"), &utilization) == nullptr) {
|
||||
gpu->coreUsage = (double) utilization / 10000000.; // Nvidia?
|
||||
}
|
||||
|
||||
if (ffCfDictGetInt64(perfStatistics, CFSTR("Alloc system memory"), (int64_t*) &vramTotal) == NULL) {
|
||||
if (ffCfDictGetInt64(perfStatistics, CFSTR("In use system memory"), (int64_t*) &vramUsed) != NULL) {
|
||||
if (ffCfDictGetInt64(perfStatistics, CFSTR("Alloc system memory"), (int64_t*) &vramTotal) == nullptr) {
|
||||
if (ffCfDictGetInt64(perfStatistics, CFSTR("In use system memory"), (int64_t*) &vramUsed) != nullptr) {
|
||||
vramTotal = 0;
|
||||
}
|
||||
} else if (ffCfDictGetInt64(perfStatistics, CFSTR("vramFreeBytes"), (int64_t*) &vramTotal) == NULL) {
|
||||
if (ffCfDictGetInt64(perfStatistics, CFSTR("vramUsedBytes"), (int64_t*) &vramUsed) == NULL) {
|
||||
} else if (ffCfDictGetInt64(perfStatistics, CFSTR("vramFreeBytes"), (int64_t*) &vramTotal) == nullptr) {
|
||||
if (ffCfDictGetInt64(perfStatistics, CFSTR("vramUsedBytes"), (int64_t*) &vramUsed) == nullptr) {
|
||||
vramTotal += vramUsed;
|
||||
} else {
|
||||
vramTotal = 0;
|
||||
@@ -154,9 +154,9 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) {
|
||||
ffStrbufInit(&gpu->name);
|
||||
// IOAccelerator returns model / vendor-id properties for Apple Silicon, but not for Intel Iris GPUs.
|
||||
// Still needs testing for AMD's
|
||||
if (ffCfDictGetString(properties, CFSTR("model"), &gpu->name) != NULL) {
|
||||
if (ffCfDictGetString(properties, CFSTR("model"), &gpu->name) != nullptr) {
|
||||
CFRelease(properties);
|
||||
properties = NULL;
|
||||
properties = nullptr;
|
||||
|
||||
FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t parentEntry = 0;
|
||||
if (IORegistryEntryGetParentEntry(registryEntry, kIOServicePlane, &parentEntry) != kIOReturnSuccess ||
|
||||
@@ -169,7 +169,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) {
|
||||
|
||||
ffStrbufInit(&gpu->vendor);
|
||||
int vendorId;
|
||||
if (ffCfDictGetInt(properties, CFSTR("vendor-id"), &vendorId) == NULL) {
|
||||
if (ffCfDictGetInt(properties, CFSTR("vendor-id"), &vendorId) == nullptr) {
|
||||
const char* vendorStr = ffGPUGetVendorString((unsigned) vendorId);
|
||||
ffStrbufAppendS(&gpu->vendor, vendorStr);
|
||||
if (vendorStr == FF_GPU_VENDOR_NAME_APPLE || vendorStr == FF_GPU_VENDOR_NAME_INTEL) {
|
||||
@@ -203,5 +203,5 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) {
|
||||
if (instance.config.general.detectVersion) {
|
||||
ffGpuDetectDriverVersion(gpus);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ const char* ffGpuDetectDriverVersion(FFlist* gpus)
|
||||
ffStrbufAppendS(&x->driver, version.UTF8String);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return "Unsupported macOS version";
|
||||
}
|
||||
@@ -43,7 +43,7 @@ const char* ffGpuDetectMetal(FFlist* gpus)
|
||||
{
|
||||
for (id<MTLDevice> device in MTLCopyAllDevices())
|
||||
{
|
||||
FFGPUResult* gpu = NULL;
|
||||
FFGPUResult* gpu = nullptr;
|
||||
FF_LIST_FOR_EACH(FFGPUResult, x, *gpus)
|
||||
{
|
||||
if (x->deviceId == device.registryID)
|
||||
@@ -81,7 +81,7 @@ const char* ffGpuDetectMetal(FFlist* gpus)
|
||||
gpu->shared.total = device.recommendedMaxWorkingSetSize;
|
||||
#endif
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return "Metal API is not supported by this macOS version";
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ static const char* detectByPci(const FFGPUOptions* options, FFlist* gpus) {
|
||||
ffGPUDetectTypeByVendorAndName(gpu);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) {
|
||||
@@ -88,7 +88,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) {
|
||||
if (options->detectionMethod == FF_GPU_DETECTION_METHOD_AUTO) {
|
||||
ffGPUDetectByDrmBSD(options, gpus);
|
||||
if (gpus->length > 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -46,7 +46,7 @@ static const char* drmGetPciinfo(int drmfd, const char* drmId, struct drm_pciinf
|
||||
snprintf(requestBuf, ARRAY_SIZE(requestBuf), "hw.dri.%s.busid", drmId);
|
||||
char pciidBuf[64];
|
||||
size_t pciidLen = ARRAY_SIZE(pciidBuf);
|
||||
if (sysctlbyname(requestBuf, pciidBuf, &pciidLen, NULL, 0) < 0) {
|
||||
if (sysctlbyname(requestBuf, pciidBuf, &pciidLen, nullptr, 0) < 0) {
|
||||
return "sysctlbyname(hw.dri.%s.busid) failed";
|
||||
}
|
||||
// hw.dri.0.busid: pci:0000:01:00.0
|
||||
@@ -100,18 +100,18 @@ static const char* drmGetPciinfo(int drmfd, const char* drmId, struct drm_pciinf
|
||||
// dev.drm.0.PCI_ID: 10de:2782
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffGPUDetectByDrmBSD(const FFGPUOptions* options, FFlist* gpus) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/dev/dri/");
|
||||
if (dirp == NULL) {
|
||||
if (dirp == nullptr) {
|
||||
return "opendir(/dev/dri/) failed";
|
||||
}
|
||||
int drifd = dirfd(dirp);
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_name[0] == '.' || !ffStrStartsWith(entry->d_name, "card")) {
|
||||
continue;
|
||||
}
|
||||
@@ -123,7 +123,7 @@ const char* ffGPUDetectByDrmBSD(const FFGPUOptions* options, FFlist* gpus) {
|
||||
|
||||
// Currently, DRM_BUS_PCI is the only bus type supported by drm-kmod on BSD (hard-coded in libdrm source tree)
|
||||
struct drm_pciinfo pciInfo;
|
||||
if (drmGetPciinfo(fd, entry->d_name + strlen("card"), &pciInfo) != NULL) {
|
||||
if (drmGetPciinfo(fd, entry->d_name + strlen("card"), &pciInfo) != nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -157,11 +157,11 @@ const char* ffGPUDetectByDrmBSD(const FFGPUOptions* options, FFlist* gpus) {
|
||||
if (ffStrStartsWith(driverName, "i915")) {
|
||||
ffDrmDetectI915(gpu, fd);
|
||||
} else if (ffStrStartsWith(driverName, "amdgpu")) {
|
||||
uint32_t primaryNodeId = (uint32_t) strtoul(entry->d_name + strlen("card"), NULL, 10);
|
||||
uint32_t primaryNodeId = (uint32_t) strtoul(entry->d_name + strlen("card"), nullptr, 10);
|
||||
FF_STRBUF_AUTO_DESTROY renderNode = ffStrbufCreateF("/dev/dri/renderD%d", primaryNodeId + 128);
|
||||
ffDrmDetectAmdgpu(options, gpu, renderNode.chars);
|
||||
} else if (ffStrStartsWith(driverName, "radeon")) {
|
||||
uint32_t primaryNodeId = (uint32_t) strtoul(entry->d_name + strlen("card"), NULL, 10);
|
||||
uint32_t primaryNodeId = (uint32_t) strtoul(entry->d_name + strlen("card"), nullptr, 10);
|
||||
FF_STRBUF_AUTO_DESTROY renderNode = ffStrbufCreateF("/dev/dri/renderD%d", primaryNodeId + 128);
|
||||
ffDrmDetectRadeon(options, gpu, renderNode.chars);
|
||||
} else if (ffStrStartsWith(driverName, "xe")) {
|
||||
@@ -191,7 +191,7 @@ const char* ffGPUDetectByDrmBSD(const FFGPUOptions* options, FFlist* gpus) {
|
||||
ffGPUDetectTypeByVendorAndName(gpu);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@@ -15,7 +15,7 @@ typedef struct FFGpuDriverPciDeviceId {
|
||||
uint32_t revId;
|
||||
} FFGpuDriverPciDeviceId;
|
||||
|
||||
// Use pciBusId if not NULL; use pciDeviceId otherwise
|
||||
// Use pciBusId if not nullptr; use pciDeviceId otherwise
|
||||
typedef struct FFGpuDriverCondition {
|
||||
FFGpuDriverConditionType type;
|
||||
FFGpuDriverPciBusId pciBusId;
|
||||
@@ -23,7 +23,7 @@ typedef struct FFGpuDriverCondition {
|
||||
uint64_t luid;
|
||||
} FFGpuDriverCondition;
|
||||
|
||||
// detect x if not NULL
|
||||
// detect x if not nullptr
|
||||
typedef struct FFGpuDriverResult {
|
||||
uint32_t* index;
|
||||
double* temp;
|
||||
@@ -82,8 +82,8 @@ FF_A_UNUSED static inline bool getDriverSpecificDetectionFn(const char* vendor,
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
*pDetectFn = NULL;
|
||||
*pDllName = NULL;
|
||||
*pDetectFn = nullptr;
|
||||
*pDllName = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+15
-15
@@ -80,7 +80,7 @@ const char* ffDrmDetectRadeon(const FFGPUOptions* options, FFGPUResult* gpu, con
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, const char* renderPath) {
|
||||
@@ -172,7 +172,7 @@ const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, con
|
||||
gpu->coreUsage = value;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffDrmDetectI915(FFGPUResult* gpu, int fd) {
|
||||
@@ -213,7 +213,7 @@ const char* ffDrmDetectI915(FFGPUResult* gpu, int fd) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static inline int popcountBytes(uint8_t* bytes, uint32_t length) {
|
||||
@@ -296,7 +296,7 @@ const char* ffDrmDetectXe(FFGPUResult* gpu, int fd) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag ? NULL : "Failed to query Xe GPU information";
|
||||
return flag ? nullptr : "Failed to query Xe GPU information";
|
||||
}
|
||||
|
||||
const char* ffDrmDetectAsahi(FFGPUResult* gpu, int fd) {
|
||||
@@ -334,7 +334,7 @@ const char* ffDrmDetectAsahi(FFGPUResult* gpu, int fd) {
|
||||
ffStrbufSetF(&gpu->name, "Apple M%d%s (G%d%c %02X)", paramsGlobal.gpu_generation - 12, variant, paramsGlobal.gpu_generation, paramsGlobal.gpu_variant, paramsGlobal.gpu_revision + 0xA0);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return "Failed to query Asahi GPU information";
|
||||
@@ -362,7 +362,7 @@ const char* ffDrmDetectNouveau(FFGPUResult* gpu, int fd) {
|
||||
gpu->coreCount = (int32_t) getparam.value;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif // FF_HAVE_DRM
|
||||
@@ -380,17 +380,17 @@ const char* ffGPUDetectDriverSpecific(const FFGPUOptions* options, FFGPUResult*
|
||||
},
|
||||
(FFGpuDriverResult) {
|
||||
.index = &gpu->index,
|
||||
.temp = options->temp ? &gpu->temperature : NULL,
|
||||
.memory = options->driverSpecific ? &gpu->dedicated : NULL,
|
||||
.sharedMemory = options->driverSpecific ? &gpu->shared : NULL,
|
||||
.memoryType = options->driverSpecific ? &gpu->memoryType : NULL,
|
||||
.coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : NULL,
|
||||
.coreUsage = options->driverSpecific ? &gpu->coreUsage : NULL,
|
||||
.temp = options->temp ? &gpu->temperature : nullptr,
|
||||
.memory = options->driverSpecific ? &gpu->dedicated : nullptr,
|
||||
.sharedMemory = options->driverSpecific ? &gpu->shared : nullptr,
|
||||
.memoryType = options->driverSpecific ? &gpu->memoryType : nullptr,
|
||||
.coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : nullptr,
|
||||
.coreUsage = options->driverSpecific ? &gpu->coreUsage : nullptr,
|
||||
.type = &gpu->type,
|
||||
.frequency = options->driverSpecific ? &gpu->frequency : NULL,
|
||||
.frequency = options->driverSpecific ? &gpu->frequency : nullptr,
|
||||
.name = &gpu->name,
|
||||
.psCurr = options->driverSpecific ? &gpu->psCurr : NULL,
|
||||
.psMax = options->driverSpecific ? &gpu->psMax : NULL,
|
||||
.psCurr = options->driverSpecific ? &gpu->psCurr : nullptr,
|
||||
.psMax = options->driverSpecific ? &gpu->psMax : nullptr,
|
||||
},
|
||||
soName);
|
||||
}
|
||||
|
||||
@@ -22,12 +22,12 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu
|
||||
}
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dirDomain = fdopendir(dDomainFd);
|
||||
if (dirDomain == NULL) {
|
||||
if (dirDomain == nullptr) {
|
||||
return "fdopendir(domain) failed";
|
||||
}
|
||||
|
||||
struct dirent* busEntry;
|
||||
while ((busEntry = readdir(dirDomain)) != NULL) {
|
||||
while ((busEntry = readdir(dirDomain)) != nullptr) {
|
||||
if (busEntry->d_type != DT_DIR || busEntry->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
@@ -44,12 +44,12 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu
|
||||
}
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dirBus = fdopendir(dBusFd);
|
||||
if (dirBus == NULL) {
|
||||
if (dirBus == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
struct dirent* devEntry;
|
||||
while ((devEntry = readdir(dirBus)) != NULL) {
|
||||
while ((devEntry = readdir(dirBus)) != nullptr) {
|
||||
if (devEntry->d_type != DT_DIR || devEntry->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
@@ -65,12 +65,12 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu
|
||||
}
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dirDev = fdopendir(dDevFd);
|
||||
if (dirDev == NULL) {
|
||||
if (dirDev == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
struct dirent* funcEntry;
|
||||
while ((funcEntry = readdir(dirDev)) != NULL) {
|
||||
while ((funcEntry = readdir(dirDev)) != nullptr) {
|
||||
if (funcEntry->d_type != DT_DIR || funcEntry->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
@@ -143,5 +143,5 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -48,5 +48,5 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ struct FFIgclData {
|
||||
static void shutdownIgcl() {
|
||||
if (igclData.apiHandle) {
|
||||
igclData.ffctlClose(igclData.apiHandle);
|
||||
igclData.apiHandle = NULL;
|
||||
igclData.apiHandle = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
|
||||
return "loading igcl library failed";
|
||||
}
|
||||
atexit(shutdownIgcl);
|
||||
libigcl = NULL; // don't close igcl
|
||||
libigcl = nullptr; // don't close igcl
|
||||
}
|
||||
|
||||
if (!igclData.apiHandle) {
|
||||
@@ -66,11 +66,11 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
|
||||
}
|
||||
|
||||
uint32_t deviceCount = 0;
|
||||
// ctlEnumerateDevices MUST be called with deviceCount = 0 and devices = NULL first,
|
||||
// ctlEnumerateDevices MUST be called with deviceCount = 0 and devices = nullptr first,
|
||||
// otherwise it will be silently ignored and return CTL_RESULT_SUCCESS with deviceCount and devices unmodified.
|
||||
// VERY STRANGE BEHAVIOR
|
||||
if (igclData.ffctlEnumerateDevices(igclData.apiHandle, &deviceCount, NULL) != CTL_RESULT_SUCCESS) {
|
||||
return "ctlEnumerateDevices(NULL) failed";
|
||||
if (igclData.ffctlEnumerateDevices(igclData.apiHandle, &deviceCount, nullptr) != CTL_RESULT_SUCCESS) {
|
||||
return "ctlEnumerateDevices(nullptr) failed";
|
||||
}
|
||||
if (deviceCount == 0) {
|
||||
return "No Intel graphics adapter found";
|
||||
@@ -81,7 +81,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
|
||||
return "ctlEnumerateDevices(devices) failed";
|
||||
}
|
||||
|
||||
ctl_device_adapter_handle_t device = NULL;
|
||||
ctl_device_adapter_handle_t device = nullptr;
|
||||
|
||||
uint64_t /* LUID */ deviceId = 0;
|
||||
ctl_device_adapter_properties_t properties = {
|
||||
@@ -257,5 +257,5 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -61,11 +61,11 @@ FF_A_UNUSED static const char* drmFindRenderFromCard(const char* drmCardKey, FFs
|
||||
}
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (ffStrStartsWith(entry->d_name, "render")) {
|
||||
ffStrbufSetS(result, "/dev/dri/");
|
||||
ffStrbufAppendS(result, entry->d_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return "Failed to find render device";
|
||||
@@ -95,7 +95,7 @@ static void pciDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult* gpu,
|
||||
}
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
@@ -186,7 +186,7 @@ static void pciDetectIntelSpecific(const FFGPUOptions* options, FFGPUResult* gpu
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(pciDir->chars);
|
||||
if (dirp) {
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
@@ -249,7 +249,7 @@ static const char* pciDetectTempGeneral(const FFGPUOptions* options, FFGPUResult
|
||||
}
|
||||
ffStrbufSubstrBefore(pciDir, pciDirLen);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const char* drmDetectNouveauSpecific(FFGPUResult* gpu, const char* drmKey, FFstrbuf* buffer) {
|
||||
@@ -302,7 +302,7 @@ static const char* pciDetectZxSpecific(const FFGPUOptions* options, FFGPUResult*
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static inline uint16_t pcieLinkSpeedToGen(const FFstrbuf* buffer) {
|
||||
@@ -344,7 +344,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
}
|
||||
|
||||
char pciPath[PATH_MAX];
|
||||
const char* pPciPath = NULL;
|
||||
const char* pPciPath = nullptr;
|
||||
if (drmKey) {
|
||||
ssize_t pathLength = readlink(deviceDir->chars, pciPath, ARRAY_SIZE(pciPath) - 1);
|
||||
if (pathLength <= 0) {
|
||||
@@ -352,7 +352,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
}
|
||||
pciPath[pathLength] = '\0';
|
||||
pPciPath = strrchr(pciPath, '/');
|
||||
if (__builtin_expect(pPciPath != NULL, true)) {
|
||||
if (__builtin_expect(pPciPath != nullptr, true)) {
|
||||
pPciPath++;
|
||||
} else {
|
||||
pPciPath = pciPath;
|
||||
@@ -394,7 +394,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(deviceDir->chars);
|
||||
if (dirp) {
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (ffStrStartsWith(entry->d_name, "card")) {
|
||||
ffStrCopy(drmKeyBuffer, entry->d_name, ARRAY_SIZE(drmKeyBuffer));
|
||||
drmKey = drmKeyBuffer;
|
||||
@@ -415,7 +415,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD) {
|
||||
bool ok = false;
|
||||
if (drmKey && options->driverSpecific) {
|
||||
ok = drmDetectAmdSpecific(options, gpu, drmKey, buffer) == NULL;
|
||||
ok = drmDetectAmdSpecific(options, gpu, drmKey, buffer) == nullptr;
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
@@ -491,7 +491,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if __aarch64__
|
||||
@@ -510,7 +510,7 @@ FF_A_UNUSED static const char* drmDetectAsahiSpecific(FFGPUResult* gpu, const ch
|
||||
return ffDrmDetectAsahi(gpu, fd);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -563,7 +563,7 @@ static const char* detectOf(FFlist* gpus, FFstrbuf* buffer, FFstrbuf* drmDir, co
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const char* drmDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
@@ -572,16 +572,16 @@ static const char* drmDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
const uint32_t drmDirLength = drmDir.length;
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dir = opendir(drmDir.chars);
|
||||
if (dir == NULL) {
|
||||
if (dir == nullptr) {
|
||||
return "Failed to open `/sys/class/drm/`";
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
while ((entry = readdir(dir)) != nullptr) {
|
||||
if (!ffStrStartsWith(entry->d_name, "card") ||
|
||||
strchr(entry->d_name + 4, '-') != NULL) {
|
||||
strchr(entry->d_name + 4, '-') != nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -603,7 +603,7 @@ static const char* drmDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
@@ -611,7 +611,7 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
const char* pciDirPath = "/sys/bus/pci/devices/";
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(pciDirPath);
|
||||
if (dirp == NULL) {
|
||||
if (dirp == nullptr) {
|
||||
return "Failed to open `/sys/bus/pci/devices/`";
|
||||
}
|
||||
|
||||
@@ -623,7 +623,7 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
@@ -639,24 +639,24 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
ffStrbufSubstrBefore(&pciDir, pciDevDirLength);
|
||||
assert(ffStrbufStartsWithS(&buffer, "pci:"));
|
||||
|
||||
detectPci(options, gpus, &buffer, &pciDir, NULL);
|
||||
detectPci(options, gpus, &buffer, &pciDir, nullptr);
|
||||
ffStrbufSubstrBefore(&pciDir, pciBaseDirLength);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) {
|
||||
#if __x86_64__ || __aarch64__
|
||||
const char* ffGPUDetectWsl2(const FFGPUOptions* options, FFlist* gpus);
|
||||
if (ffGPUDetectWsl2(options, gpus) == NULL) {
|
||||
return NULL;
|
||||
if (ffGPUDetectWsl2(options, gpus) == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (options->detectionMethod == FF_GPU_DETECTION_METHOD_AUTO) {
|
||||
if (drmDetectGPUs(options, gpus) == NULL && gpus->length > 0) {
|
||||
return NULL;
|
||||
if (drmDetectGPUs(options, gpus) == nullptr && gpus->length > 0) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return pciDetectGPUs(options, gpus);
|
||||
|
||||
@@ -61,23 +61,23 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlLibraryShutDown)
|
||||
|
||||
if (ffmtmlLibraryInit(&mtmlData.lib) != MTML_SUCCESS) {
|
||||
mtmlData.ffmtmlLibraryInitSystem = NULL;
|
||||
mtmlData.ffmtmlLibraryInitSystem = nullptr;
|
||||
return "mtmlLibraryInit failed";
|
||||
}
|
||||
if (mtmlData.ffmtmlLibraryInitSystem(mtmlData.lib, &mtmlData.sys) != MTML_SUCCESS) {
|
||||
mtmlData.ffmtmlLibraryShutDown(mtmlData.lib);
|
||||
mtmlData.ffmtmlLibraryInitSystem = NULL;
|
||||
mtmlData.ffmtmlLibraryInitSystem = nullptr;
|
||||
return "mtmlLibraryInitSystem failed";
|
||||
}
|
||||
atexit(shutdownMtml);
|
||||
libmtml = NULL; // don't close mtml
|
||||
libmtml = nullptr; // don't close mtml
|
||||
}
|
||||
|
||||
if (mtmlData.ffmtmlLibraryInitSystem == NULL) {
|
||||
if (mtmlData.ffmtmlLibraryInitSystem == nullptr) {
|
||||
return "loading mtml library failed";
|
||||
}
|
||||
|
||||
MtmlDevice* device = NULL;
|
||||
MtmlDevice* device = nullptr;
|
||||
if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID) {
|
||||
char pciBusIdStr[32];
|
||||
snprintf(pciBusIdStr, ARRAY_SIZE(pciBusIdStr) - 1, "%04x:%02x:%02x.%d", cond->pciBusId.domain, cond->pciBusId.bus, cond->pciBusId.device, cond->pciBusId.func);
|
||||
@@ -92,7 +92,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive
|
||||
return "mtmlLibraryCountDevice() failed";
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < count; i++, device = NULL) {
|
||||
for (uint32_t i = 0; i < count; i++, device = nullptr) {
|
||||
if (mtmlData.ffmtmlLibraryInitDeviceByIndex(mtmlData.lib, i, &device) != MTML_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
@@ -135,7 +135,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive
|
||||
}
|
||||
|
||||
if (result.temp) {
|
||||
MtmlGpu* gpu = NULL;
|
||||
MtmlGpu* gpu = nullptr;
|
||||
if (mtmlData.ffmtmlDeviceInitGpu(device, &gpu) == MTML_SUCCESS) {
|
||||
uint32_t value;
|
||||
if (mtmlData.ffmtmlGpuGetTemperature(gpu, &value) == MTML_SUCCESS) {
|
||||
@@ -145,7 +145,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive
|
||||
}
|
||||
|
||||
if (result.memory) {
|
||||
MtmlMemory* mem = NULL;
|
||||
MtmlMemory* mem = nullptr;
|
||||
if (mtmlData.ffmtmlDeviceInitMemory(device, &mem) == MTML_SUCCESS) {
|
||||
unsigned long long total;
|
||||
if (mtmlData.ffmtmlMemoryGetTotal(mem, &total) == MTML_SUCCESS) {
|
||||
@@ -164,7 +164,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive
|
||||
}
|
||||
|
||||
if (result.frequency) {
|
||||
MtmlGpu* gpu = NULL;
|
||||
MtmlGpu* gpu = nullptr;
|
||||
if (mtmlData.ffmtmlDeviceInitGpu(device, &gpu) == MTML_SUCCESS) {
|
||||
uint32_t clockMHz;
|
||||
if (mtmlData.ffmtmlGpuGetMaxClock(gpu, &clockMHz) == MTML_SUCCESS) {
|
||||
@@ -174,7 +174,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive
|
||||
}
|
||||
|
||||
if (result.coreUsage) {
|
||||
MtmlGpu* gpu = NULL;
|
||||
MtmlGpu* gpu = nullptr;
|
||||
if (mtmlData.ffmtmlDeviceInitGpu(device, &gpu) == MTML_SUCCESS) {
|
||||
unsigned int utilization;
|
||||
if (mtmlData.ffmtmlGpuGetUtilization(gpu, &utilization) == MTML_SUCCESS) {
|
||||
@@ -204,7 +204,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
#else
|
||||
|
||||
|
||||
@@ -117,5 +117,5 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ static const char* detectMoreByNvapi(FFGpuDriverResult* result) {
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libnvapi, nvapi_QueryInterface)
|
||||
#define FF_NVAPI_INTERFACE(iName, iOffset) \
|
||||
__typeof__(&iName) ff##iName = ffnvapi_QueryInterface(iOffset); \
|
||||
if (ff##iName == NULL) return "nvapi_QueryInterface " #iName " failed";
|
||||
if (ff##iName == nullptr) return "nvapi_QueryInterface " #iName " failed";
|
||||
|
||||
FF_NVAPI_INTERFACE(nvapi_Initialize, NVAPI_INTERFACE_OFFSET_INITIALIZE)
|
||||
FF_NVAPI_INTERFACE(nvapi_Unload, NVAPI_INTERFACE_OFFSET_UNLOAD)
|
||||
@@ -72,10 +72,10 @@ static const char* detectMoreByNvapi(FFGpuDriverResult* result) {
|
||||
nvapiData.ffnvapi_Unload = ffnvapi_Unload;
|
||||
|
||||
atexit((void*) ffnvapi_Unload);
|
||||
libnvapi = NULL; // don't close nvapi
|
||||
libnvapi = nullptr; // don't close nvapi
|
||||
}
|
||||
|
||||
if (nvapiData.ffnvapi_EnumPhysicalGPUs == NULL) {
|
||||
if (nvapiData.ffnvapi_EnumPhysicalGPUs == nullptr) {
|
||||
return "loading nvapi library failed";
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ static const char* detectMoreByNvapi(FFGpuDriverResult* result) {
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -173,18 +173,18 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetName)
|
||||
|
||||
if (ffnvmlInit_v2() != NVML_SUCCESS) {
|
||||
nvmlData.ffnvmlDeviceGetNumGpuCores = NULL;
|
||||
nvmlData.ffnvmlDeviceGetNumGpuCores = nullptr;
|
||||
return "nvmlInit_v2() failed";
|
||||
}
|
||||
atexit((void*) ffnvmlShutdown);
|
||||
libnvml = NULL; // don't close nvml
|
||||
libnvml = nullptr; // don't close nvml
|
||||
}
|
||||
|
||||
if (nvmlData.ffnvmlDeviceGetNumGpuCores == NULL) {
|
||||
if (nvmlData.ffnvmlDeviceGetNumGpuCores == nullptr) {
|
||||
return "loading nvml library failed";
|
||||
}
|
||||
|
||||
nvmlDevice_t device = NULL;
|
||||
nvmlDevice_t device = nullptr;
|
||||
if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID) {
|
||||
char pciBusIdStr[32];
|
||||
snprintf(pciBusIdStr, ARRAY_SIZE(pciBusIdStr), "%04x:%02x:%02x.%d", cond->pciBusId.domain, cond->pciBusId.bus, cond->pciBusId.device, cond->pciBusId.func);
|
||||
@@ -199,7 +199,7 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
|
||||
return "nvmlDeviceGetCount_v2() failed";
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < count; i++, device = NULL) {
|
||||
for (uint32_t i = 0; i < count; i++, device = nullptr) {
|
||||
if (nvmlData.ffnvmlDeviceGetHandleByIndex_v2(i, &device) != NVML_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
@@ -319,7 +319,7 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
#else
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ const char* detectByPci(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpus) {
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) {
|
||||
@@ -106,7 +106,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) {
|
||||
if (options->detectionMethod == FF_GPU_DETECTION_METHOD_AUTO) {
|
||||
ffGPUDetectByDrmBSD(options, gpus);
|
||||
if (gpus->length > 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -19,7 +19,7 @@ static int walkDevTree(di_node_t node, FF_A_UNUSED di_minor_t minor, FFlist* gpu
|
||||
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
|
||||
gpu->type = FF_GPU_TYPE_UNKNOWN;
|
||||
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
|
||||
gpu->deviceId = strtoul(di_bus_addr(node), NULL, 16);
|
||||
gpu->deviceId = strtoul(di_bus_addr(node), nullptr, 16);
|
||||
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
|
||||
gpu->pcieSpeed = FF_GPU_PCIE_SPEED_UNSET;
|
||||
|
||||
@@ -51,5 +51,5 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu
|
||||
di_walk_minor(rootNode, DDI_NT_DISPLAY, DI_WALK_CLDFIRST, gpus, (void*) walkDevTree);
|
||||
di_fini(rootNode);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -94,10 +94,10 @@ static bool queryPciDeviceInfo(FFGPUResult* gpu, D3DKMT_DEVICE_IDS* outDeviceIds
|
||||
|
||||
uint32_t pciBus = 0;
|
||||
ULONG pciBufLen = sizeof(pciBus);
|
||||
if (CM_Get_DevNode_Registry_PropertyW(devInst, CM_DRP_BUSNUMBER, NULL, &pciBus, &pciBufLen, 0) == CR_SUCCESS) {
|
||||
if (CM_Get_DevNode_Registry_PropertyW(devInst, CM_DRP_BUSNUMBER, nullptr, &pciBus, &pciBufLen, 0) == CR_SUCCESS) {
|
||||
uint32_t pciAddr = 0;
|
||||
pciBufLen = sizeof(pciAddr);
|
||||
if (CM_Get_DevNode_Registry_PropertyW(devInst, CM_DRP_ADDRESS, NULL, &pciAddr, &pciBufLen, 0) == CR_SUCCESS) {
|
||||
if (CM_Get_DevNode_Registry_PropertyW(devInst, CM_DRP_ADDRESS, nullptr, &pciAddr, &pciBufLen, 0) == CR_SUCCESS) {
|
||||
entry->adapterAddress = ffGPUPciAddr2Id(0, pciBus, (pciAddr >> 16) & 0xFFFF, pciAddr & 0xFFFF);
|
||||
FF_DEBUG("Cached device IDs for PCI bus %u: vendor=0x%04x device=0x%04x", pciBus, entry->deviceIds.VendorID, entry->deviceIds.DeviceID);
|
||||
} else {
|
||||
@@ -190,12 +190,12 @@ static bool queryVendorNameViaRegistry(FFstrbuf* vendor, D3DKMT_HANDLE hAdapter)
|
||||
swprintf(path, ARRAY_SIZE(path), L"SYSTEM\\CurrentControlSet\\Control\\Video\\{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}\\0000", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
|
||||
|
||||
FF_DEBUG("Querying registry: HKEY_LOCAL_MACHINE\\%ls\\ProviderName", path);
|
||||
FF_AUTO_CLOSE_FD HANDLE key = NULL;
|
||||
if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, path, &key, NULL)) {
|
||||
FF_AUTO_CLOSE_FD HANDLE key = nullptr;
|
||||
if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, path, &key, nullptr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ffRegReadStrbuf(key, L"ProviderName", vendor, NULL);
|
||||
return ffRegReadStrbuf(key, L"ProviderName", vendor, nullptr);
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -428,17 +428,17 @@ ffGPUDetectWsl2
|
||||
},
|
||||
(FFGpuDriverResult) {
|
||||
.index = &gpu->index,
|
||||
.temp = options->temp ? &gpu->temperature : NULL,
|
||||
.memory = options->driverSpecific ? &gpu->dedicated : NULL,
|
||||
.sharedMemory = options->driverSpecific ? &gpu->shared : NULL,
|
||||
.memoryType = options->driverSpecific ? &gpu->memoryType : NULL,
|
||||
.coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : NULL,
|
||||
.coreUsage = options->driverSpecific ? &gpu->coreUsage : NULL,
|
||||
.temp = options->temp ? &gpu->temperature : nullptr,
|
||||
.memory = options->driverSpecific ? &gpu->dedicated : nullptr,
|
||||
.sharedMemory = options->driverSpecific ? &gpu->shared : nullptr,
|
||||
.memoryType = options->driverSpecific ? &gpu->memoryType : nullptr,
|
||||
.coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : nullptr,
|
||||
.coreUsage = options->driverSpecific ? &gpu->coreUsage : nullptr,
|
||||
.type = &gpu->type,
|
||||
.frequency = options->driverSpecific ? &gpu->frequency : NULL,
|
||||
.frequency = options->driverSpecific ? &gpu->frequency : nullptr,
|
||||
.name = &gpu->name,
|
||||
.psCurr = options->driverSpecific ? &gpu->psCurr : NULL,
|
||||
.psMax = options->driverSpecific ? &gpu->psMax : NULL,
|
||||
.psCurr = options->driverSpecific ? &gpu->psCurr : nullptr,
|
||||
.psMax = options->driverSpecific ? &gpu->psMax : nullptr,
|
||||
},
|
||||
dllName);
|
||||
FF_DEBUG("Driver-specific detection completed: %s", error ?: "Success");
|
||||
@@ -638,5 +638,5 @@ ffGPUDetectWsl2
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ static IDXCoreAdapterFactory* loadDxCoreFactory() {
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
FF_LIBRARY_LOAD(dxcore, NULL, "dxcore" FF_LIBRARY_EXTENSION, 1)
|
||||
FF_LIBRARY_LOAD(dxcore, nullptr, "dxcore" FF_LIBRARY_EXTENSION, 1)
|
||||
|
||||
// DXCoreCreateAdapterFactory is a reloaded function, so we can't use FF_LIBRARY_LOAD_SYMBOL_MESSAGE here
|
||||
typedef HRESULT (*DXCoreCreateAdapterFactory_t)(REFIID riid, void** ppvFactory);
|
||||
@@ -26,7 +26,7 @@ static IDXCoreAdapterFactory* loadDxCoreFactory() {
|
||||
#ifndef FF_DISABLE_DLOPEN
|
||||
auto ffDXCoreCreateAdapterFactory = (DXCoreCreateAdapterFactory_t) dlsym(dxcore, "DXCoreCreateAdapterFactory");
|
||||
if (ffDXCoreCreateAdapterFactory == nullptr) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#else
|
||||
auto ffDXCoreCreateAdapterFactory = (DXCoreCreateAdapterFactory_t) DXCoreCreateAdapterFactory;
|
||||
@@ -35,10 +35,10 @@ static IDXCoreAdapterFactory* loadDxCoreFactory() {
|
||||
HRESULT hr = ffDXCoreCreateAdapterFactory(IID_PPV_ARGS(&factory));
|
||||
if (FAILED(hr)) {
|
||||
FF_DEBUG("DXCoreCreateAdapterFactory failed with HRESULT: 0x%08lX (%s)", hr, ffDebugHResult(hr));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
dxcore = NULL; // Don't unload
|
||||
dxcore = nullptr; // Don't unload
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ typedef struct MtmlMemory MtmlMemory;
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char sbdf[MTML_DEVICE_PCI_SBDF_BUFFER_SIZE]; //!< The tuple segment:bus:device.function PCI identifier (& NULL terminator).
|
||||
char sbdf[MTML_DEVICE_PCI_SBDF_BUFFER_SIZE]; //!< The tuple segment:bus:device.function PCI identifier (& nullptr terminator).
|
||||
unsigned int segment; //!< The PCI segment group(domain) on which the device's bus resides, 0 to 0xffffffff.
|
||||
unsigned int bus; //!< The bus on which the device resides, 0 to 0xff.
|
||||
unsigned int device; //!< The device ID on the bus, 0 to 31.
|
||||
|
||||
@@ -18,7 +18,7 @@ typedef struct nvmlDevice_t* nvmlDevice_t;
|
||||
// https://docs.nvidia.com/deploy/nvml-api/structnvmlPciInfo__t.html
|
||||
// PCI information about a GPU device
|
||||
typedef struct {
|
||||
// The legacy tuple domain:bus:device.function PCI identifier (& NULL terminator)
|
||||
// The legacy tuple domain:bus:device.function PCI identifier (& nullptr terminator)
|
||||
char busIdLegacy[NVML_DEVICE_PCI_BUS_ID_BUFFER_V2_SIZE];
|
||||
// The PCI domain on which the device's bus resides, 0 to 0xffffffff
|
||||
unsigned int domain;
|
||||
@@ -30,7 +30,7 @@ typedef struct {
|
||||
unsigned int pciDeviceId;
|
||||
// The 32-bit Sub System Device ID
|
||||
unsigned int pciSubSystemId;
|
||||
// The tuple domain:bus:device.function PCI identifier (& NULL terminator)
|
||||
// The tuple domain:bus:device.function PCI identifier (& nullptr terminator)
|
||||
char busId[NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE];
|
||||
} nvmlPciInfo_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user