I have a problem with NvAPI_DISP_GetMonitorCapabilities function. when I'm calling this function, it returns me NVAPI_INCOMPATIBLE_STRUCT_VERSION.

NvAPI_Status nvapiReturnStatus = NVAPI_ERROR;

NV_GPU_DISPLAYIDS* pDisplayID = NULL;
NvU32 displayIdCount = 0;

NvPhysicalGpuHandle gpuHandleArray[NVAPI_MAX_PHYSICAL_GPUS] = { 0 };
NvU32 gpuCount = 0;

nvapiReturnStatus = GetGPUs(gpuHandleArray, gpuCount);
if (nvapiReturnStatus != NVAPI_OK)
{
    LogError("\n GetConnectedGPUs failed with error code : %s ", nvapiReturnStatus);
    return;
}

// Get all active outputs info for all gpu's
for (NvU32 i = 0; i < gpuCount; ++i)
{
    nvapiReturnStatus = GetConnectedDisplays(gpuHandleArray[i], &pDisplayID, displayIdCount);
    if (nvapiReturnStatus != NVAPI_OK)
    {
       LogError("\n GetConnectedDisplays failed with error code : %s ", nvapiReturnStatus);
       goto cleanup;
    }

    NV_MONITOR_CAPABILITIES_V1 monitorCaps;
    monitorCaps.version = NV_MONITOR_CAPABILITIES_VER1;
    memset(&monitorCaps, 0, sizeof(NV_MONITOR_CAPABILITIES_V1));

    for (NvU32 j = 0; j < displayIdCount; j++) 
    {
        nvapiReturnStatus = NvAPI_DISP_GetMonitorCapabilities(pDisplayID[j].displayId, &monitorCaps);
        //Here I get the error
    }
}

1 Answers

0
Paul Sanders On

Looks like you need to change this:

monitorCaps.version = NV_MONITOR_CAPABILITIES_VER1;
memset(&monitorCaps, 0, sizeof(NV_MONITOR_CAPABILITIES_V1));

to this:

memset(&monitorCaps, 0, sizeof(NV_MONITOR_CAPABILITIES_V1));
monitorCaps.version = NV_MONITOR_CAPABILITIES_VER1;

Or you can do:

NV_MONITOR_CAPABILITIES_V1 monitorCaps = { NV_MONITOR_CAPABILITIES_VER1 };