Changed DontCreateD3D12DeviceForLuma to CreateD3D12DeviceForLuma for more user controllable behaviour

This commit is contained in:
cdozdil
2026-06-11 03:05:31 +02:00
committed by FakeMichau
parent 78d8222ccb
commit 663f976a2f
7 changed files with 35 additions and 26 deletions
+4 -4
View File
@@ -1403,11 +1403,11 @@ DisableOverlays=auto
; true or false - Default (auto) is false
SimulateWaitableObject=auto
; When using Luma mod and Agility update is enabled
; OptiScaler will delay loading of Reshade and create D3D12 device for Luma first
; This option will prevent creation of D3D12 device for Luma mod
; OptiScaler will delay loading of Reshade and create D3D12 device first
; This option will prevent warnings/crashes with Luma and some other ReShade mods
; When using Luma mod and this will be enabled
; true or false - Default (auto) is false
DontCreateD3D12DeviceForLuma=auto
CreateD3D12DeviceForLuma=auto
; OptiScaler will try to force High Performance GPU
; true or false - Default (auto) is false
+3 -3
View File
@@ -608,7 +608,7 @@ bool Config::Reload(std::filesystem::path iniPath)
MaskResourceBarrier.set_from_config(readInt("Hotfix", "ColorMaskResourceBarrier"));
ExposureResourceBarrier.set_from_config(readInt("Hotfix", "ExposureResourceBarrier"));
OutputResourceBarrier.set_from_config(readInt("Hotfix", "OutputResourceBarrier"));
DontCreateD3D12DeviceForLuma.set_from_config(readBool("Hotfix", "DontCreateD3D12DeviceForLuma"));
CreateD3D12DeviceForLuma.set_from_config(readBool("Hotfix", "CreateD3D12DeviceForLuma"));
}
// Dx11 with Dx12
@@ -1276,8 +1276,8 @@ bool Config::SaveIni()
// Hotfixes
{
ini.SetValue("Hotfix", "DontCreateD3D12DeviceForLuma",
GetBoolValue(Instance()->DontCreateD3D12DeviceForLuma.value_for_config()).c_str());
ini.SetValue("Hotfix", "CreateD3D12DeviceForLuma",
GetBoolValue(Instance()->CreateD3D12DeviceForLuma.value_for_config()).c_str());
ini.SetValue("Hotfix", "CheckForUpdate", GetBoolValue(Instance()->CheckForUpdate.value_for_config()).c_str());
ini.SetValue("Hotfix", "SimulateWaitableObject",
GetBoolValue(Instance()->SimulateWaitableObject.value_for_config()).c_str());
+1 -1
View File
@@ -404,7 +404,7 @@ class Config
CustomOptional<int32_t, NoDefault> MaskResourceBarrier; // disabled by default
CustomOptional<int32_t, NoDefault> OutputResourceBarrier; // disabled by default
CustomOptional<bool> DontCreateD3D12DeviceForLuma { false };
CustomOptional<bool> CreateD3D12DeviceForLuma { false };
// Upscalers
CustomOptional<Upscaler, SoftDefault> Dx11Upscaler { Upscaler::FSR22 };
+3 -3
View File
@@ -116,7 +116,7 @@ std::string Util::GetWindowsName(const OSVERSIONINFOW& os)
return "Unknown Windows Version";
}
static std::wstring ToLower(std::wstring value)
std::wstring Util::ToLower(std::wstring value)
{
std::transform(value.begin(), value.end(), value.begin(),
[](wchar_t c) { return static_cast<wchar_t>(std::towlower(c)); });
@@ -147,14 +147,14 @@ static bool HasUnrealBinariesParentStructure(const std::filesystem::path& exePat
if (binariesDir.empty())
return false;
std::wstring binariesName = ToLower(binariesDir.filename().wstring());
std::wstring binariesName = Util::ToLower(binariesDir.filename().wstring());
bool isBinariesFolder = binariesName == L"binaries";
if (!isBinariesFolder)
return false;
std::wstring platformName = ToLower(platformDir.filename().wstring());
std::wstring platformName = Util::ToLower(platformDir.filename().wstring());
bool isWindowsPlatformFolder = platformName == L"win64" || platformName == L"win32" || platformName == L"wingdk" ||
platformName == L"windows" || platformName.starts_with(L"win");
+2
View File
@@ -63,7 +63,9 @@ struct MonitorInfo
std::filesystem::path ExePath();
std::filesystem::path DllPath();
std::optional<std::filesystem::path> NvngxPath();
double MillisecondsNow();
std::wstring ToLower(std::wstring value);
HWND GetProcessWindow();
bool GetFileVersion(std::wstring dllPath, version_t* fileVersionOut, version_t* productVersionOut = nullptr);
+20 -13
View File
@@ -1113,15 +1113,14 @@ static void CheckWorkingMode()
LOG_INFO("Loading SpecialK64.dll, result: {0:X}", (UINT64) skModule);
}
// ReShade
// Do not load Reshade here is Luma is active and we will create D3D12 device for it
// We will load Reshade after D3D12 device creation in that case
if (reshadeModule == nullptr && Config::Instance()->LoadReShade.value_or_default() &&
(!(State::Instance().gameQuirks & GameQuirk::CreateD3D12DeviceForLuma) ||
Config::Instance()->DontCreateD3D12DeviceForLuma.value_or_default()))
{
auto rsFile = Util::ExePath().parent_path() / L"ReShade64.dll";
SetEnvironmentVariableW(L"RESHADE_DISABLE_LOADING_CHECK", L"1");
// ReShade
// Do not load Reshade here is Luma is active and we will create D3D12 device for it
// We will load Reshade after D3D12 device creation in that case
if (reshadeModule == nullptr && Config::Instance()->LoadReShade.value_or_default() &&
!Config::Instance()->CreateD3D12DeviceForLuma.value_or_default())
{
auto rsFile = Util::ExePath().parent_path() / L"ReShade64.dll";
SetEnvironmentVariableW(L"RESHADE_DISABLE_LOADING_CHECK", L"1");
if (skModule != nullptr)
SetEnvironmentVariableW(L"RESHADE_DISABLE_GRAPHICS_HOOK", L"1");
@@ -1540,8 +1539,10 @@ static void CheckQuirks(bool isNvidia)
const auto& path = entry.path();
if (path.extension() == L".addon")
{
const auto fname = path.filename().wstring();
if (fname.rfind(L"Luma-", 0) == 0) // starts with "Luma-"
const auto fname = Util::ToLower(path.filename().wstring());
// starts with "luma-" or "dlaa-inject."
if (fname.rfind(L"luma-", 0) == 0 || fname.rfind(L"dlaa-inject.", 0) == 0)
{
lumaDetected = true;
break;
@@ -1565,12 +1566,15 @@ static void CheckQuirks(bool isNvidia)
Config::Instance()->DontUseNTShared.set_volatile_value(true);
}
if (!Config::Instance()->DontCreateD3D12DeviceForLuma.value_or_default())
if (!Config::Instance()->CreateD3D12DeviceForLuma.has_value())
{
quirks |= GameQuirk::LoadD3D12Manually;
if (Config::Instance()->LoadReShade.value_or_default())
{
Config::Instance()->CreateD3D12DeviceForLuma.set_volatile_value(true);
quirks |= GameQuirk::CreateD3D12DeviceForLuma;
}
}
}
@@ -1591,12 +1595,15 @@ static void CheckQuirks(bool isNvidia)
Config::Instance()->DontUseNTShared.set_volatile_value(true);
}
if (!Config::Instance()->DontCreateD3D12DeviceForLuma.value_or_default())
if (!Config::Instance()->CreateD3D12DeviceForLuma.has_value())
{
quirks |= GameQuirk::LoadD3D12Manually;
if (Config::Instance()->LoadReShade.value_or_default())
{
Config::Instance()->CreateD3D12DeviceForLuma.set_volatile_value(true);
quirks |= GameQuirk::CreateD3D12DeviceForLuma;
}
}
}
+2 -2
View File
@@ -37,7 +37,7 @@ static void InitD3D12DeviceForLuma(IDXGIFactory* factory)
static void CheckLumaAndReShade(IDXGIFactory* factory)
{
if (!Config::Instance()->LoadReShade.value_or_default() ||
!(State::Instance().gameQuirks & GameQuirk::CreateD3D12DeviceForLuma) ||
!Config::Instance()->CreateD3D12DeviceForLuma.value_or_default() ||
State::Instance().currentD3D12Device != nullptr || creatingD3D12DeviceForLuma)
{
return;
@@ -55,7 +55,7 @@ static void CheckLumaAndReShade(IDXGIFactory* factory)
}
// For Luma mod + Agility update we are creating D3D12 device early to prevent issues with Luma
if (State::Instance().gameQuirks & GameQuirk::CreateD3D12DeviceForLuma &&
if (Config::Instance()->CreateD3D12DeviceForLuma.value_or_default() &&
State::Instance().currentD3D12Device == nullptr)
{
ScopedSkipDxgiLoadChecks skipDxgiLoadChecks {};