Skip to content

Commit

Permalink
nvapi: Add NvAPI_GetLogicalGPUFromDisplay (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
jp7677 committed May 26, 2024
1 parent b7e018f commit 031ada3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/nvapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,24 @@ extern "C" {
return Ok(n);
}

NvAPI_Status __cdecl NvAPI_GetLogicalGPUFromDisplay(NvDisplayHandle hNvDisp, NvLogicalGpuHandle* pLogicalGPU) {
constexpr auto n = __func__;

if (nvapiAdapterRegistry == nullptr)
return ApiNotInitialized(n);

if (hNvDisp == nullptr)
return InvalidArgument(n);

auto output = reinterpret_cast<NvapiOutput*>(hNvDisp);
if (!nvapiAdapterRegistry->IsOutput(output))
return ExpectedDisplayHandle(n);

*pLogicalGPU = reinterpret_cast<NvLogicalGpuHandle>(output->GetParent());

return Ok(n);
}

NvAPI_Status __cdecl NvAPI_GetPhysicalGPUsFromLogicalGPU(NvLogicalGpuHandle hLogicalGPU, NvPhysicalGpuHandle hPhysicalGPU[NVAPI_MAX_PHYSICAL_GPUS], NvU32* pGpuCount) {
constexpr auto n = __func__;

Expand Down
1 change: 1 addition & 0 deletions src/nvapi_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ extern "C" {
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GetDisplayDriverVersion)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GetPhysicalGPUsFromDisplay)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GetLogicalGPUFromPhysicalGPU)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GetLogicalGPUFromDisplay)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GetPhysicalGPUsFromLogicalGPU)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_EnumNvidiaDisplayHandle)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_EnumNvidiaUnAttachedDisplayHandle)
Expand Down

0 comments on commit 031ada3

Please sign in to comment.