Skip to content

Commit 19c6f4e

Browse files
authored
chore(upscaling): add back upscale multiplier (#1532)
1 parent 8047cd3 commit 19c6f4e

File tree

5 files changed

+42
-23
lines changed

5 files changed

+42
-23
lines changed

src/Features/Upscaling.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,10 @@ void Upscaling::DrawSettings()
204204
}
205205

206206
if (baseLabel) {
207-
ImGui::SliderInt("Upscale Preset", (int*)&settings.qualityMode, 0, 4, baseLabel);
207+
// Format the label with preset name and resolution scale
208+
std::string labelWithScale = std::format("{} ( {:.2f}x )", baseLabel, (resolutionScale.x + resolutionScale.y) * 0.5f);
209+
210+
ImGui::SliderInt("Upscale Preset", (int*)&settings.qualityMode, 0, 4, labelWithScale.c_str());
208211
}
209212

210213
if (upscaleMethod == UpscaleMethod::kFSR) {
@@ -704,21 +707,28 @@ void Upscaling::ConfigureUpscaling(RE::BSGraphics::State* a_viewport)
704707
auto screenHeight = static_cast<int>(screenSize.y);
705708

706709
if (upscaleMethod != UpscaleMethod::kNONE && upscaleMethod != UpscaleMethod::kTAA) {
707-
float resolutionScaleBase = 1.0f;
710+
float2 resolutionScaleBase = { 1.0f, 1.0f };
708711

709712
if (globals::game::isVR) {
710-
resolutionScaleBase = 1.0f;
713+
resolutionScaleBase = { 1.0f, 1.0f };
711714
} else if (upscaleMethod == UpscaleMethod::kDLSS) {
712715
resolutionScaleBase = streamline.GetInputResolutionScale((uint32_t)screenSize.x, (uint32_t)screenSize.y, settings.qualityMode);
713716
} else if (upscaleMethod == UpscaleMethod::kFSR) {
714717
resolutionScaleBase = fidelityFX.GetInputResolutionScale((uint32_t)screenSize.x, (uint32_t)screenSize.y, settings.qualityMode);
715718
}
716719

717-
auto renderWidth = static_cast<int>(screenWidth * resolutionScaleBase);
718-
auto renderHeight = static_cast<int>(screenHeight * resolutionScaleBase);
720+
auto renderWidth = static_cast<int>(screenWidth * resolutionScaleBase.x);
721+
auto renderHeight = static_cast<int>(screenHeight * resolutionScaleBase.y);
719722

720-
resolutionScale.x = static_cast<float>(renderWidth) / static_cast<float>(screenWidth);
721-
resolutionScale.y = static_cast<float>(renderHeight) / static_cast<float>(screenHeight);
723+
// Use precise scale if the integer conversion doesn't change the dimensions
724+
if (renderWidth == screenWidth && renderHeight == screenHeight) {
725+
// For DLAA and other 1:1 modes, ensure exactly 1.0
726+
resolutionScale.x = 1.0f;
727+
resolutionScale.y = 1.0f;
728+
} else {
729+
resolutionScale.x = static_cast<float>(renderWidth) / static_cast<float>(screenWidth);
730+
resolutionScale.y = static_cast<float>(renderHeight) / static_cast<float>(screenHeight);
731+
}
722732

723733
auto phaseCount = GetJitterPhaseCount(renderWidth, screenWidth);
724734

src/Features/Upscaling/FidelityFX.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,10 @@ void FidelityFX::DestroyFSRResources()
240240
}
241241
}
242242

243-
float FidelityFX::GetInputResolutionScale([[maybe_unused]] uint32_t outputWidth, [[maybe_unused]] uint32_t outputHeight, uint32_t qualityMode)
243+
float2 FidelityFX::GetInputResolutionScale([[maybe_unused]] uint32_t outputWidth, [[maybe_unused]] uint32_t outputHeight, uint32_t qualityMode)
244244
{
245-
return 1.0f / ffxFsr3GetUpscaleRatioFromQualityMode((FfxFsr3QualityMode)qualityMode);
245+
float scale = 1.0f / ffxFsr3GetUpscaleRatioFromQualityMode((FfxFsr3QualityMode)qualityMode);
246+
return { scale, scale };
246247
}
247248

248249
FfxResource ffxGetResource(ID3D11Resource* dx11Resource,

src/Features/Upscaling/FidelityFX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class FidelityFX
4444

4545
void DestroyFSRResources();
4646

47-
float GetInputResolutionScale(uint32_t outputWidth, uint32_t outputHeight, uint32_t qualityMode);
47+
float2 GetInputResolutionScale(uint32_t outputWidth, uint32_t outputHeight, uint32_t qualityMode);
4848

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

src/Features/Upscaling/Streamline.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,8 @@ void Streamline::CheckFrameConstants()
270270
}
271271
}
272272

