diff --git a/src/nvapi_drs.cpp b/src/nvapi_drs.cpp index f5d399c6..4dabeb83 100644 --- a/src/nvapi_drs.cpp +++ b/src/nvapi_drs.cpp @@ -37,6 +37,14 @@ extern "C" { return Ok(n); } + NvAPI_Status __cdecl NvAPI_DRS_GetCurrentGlobalProfile(NvDRSSessionHandle hSession, NvDRSProfileHandle* phProfile) { + constexpr auto n = __func__; + + *phProfile = nvapiDrsProfile; + + return Ok(n); + } + NvAPI_Status __cdecl NvAPI_DRS_GetSetting(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvU32 settingId, NVDRS_SETTING* pSetting) { constexpr auto n = __func__; diff --git a/src/nvapi_gpu.cpp b/src/nvapi_gpu.cpp index 7ebc8152..a7c73ce6 100644 --- a/src/nvapi_gpu.cpp +++ b/src/nvapi_gpu.cpp @@ -187,6 +187,20 @@ extern "C" { return Ok(n); } + NvAPI_Status __cdecl NvAPI_GPU_GetSystemType(NvPhysicalGpuHandle hPhysicalGpu, NV_SYSTEM_TYPE* pSystemType) { + constexpr auto n = __func__; + + if (nvapiAdapterRegistry == nullptr) + return ApiNotInitialized(n); + + if (hPhysicalGpu == nullptr) + return InvalidArgument(n); + + *pSystemType = NV_SYSTEM_TYPE_UNKNOWN; + + return Ok(n); + } + NvAPI_Status __cdecl NvAPI_GPU_GetPCIIdentifiers(NvPhysicalGpuHandle hPhysicalGpu, NvU32* pDeviceId, NvU32* pSubSystemId, NvU32* pRevisionId, NvU32* pExtDeviceId) { constexpr auto n = __func__; @@ -313,6 +327,24 @@ extern "C" { return Ok(n); } + NvAPI_Status __cdecl NvAPI_GPU_GetVirtualFrameBufferSize(NvPhysicalGpuHandle hPhysicalGpu, NvU32* pSize) { + constexpr auto n = __func__; + + if (nvapiAdapterRegistry == nullptr) + return ApiNotInitialized(n); + + if (pSize == nullptr) + return InvalidArgument(n); + + auto adapter = reinterpret_cast(hPhysicalGpu); + if (!nvapiAdapterRegistry->IsAdapter(adapter)) + return ExpectedPhysicalGpuHandle(n); + + *pSize = adapter->GetVirtualVRamSize(); + + return Ok(n); + } + NvAPI_Status __cdecl NvAPI_GPU_GetAdapterIdFromPhysicalGpu(NvPhysicalGpuHandle hPhysicalGpu, void* pOSAdapterId) { constexpr auto n = __func__; diff --git a/src/nvapi_interface.cpp b/src/nvapi_interface.cpp index a50f20ed..08da63b6 100644 --- a/src/nvapi_interface.cpp +++ b/src/nvapi_interface.cpp @@ -87,12 +87,14 @@ extern "C" { INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetIRQ) INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetGpuCoreCount) INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetGPUType) + INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetSystemType) INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetPCIIdentifiers) INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetFullName) INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetBusId) INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetBusSlotId) INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetBusType) INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetPhysicalFrameBufferSize) + INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetVirtualFrameBufferSize) INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetAdapterIdFromPhysicalGpu) INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetLogicalGpuInfo) INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetArchInfo) @@ -108,6 +110,7 @@ extern "C" { INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_DRS_FindProfileByName) INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_DRS_GetSetting) INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_DRS_GetBaseProfile) + INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_DRS_GetCurrentGlobalProfile); INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_DRS_LoadSettings) INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_DRS_DestroySession) INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_DRS_CreateSession) diff --git a/src/sysinfo/nvapi_adapter.cpp b/src/sysinfo/nvapi_adapter.cpp index 922e23f9..c8bcbe4e 100644 --- a/src/sysinfo/nvapi_adapter.cpp +++ b/src/sysinfo/nvapi_adapter.cpp @@ -206,6 +206,11 @@ namespace dxvk { return m_dxgiDesc.DedicatedVideoMemory / 1024; } + uint32_t NvapiAdapter::GetVirtualVRamSize() const { + // Report VRAM size from DXVK to honor memory overrides + return (m_dxgiDesc.DedicatedVideoMemory + m_dxgiDesc.DedicatedSystemMemory) / 1024; + } + std::optional NvapiAdapter::GetLuid() const { if (!m_vkIdProperties.deviceLUIDValid) return {}; diff --git a/src/sysinfo/nvapi_adapter.h b/src/sysinfo/nvapi_adapter.h index ddac7fc3..b517fc18 100644 --- a/src/sysinfo/nvapi_adapter.h +++ b/src/sysinfo/nvapi_adapter.h @@ -26,6 +26,7 @@ namespace dxvk { [[nodiscard]] uint32_t GetPciDeviceId() const; [[nodiscard]] uint32_t GetBoardId() const; [[nodiscard]] uint32_t GetVRamSize() const; + [[nodiscard]] uint32_t GetVirtualVRamSize() const; [[nodiscard]] std::optional GetLuid() const; [[nodiscard]] NV_GPU_ARCHITECTURE_ID GetArchitectureId() const; diff --git a/tests/nvapi_drs.cpp b/tests/nvapi_drs.cpp index 3bb539e3..660ba5a2 100644 --- a/tests/nvapi_drs.cpp +++ b/tests/nvapi_drs.cpp @@ -37,6 +37,12 @@ TEST_CASE("DRS methods succeed", "[.drs]") { REQUIRE(NvAPI_DRS_GetBaseProfile(handle, &profile) == NVAPI_OK); } + SECTION("GetCurrentGlobalProfile returns OK") { + NvDRSSessionHandle handle{}; + NvDRSProfileHandle profile; + REQUIRE(NvAPI_DRS_GetCurrentGlobalProfile(handle, &profile) == NVAPI_OK); + } + SECTION("GetSetting returns setting-not-found") { struct Data { int32_t settingId; diff --git a/tests/nvapi_sysinfo.cpp b/tests/nvapi_sysinfo.cpp index be329e73..5b248065 100644 --- a/tests/nvapi_sysinfo.cpp +++ b/tests/nvapi_sysinfo.cpp @@ -369,6 +369,18 @@ TEST_CASE("Sysinfo methods succeed", "[.sysinfo]") { REQUIRE(type == NV_SYSTEM_TYPE_DGPU); } + SECTION("GetSystemType returns OK") { + SetupResourceFactory(std::move(dxgiFactory), std::move(vulkan), std::move(nvml), std::move(lfx)); + REQUIRE(NvAPI_Initialize() == NVAPI_OK); + + NvPhysicalGpuHandle handle; + REQUIRE(NvAPI_SYS_GetPhysicalGpuFromDisplayId(primaryDisplayId, &handle) == NVAPI_OK); + + NV_SYSTEM_TYPE type; + REQUIRE(NvAPI_GPU_GetSystemType(handle, &type) == NVAPI_OK); + REQUIRE(type == NV_SYSTEM_TYPE_UNKNOWN); + } + SECTION("GetPCIIdentifiers returns OK") { ALLOW_CALL(adapter, GetDesc1(_)) .SIDE_EFFECT({ @@ -508,6 +520,26 @@ TEST_CASE("Sysinfo methods succeed", "[.sysinfo]") { REQUIRE(size == 8191); } + SECTION("GetVirtualFrameBufferSize returns OK") { + ALLOW_CALL(adapter, GetDesc1(_)) + .SIDE_EFFECT({ + _1->VendorId = 0x10de; + _1->DedicatedVideoMemory = 8191 * 1024; + _1->DedicatedSystemMemory = 1014 * 1024; + }) + .RETURN(S_OK); + + SetupResourceFactory(std::move(dxgiFactory), std::move(vulkan), std::move(nvml), std::move(lfx)); + REQUIRE(NvAPI_Initialize() == NVAPI_OK); + + NvPhysicalGpuHandle handle; + REQUIRE(NvAPI_SYS_GetPhysicalGpuFromDisplayId(primaryDisplayId, &handle) == NVAPI_OK); + + NvU32 size; + REQUIRE(NvAPI_GPU_GetVirtualFrameBufferSize(handle, &size) == NVAPI_OK); + REQUIRE(size == 9205); + } + SECTION("GetAdapterIdFromPhysicalGpu returns OK") { ALLOW_CALL(*vulkan, GetPhysicalDeviceProperties2(_, _, _)) .SIDE_EFFECT(