0

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
    }
}
NelsonGon
  • 13,015
  • 7
  • 27
  • 57
  • ", it returns me NVAPI_INCOMPATIBLE_STRUCT_VERSION" - It probably does that for a reason. Maybe look closer at the data you are providing as well as the version of the struct you are using. Maybe you need to include newer headers? – Jesper Juhl Apr 14 '19 at 15:50

1 Answers1

0

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 };
Paul Sanders
  • 24,133
  • 4
  • 26
  • 48
  • This help me solving the problem, however now I'm getting an empty struct (all fields are zeros). What can be a reason for this? (my monitors are connected into DP ports on the GPU thru adapters because the monitors don't have the DP input) – Nick Chernuha Apr 15 '19 at 07:21
  • IDK, but if you post this as a new question you might get some help. – Paul Sanders Apr 15 '19 at 21:13