273-
void Streamline::Upscale(ID3D11Resource* a_upscalingTexture, ID3D11Resource* a_reactiveMask, ID3D11Resource* a_transparencyCompositionMask, ID3D11Resource* a_motionVectors)
273+
void Streamline::SetDLSSOptions()
274274
{
275-
CheckFrameConstants();
276-
277-
auto state = globals::state;
278-
279-
auto renderer = globals::game::renderer;
280-
auto& depthTexture = renderer->GetDepthStencilData().depthStencils[RE::RENDER_TARGETS_DEPTHSTENCIL::kMAIN];
281-
282275
sl::DLSSOptions dlssOptions{};
283276

284277
// Map quality mode to DLSS mode
@@ -301,6 +294,8 @@ void Streamline::Upscale(ID3D11Resource* a_upscalingTexture, ID3D11Resource* a_r
301294
break;
302295
}
303296

297+
auto state = globals::state;
298+
304299
dlssOptions.outputWidth = (uint)state->screenSize.x;
305300
dlssOptions.outputHeight = (uint)state->screenSize.y;
306301
dlssOptions.colorBuffersHDR = sl::Boolean::eTrue;
@@ -318,6 +313,17 @@ void Streamline::Upscale(ID3D11Resource* a_upscalingTexture, ID3D11Resource* a_r
318313
if (SL_FAILED(result, slDLSSSetOptions(viewport, dlssOptions))) {
319314
logger::critical("[Streamline] Could not enable DLSS");
320315
}
316+
}
317+
318+
void Streamline::Upscale(ID3D11Resource* a_upscalingTexture, ID3D11Resource* a_reactiveMask, ID3D11Resource* a_transparencyCompositionMask, ID3D11Resource* a_motionVectors)
319+
{
320+
CheckFrameConstants();
321+
SetDLSSOptions();
322+
323+
auto state = globals::state;
324+
325+
auto renderer = globals::game::renderer;
326+
auto& depthTexture = renderer->GetDepthStencilData().depthStencils[RE::RENDER_TARGETS_DEPTHSTENCIL::kMAIN];
321327

322328
{
323329
auto screenSize = state->screenSize;
@@ -352,7 +358,7 @@ void Streamline::Upscale(ID3D11Resource* a_upscalingTexture, ID3D11Resource* a_r
352358
slEvaluateFeature(sl::kFeatureDLSS, *frameToken, inputs, _countof(inputs), globals::d3d::context);
353359
}
354360

355-
float Streamline::GetInputResolutionScale(uint32_t outputWidth, uint32_t outputHeight, uint32_t qualityMode)
361+
float2 Streamline::GetInputResolutionScale(uint32_t outputWidth, uint32_t outputHeight, uint32_t qualityMode)
356362
{
357363
sl::DLSSMode dlssMode;
358364
switch (qualityMode) {
@@ -382,7 +388,7 @@ float Streamline::GetInputResolutionScale(uint32_t outputWidth, uint32_t outputH
382388
sl::Result result = slDLSSGetOptimalSettings(dlssOptions, optimalSettings);
383389
if (result != sl::Result::eOk) {
384390
logger::critical("[Streamline] Failed to get DLSS optimal settings, error code: {}", (int)result);
385-
return 1.0f;
391+
return { 1.0f, 1.0f };
386392
}
387393

388394
float scaleX;
@@ -398,8 +404,8 @@ float Streamline::GetInputResolutionScale(uint32_t outputWidth, uint32_t outputH
398404
scaleY = (float)optimalSettings.optimalRenderHeight / (float)outputHeight;
399405
}
400406

401-
// Use the average scale (both should be the same for uniform scaling)
402-
return (scaleX + scaleY) * 0.5f;
407+
// Return separate X and Y scales for more precision
408+
return { scaleX, scaleY };
403409
}
404410

405411
/**

src/Features/Upscaling/Streamline.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ class Streamline
8080

8181
void CheckFrameConstants();
8282

83+
void SetDLSSOptions();
84+
8385
void Upscale(ID3D11Resource* a_upscalingTexture, ID3D11Resource* a_reactiveMask, ID3D11Resource* a_transparencyCompositionMask, ID3D11Resource* a_motionVectors);
8486

85-
float GetInputResolutionScale(uint32_t outputWidth, uint32_t outputHeight, uint32_t qualityPreset);
87+
float2 GetInputResolutionScale(uint32_t outputWidth, uint32_t outputHeight, uint32_t qualityPreset);
8688

8789
void DestroyDLSSResources();
8890

0 commit comments

Comments
 (0)