mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-13 19:29:14 +01:00
[dxgi] Add option to limit reported device memory size
This commit is contained in:
parent
48697346c0
commit
57db0b60fb
@ -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
|
||||
|
@ -30,8 +30,14 @@ namespace dxvk {
|
||||
DxgiOptions::DxgiOptions(const Config& config) {
|
||||
this->deferSurfaceCreation = config.getOption<bool> ("dxgi.deferSurfaceCreation", 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"));
|
||||
|
||||
// Fetch these as a string representing a hexadecimal number and parse it.
|
||||
this->customVendorId = parsePciId(config.getOption<std::string>("dxgi.customVendorId"));
|
||||
this->customDeviceId = parsePciId(config.getOption<std::string>("dxgi.customDeviceId"));
|
||||
|
||||
// Interpret the memory limits as Megabytes
|
||||
this->maxDeviceMemory = VkDeviceSize(config.getOption<int32_t>("dxgi.maxDeviceMemory", 0)) << 20;
|
||||
this->maxSharedMemory = VkDeviceSize(config.getOption<int32_t>("dxgi.maxSharedMemory", 0)) << 20;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user