mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-15 07:29:17 +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)
|
if (pDesc == nullptr)
|
||||||
return DXGI_ERROR_INVALID_CALL;
|
return DXGI_ERROR_INVALID_CALL;
|
||||||
|
|
||||||
|
const DxgiOptions* options = m_factory->GetOptions();
|
||||||
|
|
||||||
auto deviceProp = m_adapter->deviceProperties();
|
auto deviceProp = m_adapter->deviceProperties();
|
||||||
auto memoryProp = m_adapter->memoryProperties();
|
auto memoryProp = m_adapter->memoryProperties();
|
||||||
|
|
||||||
// Custom Vendor / Device ID
|
// Custom Vendor / Device ID
|
||||||
const int32_t customVendorID = m_factory->GetOptions()->customVendorId;
|
if (options->customVendorId >= 0)
|
||||||
const int32_t customDeviceID = m_factory->GetOptions()->customDeviceId;
|
deviceProp.vendorID = options->customVendorId;
|
||||||
|
|
||||||
if (customVendorID >= 0) {
|
if (options->customDeviceId >= 0)
|
||||||
Logger::info(str::format("Using Custom PCI Vendor ID ", std::hex, customVendorID));
|
deviceProp.deviceID = options->customDeviceId;
|
||||||
deviceProp.vendorID = customVendorID;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (customDeviceID >= 0) {
|
|
||||||
Logger::info(str::format("Using Custom PCI Device ID ", std::hex, customDeviceID));
|
|
||||||
deviceProp.deviceID = customDeviceID;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Convert device name
|
||||||
std::memset(pDesc->Description, 0, sizeof(pDesc->Description));
|
std::memset(pDesc->Description, 0, sizeof(pDesc->Description));
|
||||||
::MultiByteToWideChar(CP_UTF8, 0, deviceProp.deviceName, -1, pDesc->Description,
|
::MultiByteToWideChar(CP_UTF8, 0, deviceProp.deviceName, -1,
|
||||||
sizeof(pDesc->Description));
|
pDesc->Description, sizeof(pDesc->Description));
|
||||||
|
|
||||||
|
// Get amount of video memory
|
||||||
|
// based on the Vulkan heaps
|
||||||
VkDeviceSize deviceMemory = 0;
|
VkDeviceSize deviceMemory = 0;
|
||||||
VkDeviceSize sharedMemory = 0;
|
VkDeviceSize sharedMemory = 0;
|
||||||
|
|
||||||
@ -176,6 +174,15 @@ namespace dxvk {
|
|||||||
sharedMemory += heap.size;
|
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
|
#ifndef _WIN64
|
||||||
// The value returned by DXGI is a 32-bit value
|
// The value returned by DXGI is a 32-bit value
|
||||||
// on 32-bit platforms, so we need to clamp it
|
// on 32-bit platforms, so we need to clamp it
|
||||||
|
@ -30,8 +30,14 @@ namespace dxvk {
|
|||||||
DxgiOptions::DxgiOptions(const Config& config) {
|
DxgiOptions::DxgiOptions(const Config& config) {
|
||||||
this->deferSurfaceCreation = config.getOption<bool> ("dxgi.deferSurfaceCreation", false);
|
this->deferSurfaceCreation = config.getOption<bool> ("dxgi.deferSurfaceCreation", false);
|
||||||
this->maxFrameLatency = config.getOption<int32_t> ("dxgi.maxFrameLatency", 0);
|
this->maxFrameLatency = config.getOption<int32_t> ("dxgi.maxFrameLatency", 0);
|
||||||
|
|
||||||
|
// Fetch these as a string representing a hexadecimal number and parse it.
|
||||||
this->customVendorId = parsePciId(config.getOption<std::string>("dxgi.customVendorId"));
|
this->customVendorId = parsePciId(config.getOption<std::string>("dxgi.customVendorId"));
|
||||||
this->customDeviceId = parsePciId(config.getOption<std::string>("dxgi.customDeviceId"));
|
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 "../util/config/config.h"
|
||||||
|
|
||||||
|
#include "../dxvk/dxvk_include.h"
|
||||||
|
|
||||||
#include "dxgi_include.h"
|
#include "dxgi_include.h"
|
||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
@ -29,6 +31,12 @@ namespace dxvk {
|
|||||||
/// on a different GPU than they do and behave differently.
|
/// on a different GPU than they do and behave differently.
|
||||||
int32_t customVendorId;
|
int32_t customVendorId;
|
||||||
int32_t customDeviceId;
|
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