From 435609d4080373a008cc0312fb65641d35feae9c Mon Sep 17 00:00:00 2001 From: FakeMichau <49685661+FakeMichau@users.noreply.github.com> Date: Thu, 1 Oct 2026 15:50:50 +0200 Subject: [PATCH] Add DLSS Dx11 w/Dx12 and DLSS Vk w/Dx12 Let's you use the DX12 DLSS on DX11 and VK --- OptiScaler/OptiScaler.vcxproj | 4 +++ OptiScaler/OptiScaler.vcxproj.filters | 12 +++++++ OptiScaler/OptiTypes.cpp | 19 +++++++---- OptiScaler/OptiTypes.h | 2 ++ OptiScaler/inputs/NVNGX_DLSS_Dx11.cpp | 2 +- OptiScaler/menu/menu_common.cpp | 34 ++++++++++++------- OptiScaler/upscalers/FeatureProvider_Dx11.cpp | 20 +++++++++-- OptiScaler/upscalers/FeatureProvider_Vk.cpp | 22 ++++++++++-- .../upscalers/dlss/DLSSFeature_Dx11On12.cpp | 11 ++++++ .../upscalers/dlss/DLSSFeature_Dx11On12.h | 10 ++++++ .../upscalers/dlss/DLSSFeature_VkOnDx12.cpp | 11 ++++++ .../upscalers/dlss/DLSSFeature_VkOnDx12.h | 10 ++++++ 12 files changed, 132 insertions(+), 25 deletions(-) create mode 100644 OptiScaler/upscalers/dlss/DLSSFeature_Dx11On12.cpp create mode 100644 OptiScaler/upscalers/dlss/DLSSFeature_Dx11On12.h create mode 100644 OptiScaler/upscalers/dlss/DLSSFeature_VkOnDx12.cpp create mode 100644 OptiScaler/upscalers/dlss/DLSSFeature_VkOnDx12.h diff --git a/OptiScaler/OptiScaler.vcxproj b/OptiScaler/OptiScaler.vcxproj index 24ca80bc..a160fd48 100644 --- a/OptiScaler/OptiScaler.vcxproj +++ b/OptiScaler/OptiScaler.vcxproj @@ -438,6 +438,8 @@ copy NUL "$(SolutionDir)x64\Release\a\!! EXTRACT ALL FILES TO GAME FOLDER !!" /Y + + @@ -700,6 +702,8 @@ copy NUL "$(SolutionDir)x64\Release\a\!! EXTRACT ALL FILES TO GAME FOLDER !!" /Y + + diff --git a/OptiScaler/OptiScaler.vcxproj.filters b/OptiScaler/OptiScaler.vcxproj.filters index 5742ac71..a600096d 100644 --- a/OptiScaler/OptiScaler.vcxproj.filters +++ b/OptiScaler/OptiScaler.vcxproj.filters @@ -983,6 +983,12 @@ Header Files + + Header Files + + + Header Files + @@ -1592,6 +1598,12 @@ Source Files + + Source Files + + + Source Files + diff --git a/OptiScaler/OptiTypes.cpp b/OptiScaler/OptiTypes.cpp index d9611335..379e9475 100644 --- a/OptiScaler/OptiTypes.cpp +++ b/OptiScaler/OptiTypes.cpp @@ -76,6 +76,9 @@ std::string UpscalerDisplayName(Upscaler upscaler, API api) case Upscaler::DLSS: return "DLSS"; + case Upscaler::DLSS_on12: + return "DLSS w/Dx12"; + case Upscaler::DLSSD: return "DLSSD"; } @@ -112,6 +115,7 @@ std::string UpscalerShortName(Upscaler upscaler) return "XeSS"; case Upscaler::DLSS: + case Upscaler::DLSS_on12: return "DLSS"; case Upscaler::DLSSD: @@ -144,6 +148,8 @@ std::string UpscalerToCode(Upscaler upscaler) return "ffx_12"; case Upscaler::DLSS: return "dlss"; + case Upscaler::DLSS_on12: + return "dlss_12"; case Upscaler::DLSSD: return "dlssd"; case Upscaler::FSR31: // DX11 only @@ -157,12 +163,13 @@ std::string UpscalerToCode(Upscaler upscaler) Upscaler CodeToUpscaler(const std::string& code) { static const std::unordered_map mapping = { - { "xess", Upscaler::XeSS }, { "xess_12", Upscaler::XeSS_on12 }, - { "fsr21", Upscaler::FSR21 }, { "fsr21_12", Upscaler::FSR21_on12 }, - { "fsr22", Upscaler::FSR22 }, { "fsr22_12", Upscaler::FSR22_on12 }, - { "ffx", Upscaler::FFX }, { "ffx_12", Upscaler::FFX_on12 }, - { "dlss", Upscaler::DLSS }, { "dlssd", Upscaler::DLSSD }, - { "fsr31", Upscaler::FSR31 }, { "fsr31_12", Upscaler::FFX_on12 }, // for compat reasons + { "xess", Upscaler::XeSS }, { "xess_12", Upscaler::XeSS_on12 }, + { "fsr21", Upscaler::FSR21 }, { "fsr21_12", Upscaler::FSR21_on12 }, + { "fsr22", Upscaler::FSR22 }, { "fsr22_12", Upscaler::FSR22_on12 }, + { "ffx", Upscaler::FFX }, { "ffx_12", Upscaler::FFX_on12 }, + { "dlss", Upscaler::DLSS }, { "dlss_12", Upscaler::DLSS_on12 }, + { "dlssd", Upscaler::DLSSD }, { "fsr31", Upscaler::FSR31 }, + { "fsr31_12", Upscaler::FFX_on12 }, // for compat reasons }; auto it = mapping.find(code); diff --git a/OptiScaler/OptiTypes.h b/OptiScaler/OptiTypes.h index 60974d8d..cd6ef2c0 100644 --- a/OptiScaler/OptiTypes.h +++ b/OptiScaler/OptiTypes.h @@ -64,6 +64,8 @@ enum class Upscaler DLSS, // "dlss", used for the DLSS upscaler backend + DLSS_on12, // DX12 dlss using interops + DLSSD, // "dlssd", used for the DLSS-D/Ray Reconstruction upscaler+denoiser backend Reset }; diff --git a/OptiScaler/inputs/NVNGX_DLSS_Dx11.cpp b/OptiScaler/inputs/NVNGX_DLSS_Dx11.cpp index 3e23f52f..741ea8f9 100644 --- a/OptiScaler/inputs/NVNGX_DLSS_Dx11.cpp +++ b/OptiScaler/inputs/NVNGX_DLSS_Dx11.cpp @@ -825,7 +825,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_EvaluateFeature(ID3D11DeviceConte auto upscaler = deviceContext->GetUpscalerType(); if (!upscaleResult && !deviceContext->IsInited() && (upscaler == Upscaler::XeSS || upscaler == Upscaler::XeSS_on12 || upscaler == Upscaler::DLSS || - upscaler == Upscaler::FFX_on12)) + upscaler == Upscaler::DLSS_on12 || upscaler == Upscaler::FFX_on12)) { ImGui::InsertNotification({ ImGuiToastType::Error, 10000, "Upscaler failed to run!" }); state.newBackend = Upscaler::FSR22; diff --git a/OptiScaler/menu/menu_common.cpp b/OptiScaler/menu/menu_common.cpp index c243d197..f75e792e 100644 --- a/OptiScaler/menu/menu_common.cpp +++ b/OptiScaler/menu/menu_common.cpp @@ -485,7 +485,7 @@ void MenuCommon::RenderUpscalerCombo(const API api, Upscaler currentUpscaler, co for (auto opt : options) { // Check if GPU is capable of a given backend - if (opt == Upscaler::DLSS && !primaryGpu.dlssCapable) + if ((opt == Upscaler::DLSS || opt == Upscaler::DLSS_on12) && !primaryGpu.dlssCapable) continue; // Not all Intel GPUs support native DX11 XeSS but don't think we have a good way to check exactly @@ -506,7 +506,7 @@ void MenuCommon::AddDx11Backends(Upscaler upscaler) { RenderUpscalerCombo(API::DX11, upscaler, { Upscaler::XeSS, Upscaler::FSR22, Upscaler::FSR31, Upscaler::XeSS_on12, Upscaler::FSR21_on12, - Upscaler::FSR22_on12, Upscaler::FFX_on12, Upscaler::DLSS }); + Upscaler::FSR22_on12, Upscaler::FFX_on12, Upscaler::DLSS, Upscaler::DLSS_on12 }); } void MenuCommon::AddDx12Backends(Upscaler upscaler) @@ -519,7 +519,7 @@ void MenuCommon::AddVulkanBackends(Upscaler upscaler) { RenderUpscalerCombo(API::Vulkan, upscaler, { Upscaler::XeSS, Upscaler::FSR21, Upscaler::FSR22, Upscaler::FFX, Upscaler::FSR21_on12, - Upscaler::FFX_on12, Upscaler::DLSS }); + Upscaler::FFX_on12, Upscaler::DLSS, Upscaler::DLSS_on12 }); } template void MenuCommon::AddResourceBarrier(std::string name, CustomOptional* value) @@ -1502,9 +1502,11 @@ void MenuCommon::HandleMenuShortcuts(RenderMenuContext& ctx) if (State::Instance().currentFeature != nullptr) { - if (State::Instance().currentFeature->GetUpscalerType() == Upscaler::DLSSD) + auto upscalerType = State::Instance().currentFeature->GetUpscalerType(); + + if (upscalerType == Upscaler::DLSSD) comboPreset = config->DLSSDRenderPresetForAll.value_or_default(); - else if (State::Instance().currentFeature->GetUpscalerType() == Upscaler::DLSS) + else if (upscalerType == Upscaler::DLSS || upscalerType == Upscaler::DLSS_on12) comboPreset = config->RenderPresetForAll.value_or_default(); } } @@ -2975,7 +2977,8 @@ void MenuCommon::RenderActiveUpscalerSettings(RenderMenuContext& ctx) } // DLSS ----------------- - if ((config->DLSSEnabled.value_or_default() && currentBackend == Upscaler::DLSS && + if ((config->DLSSEnabled.value_or_default() && + (currentBackend == Upscaler::DLSS || currentBackend == Upscaler::DLSS_on12) && currentFeature->Version().major > 2) || usesDlssd) { @@ -5473,7 +5476,8 @@ void MenuCommon::RenderActiveImageSettings(RenderMenuContext& ctx) { config->OverrideSharpness = overrideSharpness; - if (currentBackend == Upscaler::DLSS && currentFeature->Version().major < 3) + if ((currentBackend == Upscaler::DLSS || currentBackend == Upscaler::DLSS_on12) && + currentFeature->Version().major < 3) { state.newBackend = currentBackend; MARK_ALL_BACKENDS_CHANGED(); @@ -5504,8 +5508,9 @@ void MenuCommon::RenderActiveImageSettings(RenderMenuContext& ctx) { // xess or dlss version >= 2.5.1 constexpr feature_version requiredDlssVersion = { 2, 5, 1 }; - rcasEnabled = (currentBackend == Upscaler::XeSS || - (currentBackend == Upscaler::DLSS && currentFeature->Version() >= requiredDlssVersion)); + const bool isDlss = currentBackend == Upscaler::DLSS || currentBackend == Upscaler::DLSS_on12; + rcasEnabled = + currentBackend == Upscaler::XeSS || (isDlss && currentFeature->Version() >= requiredDlssVersion); ImGui::Spacing(); ImGui::Spacing(); @@ -5808,7 +5813,8 @@ void MenuCommon::RenderActiveImageSettings(RenderMenuContext& ctx) _ssDownsampler = config->OutputScalingDownscaler.value_or_default(); } - ImGui::BeginDisabled((currentBackend == Upscaler::XeSS || currentBackend == Upscaler::DLSS) && + ImGui::BeginDisabled((currentBackend == Upscaler::XeSS || currentBackend == Upscaler::DLSS || + currentBackend == Upscaler::DLSS_on12) && currentFeature->RenderWidth() > currentFeature->DisplayWidth()); ImGui::Checkbox("Enable", &_ssEnabled); ImGui::EndDisabled(); @@ -5936,7 +5942,7 @@ void MenuCommon::RenderActiveImageSettings(RenderMenuContext& ctx) ImGui::BeginDisabled(!accessToReactiveMask); bool canUseReactiveMask = - accessToReactiveMask && currentBackend != Upscaler::DLSS && + accessToReactiveMask && currentBackend != Upscaler::DLSS && currentBackend != Upscaler::DLSS_on12 && (currentBackend != Upscaler::XeSS || currentFeature->Version() >= feature_version { 2, 0, 1 }); bool disableReactiveMask = config->DisableReactiveMask.value_or(!canUseReactiveMask); @@ -6022,7 +6028,8 @@ void MenuCommon::RenderActiveImageSettings(RenderMenuContext& ctx) ImGui::EndTable(); } - if (currentFeature->AccessToReactiveMask() && currentBackend != Upscaler::DLSS) + if (currentFeature->AccessToReactiveMask() && currentBackend != Upscaler::DLSS && + currentBackend != Upscaler::DLSS_on12) { ImGui::BeginDisabled(config->DisableReactiveMask.value_or(currentBackend == Upscaler::XeSS)); @@ -6203,7 +6210,8 @@ void MenuCommon::RenderAdvancedSettings(RenderMenuContext& ctx) } // Non-DLSS hotfixes ----------------------------- - if (currentFeature != nullptr && !currentFeature->IsFrozen() && currentBackend != Upscaler::DLSS) + if (currentFeature != nullptr && !currentFeature->IsFrozen() && currentBackend != Upscaler::DLSS && + currentBackend != Upscaler::DLSS_on12) { // SPOOFING/HOOKING ----------------------------- ImGui::Spacing(); diff --git a/OptiScaler/upscalers/FeatureProvider_Dx11.cpp b/OptiScaler/upscalers/FeatureProvider_Dx11.cpp index 67fd7919..009b1778 100644 --- a/OptiScaler/upscalers/FeatureProvider_Dx11.cpp +++ b/OptiScaler/upscalers/FeatureProvider_Dx11.cpp @@ -7,6 +7,7 @@ #include "NVNGX_Parameter.h" #include "upscalers/dlss/DLSSFeature_Dx11.h" +#include "upscalers/dlss/DLSSFeature_Dx11On12.h" #include "upscalers/dlssd/DLSSDFeature_Dx11.h" #include "upscalers/fsr2/FSR2Feature_Dx11.h" #include "upscalers/fsr2/FSR2Feature_Dx11On12.h" @@ -68,6 +69,19 @@ bool FeatureProvider_Dx11::GetFeature(Upscaler upscaler, UINT handleId, NVSDK_NG break; } + case Upscaler::DLSS_on12: + if (primaryGpu.dlssCapable && state.NVNGX_DLSS_Path.has_value()) + { + *feature = std::make_unique(handleId, parameters); + break; + } + else + { + *feature = std::make_unique(handleId, parameters); + upscaler = Upscaler::FSR22; + break; + } + case Upscaler::DLSSD: if (primaryGpu.dlssCapable && state.NVNGX_DLSSD_Path.has_value()) { @@ -114,7 +128,8 @@ bool FeatureProvider_Dx11::ChangeFeature(Upscaler upscaler, ID3D11Device* device State& state = State::Instance(); Config& cfg = *Config::Instance(); - const bool dlssOnNonCapable = !IdentifyGpu::getPrimaryGpu().dlssCapable && state.newBackend == Upscaler::DLSS; + const bool dlssOnNonCapable = !IdentifyGpu::getPrimaryGpu().dlssCapable && + (state.newBackend == Upscaler::DLSS || state.newBackend == Upscaler::DLSS_on12); if (state.newBackend == Upscaler::Reset || dlssOnNonCapable) state.newBackend = cfg.Dx11Upscaler.value_or_default(); @@ -135,7 +150,8 @@ bool FeatureProvider_Dx11::ChangeFeature(Upscaler upscaler, ID3D11Device* device auto* dc = contextData->feature.get(); // Use given params if using DLSS passthrough - const bool isPassthrough = state.newBackend == Upscaler::DLSSD || state.newBackend == Upscaler::DLSS; + const bool isPassthrough = state.newBackend == Upscaler::DLSSD || state.newBackend == Upscaler::DLSS || + state.newBackend == Upscaler::DLSS_on12; contextData->createParams = isPassthrough ? parameters : GetNGXParameters(API::DX11, false); contextData->createParams->Set(NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags, dc->GetFeatureFlags()); diff --git a/OptiScaler/upscalers/FeatureProvider_Vk.cpp b/OptiScaler/upscalers/FeatureProvider_Vk.cpp index 582cfdc6..197641ac 100644 --- a/OptiScaler/upscalers/FeatureProvider_Vk.cpp +++ b/OptiScaler/upscalers/FeatureProvider_Vk.cpp @@ -8,6 +8,7 @@ #include "upscalers/fsr2/FSR2Feature_Vk.h" #include "upscalers/dlss/DLSSFeature_Vk.h" +#include "upscalers/dlss/DLSSFeature_VkOnDx12.h" #include "upscalers/dlssd/DLSSDFeature_Vk.h" #include "upscalers/fsr2_212/FSR2Feature_Vk_212.h" #include "upscalers/fsr2_212/FSR2Feature_VkOnDx12_212.h" @@ -62,6 +63,19 @@ bool FeatureProvider_Vk::GetFeature(Upscaler upscaler, UINT handleId, NVSDK_NGX_ break; } + case Upscaler::DLSS_on12: + if (primaryGpu.dlssCapable && state.NVNGX_DLSS_Path.has_value()) + { + *feature = std::make_unique(handleId, parameters); + break; + } + else + { + *feature = std::make_unique(handleId, parameters); + upscaler = Upscaler::FSR22; + break; + } + case Upscaler::DLSSD: if (primaryGpu.dlssCapable && state.NVNGX_DLSSD_Path.has_value()) { @@ -109,7 +123,8 @@ bool FeatureProvider_Vk::ChangeFeature(Upscaler upscaler, VkInstance instance, V State& state = State::Instance(); Config& cfg = *Config::Instance(); - const bool dlssOnNonCapable = !IdentifyGpu::getPrimaryGpu().dlssCapable && state.newBackend == Upscaler::DLSS; + const bool dlssOnNonCapable = !IdentifyGpu::getPrimaryGpu().dlssCapable && + (state.newBackend == Upscaler::DLSS || state.newBackend == Upscaler::DLSS_on12); if (state.newBackend == Upscaler::Reset || dlssOnNonCapable) state.newBackend = cfg.VulkanUpscaler.value_or_default(); @@ -126,7 +141,8 @@ bool FeatureProvider_Vk::ChangeFeature(Upscaler upscaler, VkInstance instance, V auto* dc = contextData->feature.get(); // Use given params if using DLSS passthrough - const bool isPassthrough = state.newBackend == Upscaler::DLSSD || state.newBackend == Upscaler::DLSS; + const bool isPassthrough = state.newBackend == Upscaler::DLSSD || state.newBackend == Upscaler::DLSS || + state.newBackend == Upscaler::DLSS_on12; contextData->createParams = isPassthrough ? parameters : GetNGXParameters(API::Vulkan, false); contextData->createParams->Set(NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags, dc->GetFeatureFlags()); @@ -204,7 +220,7 @@ bool FeatureProvider_Vk::ChangeFeature(Upscaler upscaler, VkInstance instance, V if (state.newBackend != Upscaler::DLSSD) { - if (cfg.VulkanUpscaler == Upscaler::DLSS) + if (cfg.VulkanUpscaler == Upscaler::DLSS || cfg.VulkanUpscaler == Upscaler::DLSS_on12) { state.newBackend = Upscaler::XeSS; ImGui::InsertNotification({ ImGuiToastType::Warning, 10000, "Falling back to XeSS" }); diff --git a/OptiScaler/upscalers/dlss/DLSSFeature_Dx11On12.cpp b/OptiScaler/upscalers/dlss/DLSSFeature_Dx11On12.cpp new file mode 100644 index 00000000..bb53c7ea --- /dev/null +++ b/OptiScaler/upscalers/dlss/DLSSFeature_Dx11On12.cpp @@ -0,0 +1,11 @@ +#include + +#include "DLSSFeature_Dx11On12.h" +#include + +DLSSFeatureDx11On12::DLSSFeatureDx11On12(unsigned int InHandleId, NVSDK_NGX_Parameter* InParameters) + : IFeature_Dx11wDx12(InHandleId, InParameters), IFeature_Dx11(InHandleId, InParameters), + IFeature(InHandleId, InParameters) +{ + dx12Feature = std::make_unique(InHandleId, InParameters); +} diff --git a/OptiScaler/upscalers/dlss/DLSSFeature_Dx11On12.h b/OptiScaler/upscalers/dlss/DLSSFeature_Dx11On12.h new file mode 100644 index 00000000..d698fa47 --- /dev/null +++ b/OptiScaler/upscalers/dlss/DLSSFeature_Dx11On12.h @@ -0,0 +1,10 @@ +#pragma once +#include + +class DLSSFeatureDx11On12 : public IFeature_Dx11wDx12 +{ + public: + Upscaler GetUpscalerType() const final { return Upscaler::DLSS_on12; } + + DLSSFeatureDx11On12(unsigned int InHandleId, NVSDK_NGX_Parameter* InParameters); +}; diff --git a/OptiScaler/upscalers/dlss/DLSSFeature_VkOnDx12.cpp b/OptiScaler/upscalers/dlss/DLSSFeature_VkOnDx12.cpp new file mode 100644 index 00000000..a3993553 --- /dev/null +++ b/OptiScaler/upscalers/dlss/DLSSFeature_VkOnDx12.cpp @@ -0,0 +1,11 @@ +#include + +#include "DLSSFeature_VkOnDx12.h" +#include + +DLSSFeatureVkOnDx12::DLSSFeatureVkOnDx12(unsigned int InHandleId, NVSDK_NGX_Parameter* InParameters) + : IFeature_VkwDx12(InHandleId, InParameters), IFeature_Vk(InHandleId, InParameters), + IFeature(InHandleId, InParameters) +{ + dx12Feature = std::make_unique(InHandleId, InParameters); +} diff --git a/OptiScaler/upscalers/dlss/DLSSFeature_VkOnDx12.h b/OptiScaler/upscalers/dlss/DLSSFeature_VkOnDx12.h new file mode 100644 index 00000000..09e08a81 --- /dev/null +++ b/OptiScaler/upscalers/dlss/DLSSFeature_VkOnDx12.h @@ -0,0 +1,10 @@ +#pragma once +#include + +class DLSSFeatureVkOnDx12 : public IFeature_VkwDx12 +{ + public: + Upscaler GetUpscalerType() const final { return Upscaler::DLSS_on12; } + + DLSSFeatureVkOnDx12(unsigned int InHandleId, NVSDK_NGX_Parameter* InParameters); +};