Get Monitor Capabilities outputting invalid caps

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();
}

Dear @bderry

Thank you for contacting NVIDIA developer forum.
The support to query ‘supportVRR’ and ‘isTrueGsync’ capabilities will be available in R530 NVAPI SDK. We will let you know the details once the SDK is posted.

Thanks,
NVAPI Forum Moderator

Dear @bderry

The R530 NVAPI SDK is now available at https://developer.nvidia.com/gameworksdownload#?search=nvapi.

While calling NvAPI_DISP_GetMonitorCapabilities please set NV_MONITOR_CAPABILITIES::infoType to NV_MONITOR_CAPS_TYPE_GENERIC in order to get information for ‘supportVRR’ and ‘isTrueGsync’ caps.

Please let us know if this helps.

Thanks,
NVAPI Forum Moderator

Hey @planke

Thanks for the info, testing R530 and this does work now, thanks again!
I added the use of the new function “NvAPI_Disp_GetVRRInfo”; below is new code for anyone curious.

#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;
    NvU32 DisplayID = 0;

    
    int j = 0;

    if (!NVSucceeded(NvAPI_Initialize()))
        exit(1);

    while (NVSucceeded(NvAPI_EnumNvidiaDisplayHandle(j, &display)))
    {
        NvAPI_ShortString displayName = "";
        NV_MONITOR_CAPABILITIES Caps = { NV_MONITOR_CAPABILITIES_VER };
        Caps.infoType = NV_MONITOR_CAPS_TYPE_GENERIC;

        NvAPI_GetAssociatedNvidiaDisplayName(display, displayName);
        NvAPI_DISP_GetDisplayIdByDisplayName(displayName, &DisplayID);

        if (NVSucceeded(NvAPI_DISP_GetMonitorCapabilities(DisplayID, &Caps)))
        {
            if (Caps.data.caps.supportVRR) {

                NV_GET_VRR_INFO VrrInfo = { NV_GET_VRR_INFO_VER };

                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;
                }

                if (NVSucceeded(NvAPI_Disp_GetVRRInfo(DisplayID, &VrrInfo))) {
                    message = message + "VRR Enabled: " + (VrrInfo.bIsVRREnabled ? "True\n" : "False\n");
                }
            }
            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 };
                        Caps.infoType = NV_MONITOR_CAPS_TYPE_GENERIC;
                        if (NVSucceeded(NvAPI_DISP_GetMonitorCapabilities(nvDisplays[i].displayId, &Caps)))
                        {
                            if (Caps.data.caps.supportVRR) {

                                NV_GET_VRR_INFO VrrInfo = { NV_GET_VRR_INFO_VER };

                                if (Caps.data.caps.isTrueGsync) {
                                    std::string gsyncSupport = " Supports: True Gsync\n";
                                    message = gsyncSupport;
                                }
                                else {
                                    std::string vrrSupport = " Supports: VRR\n";
                                    message = vrrSupport;
                                }

                                if (NVSucceeded(NvAPI_Disp_GetVRRInfo(DisplayID, &VrrInfo))) {
                                    message = message + "VRR Enabled: " + (VrrInfo.bIsVRREnabled ? "True\n" : "False\n");
                                }
                            }
                            else {
                                std::string noSupport = " No VRR Support\n";
                                message = noSupport;
                            }
                            std::cout << message;
                        }
                    }
                }
            }
        }
    }
    NvAPI_Unload();
}

Dear @bderry ,
Glad that we could help here. I am marking this topic as closed.

Thanks,
NVAPI Forum Moderator