Best way to handle different plugin that handle swapchain

Hello,

We want to provide an implementation of FSR (FI/FSR4), DLSS (DLSS-G, DLSS-SR, DLAA), XeSS…

However, handling the swapchain issue make it complexe. The solution we have found to offer a possibility to choose the AA/FG before the start was to use a launcher, this launcher setup an argument to the program (-DLSS, -FSR, -XeSS…).

Then with a custom plugin “boostrap”, changing the cvar before initilisation of plugin :

{
  "Name": "ETLBootstrap",
  "Type": "Runtime",
  "LoadingPhase": "PostConfigInit"
}

The idea was to set off all the plugin cvar trough the project.ini, then override them before init of plugins with the boostrap, this way :

void FETLBootstrapModule::SetDLSSMode(bool bOn) {
    FString Args;
    if (bOn) {
        Args = TEXT(" -ngxenable");
        SetCommandValue(TEXT("r.AntiAliasingMethod"), TEXT("4"));
        SetCommandValue(TEXT("r.TemporalAA.Upsampling"), false);
        SetCommandValue(TEXT("r.TemporalAA.Upscaler"), false);
    } else {
        Args = TEXT(" -ngxdisable");
    }

    SetCommandValue(TEXT("r.NGX.Enable"), bOn);
    SetCommandValue(TEXT("r.NGX.DLSS.Enable"), bOn);
    
    FCommandLine::Append(*Args);
    UE_LOGFMT(LogEngine, Log, "ETLBootstrapModule: Appended DLSS args: {0}", *Args);
}

Unfortunately, CVar are not available sometime before plugin initialisation, and if we create it, some plugin like DLSS doesn’t like it and crash.

What is the epic recommandation on this topic ?

Note : it’s maybe out of your support scope, but we noticed than “preset quality” from some plugins doesn’t have any effect, asking here in the same time in case that would be a potential unreal configuration issue.

Thanks

Steps to Reproduce

Hi there,

I’d recommend that you set the CVars in the saved Engine.ini config ini and then request the user to restart the game.

This UDN case answers a similar question regarding FSR settings: [Content removed]

You can write to the saved Engine.ini file using code that follows this pattern:

GConfig->SetInt(SectionKey, Key, Value, GEngineIni);
GConfig->Flush(false, GEngineIni);

E.g.

GConfig->SetInt(TEXT("/Script/Engine.RendererSettings"), TEXT("r.NGX.Enable"), Value, GEngineIni);
GConfig->Flush(false, GEngineIni);

Then request that the user restart the game. The CVars will be automatically loaded at the correct time.

Note that any ini sections (like /Script/Engine.RendererSettings) that you want to be saveable / loadable must be added to the [SectionsToSave] section of your project DefaultEngine.ini like this:

[SectionsToSave]

+Section=/Script/Engine.RendererSettings

If you wanted to still use your launcher, you could set it up to write to the saved Engine.ini file. This file is located at %localappdata%\<ProjectName>\Saved\Config\Windows\Engine.ini on Windows shipping builds (you can create it if it doesn’t exist). Note that the location of this file is going to change per platform / build configuration.

I’ve attached an example project showing how this can be set up for the r.NGX.Enable CVar (note that this example project expects the DLSS plugin to be present in the Engine’s Plugins/Marketplace folder).

Let me know if you have any further questions or issues.

Regards,

Lance Chaney