Hey all,
I have been trying to use the “NvAPI_DISP_GetMonitorCapabilities()” and so far I’m getting what appears to be invalid Caps outputted even though I get a NvAPI_OK status. Below is the code where I have tried fetching the display caps with two different methods; any help with be appreciated…
NOTE: I am running Nvidia Driver 528.49 with an Quadro RTX 4000
#include <iostream>
#include <nvapi.h>
#include <string>
NvPhysicalGpuHandle nvGPUHandles[NVAPI_MAX_PHYSICAL_GPUS];
NV_GPU_DISPLAYIDS* nvDisplays;
NvU32 GPUCount = 0;
NvU32 DisplayCount = 0;
bool NVSucceeded(NvAPI_Status status) {
//std::cout << status;
return status == NVAPI_OK;
}
int main()
{
std::string message;
NvDisplayHandle display;
NvAPI_ShortString displayName = "";
NvU32 DisplayID = 0;
int j = 0;
if (!NVSucceeded(NvAPI_Initialize()))
exit(1);
while (NVSucceeded(NvAPI_EnumNvidiaDisplayHandle(j, &display)))
{
NV_MONITOR_CAPABILITIES Caps = { NV_MONITOR_CAPABILITIES_VER };
//Caps.size = sizeof(Caps);
NvAPI_GetAssociatedNvidiaDisplayName(display, displayName);
NvAPI_DISP_GetDisplayIdByDisplayName(displayName, &DisplayID);
if (NVSucceeded(NvAPI_DISP_GetMonitorCapabilities(DisplayID, &Caps)))
{
if (Caps.data.caps.supportVRR) {
if (Caps.data.caps.isTrueGsync) {
std::string gsyncSupport = " Supports: True Gsync\n";
message = displayName + gsyncSupport;
}
else {
std::string vrrSupport = " Supports: VRR\n";
message = displayName + vrrSupport;
}
}
else {
std::string noSupport = " No VRR Support\n";
message = displayName + noSupport;
}
std::cout << message;
}
j++;
}
if (NVSucceeded(NvAPI_EnumPhysicalGPUs(nvGPUHandles, &GPUCount))) {
for (NvPhysicalGpuHandle gpuHandle : nvGPUHandles) {
NvAPI_GPU_GetAllDisplayIds(gpuHandle, NULL, &DisplayCount);
nvDisplays = static_cast<NV_GPU_DISPLAYIDS*>(malloc(sizeof(NV_GPU_DISPLAYIDS) * DisplayCount));
memset(nvDisplays, 0, sizeof(NV_GPU_DISPLAYIDS) * DisplayCount);
for (int i = 0; i < DisplayCount; i++) {
nvDisplays[i].version = NV_GPU_DISPLAYIDS_VER;
}
if (NVSucceeded(NvAPI_GPU_GetAllDisplayIds(gpuHandle, nvDisplays, &DisplayCount))) {
for (int i = 0; i < DisplayCount; i++) {
if (nvDisplays[i].isConnected && nvDisplays[i].isPhysicallyConnected)
{
NV_MONITOR_CAPABILITIES Caps = { NV_MONITOR_CAPABILITIES_VER };
//void* Caps;
//Caps = static_cast<NV_MONITOR_CAPABILITIES*>(malloc(sizeof(NV_MONITOR_CAPABILITIES)));
//Caps.size = sizeof(NV_MONITOR_CAPABILITIES);
//Caps.connectorType = nvDisplays[i].connectorType;
if (NVSucceeded(NvAPI_DISP_GetMonitorCapabilities(nvDisplays[i].displayId, &Caps)))
{
if (Caps.data.caps.supportVRR) {
if (Caps.data.caps.isTrueGsync) {
std::cout << ("Supports: True Gsync\n");
}
else {
std::cout << ("Supports: VRR\n");
}
}
else {
std::cout << ("No VRR Support\n");
}
}
}
}
}
}
}
NvAPI_Unload();
}