diff --git a/src/dxgi/dxgi_adapter.cpp b/src/dxgi/dxgi_adapter.cpp index 7de26ccd..63ff001b 100644 --- a/src/dxgi/dxgi_adapter.cpp +++ b/src/dxgi/dxgi_adapter.cpp @@ -143,27 +143,25 @@ namespace dxvk { if (pDesc == nullptr) return DXGI_ERROR_INVALID_CALL; + const DxgiOptions* options = m_factory->GetOptions(); + auto deviceProp = m_adapter->deviceProperties(); auto memoryProp = m_adapter->memoryProperties(); // Custom Vendor / Device ID - const int32_t customVendorID = m_factory->GetOptions()->customVendorId; - const int32_t customDeviceID = m_factory->GetOptions()->customDeviceId; + if (options->customVendorId >= 0) + deviceProp.vendorID = options->customVendorId; - if (customVendorID >= 0) { - Logger::info(str::format("Using Custom PCI Vendor ID ", std::hex, customVendorID)); - deviceProp.vendorID = customVendorID; - } - - if (customDeviceID >= 0) { - Logger::info(str::format("Using Custom PCI Device ID ", std::hex, customDeviceID)); - deviceProp.deviceID = customDeviceID; - } + if (options->customDeviceId >= 0) + deviceProp.deviceID = options->customDeviceId; + // Convert device name std::memset(pDesc->Description, 0, sizeof(pDesc->Description)); - ::MultiByteToWideChar(CP_UTF8, 0, deviceProp.deviceName, -1, pDesc->Description, - sizeof(pDesc->Description)); + ::MultiByteToWideChar(CP_UTF8, 0, deviceProp.deviceName, -1, + pDesc->Description, sizeof(pDesc->Description)); + // Get amount of video memory + // based on the Vulkan heaps VkDeviceSize deviceMemory = 0; VkDeviceSize sharedMemory = 0; @@ -176,6 +174,15 @@ namespace dxvk { sharedMemory += heap.size; } + // Some games are silly and need their memory limited + if (options->maxDeviceMemory > 0 + && options->maxDeviceMemory < deviceMemory) + deviceMemory = options->maxDeviceMemory; + + if (options->maxSharedMemory > 0 + && options->maxSharedMemory < sharedMemory) + sharedMemory = options->maxSharedMemory; + #ifndef _WIN64 // The value returned by DXGI is a 32-bit value // on 32-bit platforms, so we need to clamp it diff --git a/src/dxgi/dxgi_options.cpp b/src/dxgi/dxgi_options.cpp index 05957bbb..033e4d5a 100644 --- a/src/dxgi/dxgi_options.cpp +++ b/src/dxgi/dxgi_options.cpp @@ -30,8 +30,14 @@ namespace dxvk { DxgiOptions::DxgiOptions(const Config& config) { this->deferSurfaceCreation = config.getOption ("dxgi.deferSurfaceCreation", false); this->maxFrameLatency = config.getOption ("dxgi.maxFrameLatency", 0); - this->customVendorId = parsePciId(config.getOption("dxgi.customVendorId")); - this->customDeviceId = parsePciId(config.getOption("dxgi.customDeviceId")); + + // Fetch these as a string representing a hexadecimal number and parse it. + this->customVendorId = parsePciId(config.getOption("dxgi.customVendorId")); + this->customDeviceId = parsePciId(config.getOption("dxgi.customDeviceId")); + + // Interpret the memory limits as Megabytes + this->maxDeviceMemory = VkDeviceSize(config.getOption("dxgi.maxDeviceMemory", 0)) << 20; + this->maxSharedMemory = VkDeviceSize(config.getOption("dxgi.maxSharedMemory", 0)) << 20; } } \ No newline at end of file diff --git a/src/dxgi/dxgi_options.h b/src/dxgi/dxgi_options.h index a1736b83..b078eb05 100644 --- a/src/dxgi/dxgi_options.h +++ b/src/dxgi/dxgi_options.h @@ -2,6 +2,8 @@ #include "../util/config/config.h" +#include "../dxvk/dxvk_include.h" + #include "dxgi_include.h" namespace dxvk { @@ -29,6 +31,12 @@ namespace dxvk { /// on a different GPU than they do and behave differently. int32_t customVendorId; int32_t customDeviceId; + + /// Override maximum reported VRAM size. This may be + /// useful for some 64-bit games which do not support + /// more than 4 GiB of VRAM. + VkDeviceSize maxDeviceMemory; + VkDeviceSize maxSharedMemory; }; }