mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-28 05:11:37 +00:00
Add low-end defaults for low-end devices. Uses either the reported type by the API or the VRAM.
This commit is contained in:
parent
cd38776576
commit
25cfbe83e0
3 changed files with 58 additions and 0 deletions
|
|
@ -475,6 +475,14 @@ namespace plume {
|
||||||
|
|
||||||
typedef uint32_t RenderSampleCounts;
|
typedef uint32_t RenderSampleCounts;
|
||||||
|
|
||||||
|
enum class RenderDeviceType {
|
||||||
|
UNKNOWN,
|
||||||
|
INTEGRATED,
|
||||||
|
DISCRETE,
|
||||||
|
VIRTUAL,
|
||||||
|
CPU
|
||||||
|
};
|
||||||
|
|
||||||
// Global functions.
|
// Global functions.
|
||||||
|
|
||||||
constexpr uint32_t RenderFormatSize(RenderFormat format) {
|
constexpr uint32_t RenderFormatSize(RenderFormat format) {
|
||||||
|
|
@ -1754,6 +1762,7 @@ namespace plume {
|
||||||
|
|
||||||
struct RenderDeviceDescription {
|
struct RenderDeviceDescription {
|
||||||
std::string name = "Unknown";
|
std::string name = "Unknown";
|
||||||
|
RenderDeviceType type = RenderDeviceType::UNKNOWN;
|
||||||
uint32_t driverVersion = 0;
|
uint32_t driverVersion = 0;
|
||||||
uint64_t dedicatedVideoMemory = 0;
|
uint64_t dedicatedVideoMemory = 0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -705,6 +705,21 @@ namespace plume {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static RenderDeviceType toDeviceType(VkPhysicalDeviceType type) {
|
||||||
|
switch (type) {
|
||||||
|
case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU:
|
||||||
|
return RenderDeviceType::INTEGRATED;
|
||||||
|
case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU:
|
||||||
|
return RenderDeviceType::DISCRETE;
|
||||||
|
case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU:
|
||||||
|
return RenderDeviceType::VIRTUAL;
|
||||||
|
case VK_PHYSICAL_DEVICE_TYPE_CPU:
|
||||||
|
return RenderDeviceType::CPU;
|
||||||
|
default:
|
||||||
|
return RenderDeviceType::UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void setObjectName(VkDevice device, VkDebugReportObjectTypeEXT objectType, uint64_t object, const std::string &name) {
|
static void setObjectName(VkDevice device, VkDebugReportObjectTypeEXT objectType, uint64_t object, const std::string &name) {
|
||||||
# ifdef VULKAN_OBJECT_NAMES_ENABLED
|
# ifdef VULKAN_OBJECT_NAMES_ENABLED
|
||||||
VkDebugMarkerObjectNameInfoEXT nameInfo = {};
|
VkDebugMarkerObjectNameInfoEXT nameInfo = {};
|
||||||
|
|
@ -3496,6 +3511,7 @@ namespace plume {
|
||||||
if (preferOption) {
|
if (preferOption) {
|
||||||
physicalDevice = physicalDevices[i];
|
physicalDevice = physicalDevices[i];
|
||||||
description.name = std::string(deviceProperties.deviceName);
|
description.name = std::string(deviceProperties.deviceName);
|
||||||
|
description.type = toDeviceType(deviceProperties.deviceType);
|
||||||
description.driverVersion = deviceProperties.driverVersion;
|
description.driverVersion = deviceProperties.driverVersion;
|
||||||
currentDeviceTypeScore = deviceTypeScore;
|
currentDeviceTypeScore = deviceTypeScore;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1480,6 +1480,29 @@ static void BeginCommandList()
|
||||||
commandList->setGraphicsDescriptorSet(g_samplerDescriptorSet.get(), 3);
|
commandList->setGraphicsDescriptorSet(g_samplerDescriptorSet.get(), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
static void ApplyLowEndDefault(ConfigDef<T> &configDef, T newDefault, bool &changed)
|
||||||
|
{
|
||||||
|
if (configDef.IsDefaultValue() && !configDef.IsLoadedFromConfig)
|
||||||
|
{
|
||||||
|
configDef = newDefault;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ApplyLowEndDefaults()
|
||||||
|
{
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
|
ApplyLowEndDefault(Config::AntiAliasing, EAntiAliasing::MSAA2x, changed);
|
||||||
|
ApplyLowEndDefault(Config::ShadowResolution, EShadowResolution::Original, changed);
|
||||||
|
ApplyLowEndDefault(Config::TransparencyAntiAliasing, false, changed);
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
|
Config::Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Video::CreateHostDevice(const char *sdlVideoDriver)
|
bool Video::CreateHostDevice(const char *sdlVideoDriver)
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < 16; i++)
|
for (uint32_t i = 0; i < 16; i++)
|
||||||
|
|
@ -1529,6 +1552,16 @@ bool Video::CreateHostDevice(const char *sdlVideoDriver)
|
||||||
|
|
||||||
LoadEmbeddedResources();
|
LoadEmbeddedResources();
|
||||||
|
|
||||||
|
constexpr uint64_t LowEndMemoryLimit = 2048ULL * 1024ULL * 1024ULL;
|
||||||
|
RenderDeviceDescription deviceDescription = g_device->getDescription();
|
||||||
|
bool lowEndType = deviceDescription.type != RenderDeviceType::UNKNOWN && deviceDescription.type != RenderDeviceType::DISCRETE;
|
||||||
|
bool lowEndMemory = deviceDescription.dedicatedVideoMemory < LowEndMemoryLimit;
|
||||||
|
if (lowEndType || lowEndMemory)
|
||||||
|
{
|
||||||
|
// Switch to low end defaults if a non-discrete GPU was detected or a low amount of VRAM was detected.
|
||||||
|
ApplyLowEndDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
g_capabilities = g_device->getCapabilities();
|
g_capabilities = g_device->getCapabilities();
|
||||||
|
|
||||||
g_queue = g_device->createCommandQueue(RenderCommandListType::DIRECT);
|
g_queue = g_device->createCommandQueue(RenderCommandListType::DIRECT);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue