From 1bad90ae96a4db30cf5c425980d1b693cea4e503 Mon Sep 17 00:00:00 2001 From: Guy1524 <35645466+Guy1524@users.noreply.github.com> Date: Sat, 10 Mar 2018 09:05:32 -0500 Subject: [PATCH] Add Custom PCI Vendor and Device ID Support (#137) * Add Custom PCI Vendor and Device ID Support Allow the user to configure DXVK to use a custom PCI Vendor and Device ID, so that the program behaves the same on different cards. * Remove AMD/NVIDIA/INTEL Shortcuts * Remove extra semicolon * Return DxvkGpuVendor to being an enum class * Fixed hexadecimal output --- src/dxvk/dxvk_adapter.cpp | 17 ++++++++++++++++- src/dxvk/dxvk_adapter.h | 4 +++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/dxvk/dxvk_adapter.cpp b/src/dxvk/dxvk_adapter.cpp index 16fa43122..90777e68f 100644 --- a/src/dxvk/dxvk_adapter.cpp +++ b/src/dxvk/dxvk_adapter.cpp @@ -32,6 +32,21 @@ namespace dxvk { VkPhysicalDeviceProperties properties; m_vki->vkGetPhysicalDeviceProperties(m_handle, &properties); + const std::string customVendorID = env::getEnvVar(L"DXVK_CUSTOM_VENDOR_ID"); + const std::string customDeviceID = env::getEnvVar(L"DXVK_CUSTOM_DEVICE_ID"); + + if (!customVendorID.empty()) { + Logger::info("Using Custom PCI Vendor ID " + customVendorID + " instead of " + str::format(std::hex, properties.vendorID)); + + properties.vendorID = std::stoul(customVendorID, nullptr, 16); + } + + if (!customDeviceID.empty()) { + Logger::info("Using Custom PCI Device ID " + customDeviceID + " instead of " + str::format(std::hex, properties.deviceID)); + + properties.deviceID = std::stoul(customDeviceID, nullptr, 16); + } + if (DxvkGpuVendor(properties.vendorID) == DxvkGpuVendor::Nvidia) { properties.driverVersion = VK_MAKE_VERSION( VK_VERSION_MAJOR(properties.driverVersion), @@ -238,4 +253,4 @@ namespace dxvk { Logger::info(str::format(" ", names.name(i))); } -} \ No newline at end of file +} diff --git a/src/dxvk/dxvk_adapter.h b/src/dxvk/dxvk_adapter.h index e08239abd..101c37b81 100644 --- a/src/dxvk/dxvk_adapter.h +++ b/src/dxvk/dxvk_adapter.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "./vulkan/dxvk_vulkan_extensions.h" #include "dxvk_include.h" @@ -167,4 +169,4 @@ namespace dxvk { }; -} \ No newline at end of file +}