[dxgi] Add custom device/vendor IDs to DxgiOptions

This commit is contained in:
Philip Rebohle 2018-08-07 17:33:19 +02:00
parent fb9b520f60
commit f08add9c34
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 40 additions and 11 deletions

View File

@ -81,8 +81,6 @@ Additionally, `DXVK_HUD=1` has the same effect as `DXVK_HUD=devinfo,fps`.
### Debugging
The following environment variables can be used for **debugging** purposes.
- `VK_INSTANCE_LAYERS=VK_LAYER_LUNARG_standard_validation` Enables Vulkan debug layers. Highly recommended for troubleshooting rendering issues and driver crashes. Requires the Vulkan SDK to be installed on the host system.
- `DXVK_CUSTOM_VENDOR_ID=<ID>` Specifies a custom PCI vendor ID
- `DXVK_CUSTOM_DEVICE_ID=<ID>` Specifies a custom PCI device ID
- `DXVK_LOG_LEVEL=none|error|warn|info|debug` Controls message logging
## Troubleshooting

View File

@ -150,18 +150,18 @@ namespace dxvk {
auto deviceProp = m_adapter->deviceProperties();
auto memoryProp = m_adapter->memoryProperties();
// Custom Vendor ID
const std::string customVendorID = env::getEnvVar(L"DXVK_CUSTOM_VENDOR_ID");
const std::string customDeviceID = env::getEnvVar(L"DXVK_CUSTOM_DEVICE_ID");
// Custom Vendor / Device ID
const int32_t customVendorID = m_factory->GetOptions()->customVendorId;
const int32_t customDeviceID = m_factory->GetOptions()->customDeviceId;
if (!customVendorID.empty()) {
Logger::info("Using Custom PCI Vendor ID " + customVendorID + " instead of " + str::format(std::hex, deviceProp.vendorID));
deviceProp.vendorID = std::stoul(customVendorID, nullptr, 16);
if (customVendorID >= 0) {
Logger::info(str::format("Using Custom PCI Vendor ID ", std::hex, customVendorID));
deviceProp.vendorID = customVendorID;
}
if (!customDeviceID.empty()) {
Logger::info("Using Custom PCI Device ID " + customDeviceID + " instead of " + str::format(std::hex, deviceProp.deviceID));
deviceProp.deviceID = std::stoul(customDeviceID, nullptr, 16);
if (customDeviceID >= 0) {
Logger::info(str::format("Using Custom PCI Device ID ", std::hex, customDeviceID));
deviceProp.deviceID = customDeviceID;
}
std::memset(pDesc->Description, 0, sizeof(pDesc->Description));

View File

@ -3,11 +3,36 @@
#include <unordered_map>
namespace dxvk {
static int32_t parsePciId(const std::string& str) {
if (str.size() != 4)
return -1;
int32_t id = 0;
for (size_t i = 0; i < str.size(); i++) {
id *= 16;
if (str[i] >= '0' && str[i] <= '9')
id += str[i] - '0';
else if (str[i] >= 'A' && str[i] <= 'F')
id += str[i] - 'A' + 10;
else if (str[i] >= 'a' && str[i] <= 'f')
id += str[i] - 'a' + 10;
else
return -1;
}
return id;
}
DxgiOptions::DxgiOptions(const Config& config) {
this->deferSurfaceCreation = config.getOption<bool> ("dxgi.deferSurfaceCreation", false);
this->fakeDx10Support = config.getOption<bool> ("dxgi.fakeDx10Support", false);
this->maxFrameLatency = config.getOption<int32_t> ("dxgi.maxFrameLatency", 0);
this->customVendorId = parsePciId(config.getOption<std::string>("dxgi.customVendorId"));
this->customDeviceId = parsePciId(config.getOption<std::string>("dxgi.customDeviceId"));
}
}

View File

@ -28,6 +28,12 @@ namespace dxvk {
/// Override maximum frame latency if the app specifies
/// a higher value. May help with frame timing issues.
int32_t maxFrameLatency;
/// Override PCI vendor and device IDs reported to the
/// application. This may make apps think they are running
/// on a different GPU than they do and behave differently.
int32_t customVendorId;
int32_t customDeviceId;
};
}