Check for UMA flag on D3D12 to detect integrated GPUs.

This commit is contained in:
Skyth 2025-01-31 15:09:54 +03:00 committed by Dario
parent 8888b2750a
commit 1b76b6ce35
3 changed files with 19 additions and 4 deletions

View file

@ -3324,6 +3324,14 @@ namespace plume {
dynamicDepthBiasOption = d3d12Options16.DynamicDepthBiasSupported;
}
// Check if the architecture has UMA.
bool uma = false;
D3D12_FEATURE_DATA_ARCHITECTURE1 architecture1 = {};
res = deviceOption->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE1, &architecture1, sizeof(architecture1));
if (SUCCEEDED(res)) {
uma = architecture1.UMA;
}
// Pick this adapter and device if it has better feature support than the current one.
bool preferOverNothing = (adapter == nullptr) || (d3d == nullptr);
bool preferVideoMemory = adapterDesc.DedicatedVideoMemory > description.dedicatedVideoMemory;
@ -3346,6 +3354,7 @@ namespace plume {
capabilities.sampleLocations = samplePositionsOption;
capabilities.triangleFan = triangleFanSupportOption;
capabilities.dynamicDepthBias = dynamicDepthBiasOption;
capabilities.uma = uma;
description.name = Utf16ToUtf8(adapterDesc.Description);
description.dedicatedVideoMemory = adapterDesc.DedicatedVideoMemory;

View file

@ -1789,6 +1789,9 @@ namespace plume {
// Draw.
bool triangleFan = false;
bool dynamicDepthBias = false;
// UMA.
bool uma = false;
};
struct RenderInterfaceCapabilities {

View file

@ -1499,7 +1499,8 @@ static void ApplyLowEndDefaults()
ApplyLowEndDefault(Config::TransparencyAntiAliasing, false, changed);
ApplyLowEndDefault(Config::GITextureFiltering, EGITextureFiltering::Bilinear, changed);
if (changed) {
if (changed)
{
Config::Save();
}
}
@ -1550,6 +1551,8 @@ bool Video::CreateHostDevice(const char *sdlVideoDriver)
{
return false;
}
g_capabilities = g_device->getCapabilities();
LoadEmbeddedResources();
@ -1557,14 +1560,14 @@ bool Video::CreateHostDevice(const char *sdlVideoDriver)
RenderDeviceDescription deviceDescription = g_device->getDescription();
bool lowEndType = deviceDescription.type != RenderDeviceType::UNKNOWN && deviceDescription.type != RenderDeviceType::DISCRETE;
bool lowEndMemory = deviceDescription.dedicatedVideoMemory < LowEndMemoryLimit;
if (lowEndType || lowEndMemory)
bool lowEndUMA = deviceDescription.type == RenderDeviceType::UNKNOWN && g_capabilities.uma;
if (lowEndType || lowEndMemory || lowEndUMA)
{
// Switch to low end defaults if a non-discrete GPU was detected or a low amount of VRAM was detected.
// Checking for UMA on D3D12 seems to be a reliable way to detect integrated GPUs.
ApplyLowEndDefaults();
}
g_capabilities = g_device->getCapabilities();
g_queue = g_device->createCommandQueue(RenderCommandListType::DIRECT);
for (auto& commandList : g_commandLists)