Skip to content
Merged
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
23 changes: 5 additions & 18 deletions src/Features/Upscaling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,26 +739,13 @@ void Upscaling::ConfigureUpscaling(RE::BSGraphics::State* a_viewport)
auto screenHeight = static_cast<int>(screenSize.y);

if (upscaleMethod != UpscaleMethod::kNONE && upscaleMethod != UpscaleMethod::kTAA) {
float2 resolutionScaleBase = { 1.0f, 1.0f };
float resolutionScaleBase = 1.0f / ffxFsr3GetUpscaleRatioFromQualityMode((FfxFsr3QualityMode)settings.qualityMode);

if (upscaleMethod == UpscaleMethod::kDLSS) {
resolutionScaleBase = streamline.GetInputResolutionScale((uint32_t)screenSize.x, (uint32_t)screenSize.y, settings.qualityMode);
} else if (upscaleMethod == UpscaleMethod::kFSR) {
resolutionScaleBase = fidelityFX.GetInputResolutionScale((uint32_t)screenSize.x, (uint32_t)screenSize.y, settings.qualityMode);
}
auto renderWidth = static_cast<int>(screenWidth * resolutionScaleBase);
auto renderHeight = static_cast<int>(screenHeight * resolutionScaleBase);

auto renderWidth = static_cast<int>(screenWidth * resolutionScaleBase.x);
auto renderHeight = static_cast<int>(screenHeight * resolutionScaleBase.y);

// Use precise scale if the integer conversion doesn't change the dimensions
if (renderWidth == screenWidth && renderHeight == screenHeight) {
// For DLAA and other 1:1 modes, ensure exactly 1.0
resolutionScale.x = 1.0f;
resolutionScale.y = 1.0f;
} else {
resolutionScale.x = static_cast<float>(renderWidth) / static_cast<float>(screenWidth);
resolutionScale.y = static_cast<float>(renderHeight) / static_cast<float>(screenHeight);
}
resolutionScale.x = static_cast<float>(renderWidth) / static_cast<float>(screenWidth);
resolutionScale.y = static_cast<float>(renderHeight) / static_cast<float>(screenHeight);

auto phaseCount = GetJitterPhaseCount(renderWidth, screenWidth);

Expand Down
4 changes: 2 additions & 2 deletions src/Features/Upscaling.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ struct Upscaling : Feature
uint frameGenerationMode = 1;
uint frameGenerationForceEnable = 0;
uint streamlineLogLevel = 0; // 0=Off, 1=Default, 2=Verbose
float sharpnessFSR = 1.0f;
float sharpnessDLSS = 0.5f;
float sharpnessFSR = 0.0f;
float sharpnessDLSS = 0.0f;
Comment thread
alandtse marked this conversation as resolved.
};

Settings settings;
Expand Down
6 changes: 0 additions & 6 deletions src/Features/Upscaling/FidelityFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,6 @@ void FidelityFX::DestroyFSRResources()
fsrDispatchCrashLogged = false;
}

float2 FidelityFX::GetInputResolutionScale([[maybe_unused]] uint32_t outputWidth, [[maybe_unused]] uint32_t outputHeight, uint32_t qualityMode)
{
float scale = 1.0f / ffxFsr3GetUpscaleRatioFromQualityMode((FfxFsr3QualityMode)qualityMode);
return { scale, scale };
}

FfxResource ffxGetResource(ID3D11Resource* dx11Resource,
[[maybe_unused]] wchar_t const* ffxResName,
FfxResourceStates state = FFX_RESOURCE_STATE_PIXEL_COMPUTE_READ)
Expand Down
2 changes: 0 additions & 2 deletions src/Features/Upscaling/FidelityFX.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class FidelityFX

void DestroyFSRResources();

float2 GetInputResolutionScale(uint32_t outputWidth, uint32_t outputHeight, uint32_t qualityMode);

void Upscale(ID3D11Resource* a_upscalingTexture, ID3D11Resource* a_reactiveMask, ID3D11Resource* a_transparencyCompositionMask, ID3D11Resource* a_motionVectors, float a_sharpness);

private:
Expand Down
60 changes: 7 additions & 53 deletions src/Features/Upscaling/Streamline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,13 @@ void Streamline::SetDLSSOptions()
dlssOptions.colorBuffersHDR = sl::Boolean::eTrue;
dlssOptions.useAutoExposure = sl::Boolean::eTrue;

