Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions source/maindll/FFFrameInterpolator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@
bool g_EnableDebugOverlay = false;
bool g_EnableDebugTearLines = false;
bool g_EnableInterpolatedFramesOnly = false;
bool g_EnableHDRLuminanceOverride = false;
float g_HDRLuminanceMin = 0.0001f;
float g_HDRLuminanceMax = 1000.0000f;


extern "C" void __declspec(dllexport) RefreshGlobalConfiguration()
{
g_EnableDebugOverlay = Util::GetSetting(L"EnableDebugOverlay", false);
g_EnableDebugTearLines = Util::GetSetting(L"EnableDebugTearLines", false);
g_EnableInterpolatedFramesOnly = Util::GetSetting(L"EnableInterpolatedFramesOnly", false);
g_EnableHDRLuminanceOverride = Util::GetSetting(L"EnableHDRLuminanceOverride", false);
g_HDRLuminanceMin = Util::GetSetting(L"HDRLuminanceMin", g_HDRLuminanceMin);
g_HDRLuminanceMax = Util::GetSetting(L"HDRLuminanceMax", g_HDRLuminanceMax);
}

FFFrameInterpolator::FFFrameInterpolator(uint32_t OutputWidth, uint32_t OutputHeight)
Expand Down Expand Up @@ -209,6 +216,25 @@ void FFFrameInterpolator::QueryHDRLuminanceRange(NGXInstanceParameters *NGXParam
if (m_HDRLuminanceRangeSet)
return;

if (g_EnableHDRLuminanceOverride)
{
if (g_HDRLuminanceMin != m_HDRLuminanceMin)
{
m_HDRLuminanceMin = g_HDRLuminanceMin;
spdlog::info("Overriding HDR luminance min to {} nits", g_HDRLuminanceMin);
}

if (g_HDRLuminanceMax != m_HDRLuminanceMax)
{
m_HDRLuminanceMax = g_HDRLuminanceMax;
spdlog::info("Overriding HDR luminance max to {} nits", g_HDRLuminanceMax);
}

m_HDRLuminanceRange = { m_HDRLuminanceMin, m_HDRLuminanceMax };
m_HDRLuminanceRangeSet = true;
return;
}

// Microsoft DirectX 12 HDR sample
// https://github.com/microsoft/DirectX-Graphics-Samples/blob/b5f92e2251ee83db4d4c795b3cba5d470c52eaf8/Samples/Desktop/D3D12HDR/src/D3D12HDR.cpp#L1064
const auto luid = GetActiveAdapterLUID();
Expand Down
5 changes: 4 additions & 1 deletion source/maindll/FFFrameInterpolator.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ class FFFrameInterpolator
const uint32_t m_SwapchainWidth; // Final image presented to the screen dimensions
const uint32_t m_SwapchainHeight;

FfxFloatCoords2D m_HDRLuminanceRange = { 0.0001f, 1000.0f };
bool m_HDRLuminanceRangeSet = false;
float m_HDRLuminanceMin = 0.0001f;
float m_HDRLuminanceMax = 1000.0000f;
FfxFloatCoords2D m_HDRLuminanceRange = { m_HDRLuminanceMin, m_HDRLuminanceMax };


// Transient
uint32_t m_PreUpscaleRenderWidth = 0; // GBuffer dimensions
Expand Down
28 changes: 28 additions & 0 deletions source/maindll/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,32 @@ namespace Util
const static auto iniPath = GetThisDllPath() + L"\\dlssg_to_fsr3.ini";
return GetPrivateProfileIntW(L"Debug", Key, DefaultValue, iniPath.c_str()) != 0;
}

float GetSetting(const wchar_t *Key, float DefaultValue)
{
wchar_t envKey[256];
swprintf_s(envKey, L"DLSSGTOFSR3_%s", Key);

wchar_t envValue[64];
if (GetEnvironmentVariableW(envKey, envValue, std::size(envValue)) > 0)
{
wchar_t* endPtr;
float result = wcstof(envValue, &endPtr);
if (endPtr != envValue)
return result;
}

const static auto iniPath = GetThisDllPath() + L"\\dlssg_to_fsr3.ini";

wchar_t iniValue[64];
if (GetPrivateProfileStringW(L"Debug", Key, nullptr, iniValue, std::size(iniValue), iniPath.c_str()) > 0)
{
wchar_t* endPtr;
float result = wcstof(iniValue, &endPtr);
if (endPtr != iniValue)
return result;
}

return DefaultValue;
}
}
1 change: 1 addition & 0 deletions source/maindll/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ namespace Util
{
void InitializeLog();
bool GetSetting(const wchar_t *Key, bool DefaultValue);
float GetSetting(const wchar_t *Key, float DefaultValue);
}