dlssOptions.dlaaPreset = sl::DLSSPreset::ePresetJ;
dlssOptions.ultraQualityPreset = sl::DLSSPreset::ePresetJ;
dlssOptions.qualityPreset = sl::DLSSPreset::ePresetM;
Comment thread
alandtse marked this conversation as resolved.
dlssOptions.balancedPreset = sl::DLSSPreset::ePresetM;
dlssOptions.performancePreset = sl::DLSSPreset::ePresetM;
dlssOptions.ultraPerformancePreset = sl::DLSSPreset::ePresetL;

dlssOptions.preExposure = 1.0f;
dlssOptions.sharpness = 0.0f;
Comment thread
doodlum marked this conversation as resolved.

Expand Down Expand Up @@ -333,59 +340,6 @@ void Streamline::Upscale(ID3D11Resource* a_upscalingTexture, ID3D11Resource* a_r
slEvaluateFeature(sl::kFeatureDLSS, *frameToken, inputs, _countof(inputs), globals::d3d::context);
}

float2 Streamline::GetInputResolutionScale(uint32_t outputWidth, uint32_t outputHeight, uint32_t qualityMode)
{
sl::DLSSMode dlssMode;
switch (qualityMode) {
case 1:
dlssMode = sl::DLSSMode::eMaxQuality;
break;
case 2:
dlssMode = sl::DLSSMode::eBalanced;
break;
case 3:
dlssMode = sl::DLSSMode::eMaxPerformance;
break;
case 4:
dlssMode = sl::DLSSMode::eUltraPerformance;
break;
default:
dlssMode = sl::DLSSMode::eDLAA;
break;
}

sl::DLSSOptions dlssOptions{};
dlssOptions.mode = dlssMode;
dlssOptions.outputWidth = outputWidth;
dlssOptions.outputHeight = outputHeight;

sl::DLSSOptimalSettings optimalSettings{};
sl::Result result = slDLSSGetOptimalSettings(dlssOptions, optimalSettings);
if (result != sl::Result::eOk) {
if (outputWidth > MAX_RESOLUTION || outputHeight > MAX_RESOLUTION) {
logger::critical("[Streamline] Requested resolution {} x {} exceeds the maximum allowed resolution of {} x {}. Lower your resolution to enable Streamline.", outputWidth, outputHeight, MAX_RESOLUTION, MAX_RESOLUTION);
}
logger::critical("[Streamline] Failed to get DLSS optimal settings, error code: {}({})", magic_enum::enum_name(result), (int)result);
return { 1.0f, 1.0f };
}

float scaleX;
float scaleY;

if (globals::game::ui->GameIsPaused()) {
// Calculate scale as ratio of minimum render resolution to output resolution
scaleX = (float)optimalSettings.renderWidthMin / (float)outputWidth;
scaleY = (float)optimalSettings.renderHeightMin / (float)outputHeight;
} else {
// Calculate scale as ratio of optimal render resolution to output resolution
scaleX = (float)optimalSettings.optimalRenderWidth / (float)outputWidth;
scaleY = (float)optimalSettings.optimalRenderHeight / (float)outputHeight;
}

// Return separate X and Y scales for more precision
return { scaleX, scaleY };
}

/**
* @brief Releases DLSS resources and disables DLSS for the current viewport.
*
Expand Down
2 changes: 0 additions & 2 deletions src/Features/Upscaling/Streamline.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,5 @@ class Streamline

void Upscale(ID3D11Resource* a_upscalingTexture, ID3D11Resource* a_reactiveMask, ID3D11Resource* a_transparencyCompositionMask, ID3D11Resource* a_motionVectors);

float2 GetInputResolutionScale(uint32_t outputWidth, uint32_t outputHeight, uint32_t qualityPreset);

void DestroyDLSSResources();
};
4 changes: 1 addition & 3 deletions src/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -832,9 +832,7 @@ void State::UpdateSharedData([[maybe_unused]] bool a_inWorld, [[maybe_unused]] b
auto upscaleMethod = upscaling.GetUpscaleMethod();
if (temporal && upscaleMethod != Upscaling::UpscaleMethod::kTAA) {
auto renderSize = Util::ConvertToDynamic(screenSize, true);
data.MipBias = std::log2f(renderSize.x / screenSize.x);
if (upscaleMethod == Upscaling::UpscaleMethod::kDLSS)
data.MipBias -= 1.0f;
data.MipBias = std::log2f(renderSize.x / screenSize.x) - 1.0f;
} else {
data.MipBias = 0;
}
Expand Down