feat(vk): NVIDIA DLAA before the game's bloom and tone map #1652
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1652
Loading…
Reference in a new issue
No description provided.
Delete branch "pmwork-personal/Longshot:feat/dlss-pre-bloom"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type: feat · Risk: medium · Tested on: Windows 11, RTX 5090 · Needs: Windows, NVIDIA RTX, on screen in motion
TL;DR
With NVIDIA DLAA, DLSS ran after the game's bloom and tone map, on a picture already squeezed into 0–1. This PR runs
DLAA earlier, on the scene's full-range colour before the bloom and the tone map, so the bloom is made from an
anti-aliased scene and bright highlights are not clipped before DLSS sees them. It is on by default with DLAA, and
RX_VK_DLSS_PRE_BLOOM=0gives the old order. In the Market, still pictures are a little sharper; the measured shimmeron static stone edges is mixed: the bright, static temple stone changes about 20% more from frame to frame, while darker, textured areas are up to a third steadier.
Breakdown
scene and every highlight was clipped at white before DLSS saw it.
map and the passes after them then use that picture, and the game's upscale only copies.
frame generation inputs, and everything with
RX_VK_DLSS_PRE_BLOOM=0or the parallel replay (RX_VK_PARALLEL2+).each: stills and 24-frame bursts with the camera still; the log shows every frame drawn before the bloom.
HDR and PsychoV35 with this order.
RX_VK_DLSS_PRE_BLOOM=0turns it off.Why
The game draws its scene in linear light, adds bloom, tone maps, and then runs its own upscale network. Longshot
replaces that network with DLSS, so DLSS got the tone-mapped picture: the bloom had already been built from the
jittered, aliased scene, and the highlights were clipped. Running DLAA before the bloom gives the post passes a stable,
anti-aliased scene and lets DLSS see the full range of the light, as DLSS is meant to be used.
What changed
DLAA now runs at the first pass that reads the scene after the frame's last draw into it, which in a gameplay frame is
the bloom's first pass. That place is known only at the end of a frame (the game copies the scene for refraction and
draws more into it before the bloom), so each frame learns it for the next, by program and by its place among the
passes that read the scene. A frame without that place (the first frame in an area, a menu) runs DLAA at the network
as before and teaches the next frame.
gpu/vk/pre_bloom.h(new): the frame's list of passes and the learning rule, pure and tested.gpu/vk/vk_temporal.cpp:temporal_pre_bloom()(the place, the checks, DLAA on the scene and its picture writtenback); the engine's evaluation moved from
temporal_upscale()intodraw_engine(), used from both places, with aprep_lininput pass (linear, not squared);temporal_upscale()learns the next place and copies the network'sinput where DLAA ran before the bloom (
stretch_record(), split out ofstretch()); the status line counts theframes drawn before the bloom.
gpu/vk/vk_draw.cpp: each draw callstemporal_pre_bloom()after its descriptors and before its pass.gpu/vk/vk_dlss.cpp: the DLSS feature is made for HDR colour (with NGX's auto exposure) when this order is on.gpu/vk/switches.def,docs/development.md:RX_VK_DLSS_PRE_BLOOM.tests/test_dlss_pre_bloom.py/.cpp(new); six checks that read the moved code follow it.Measurements
Verdict: mixed. Stills are slightly sharper, and the darker, textured areas are steadier (bench and wall -33%, stone path -9%, distant haze -8%), but the bright static stone in the sun changes about 20% more from frame to frame, with 2.4 to 3.2 times as many pixels changing by more than 8 of 255. Every frame of the PR runs drew DLAA before the bloom. Not measured yet: on screen, in motion, in scenes with strong bloom.
Hardware: Windows 11 Pro build 26300; NVIDIA GeForce RTX 5090, driver 621.24; AMD Ryzen 7 9800X3D, 64 GB
Scene: Hyrule Market (child), day, the tester's saved spot, camera still; 5120x2160, NVIDIA DLAA, frame generation off,
the tester's own settings otherwise
Method: the game off-screen (
HOS_HEADLESS=1) from the control bridge (scripts/longshot_ctl.py): 3 full-size stills,then 24 consecutive full-size frames (
RX_VK_SHOT_GO), main and this PR in turn, 2 runs each; per region, the meanabsolute frame-to-frame change of luma (0–255) over the 23 steps; the median of the 2 runs
How to reproduce:
scripts/longshot_ctl.py launch <runtime> --env HOS_HEADLESS=1 --env RX_VK_FRAMEGEN=0 --env RX_VK_SHOT_W=5120 --env RX_VK_SHOT_H=2160 --env RX_VK_SHOTS=<dir> --env RX_VK_SHOT_GO=<file> --env RX_VK_SHOT_EVERY=1000000,press Auntil in play at the saved spot, wait 12 s, create the go file until 24 frames are saved; per region, the mean over the pixels of |luma(n+1) - luma(n)|Builds: 4f71ed0c is this PR's change on
c507b98c, the shared base's commit (both built from source, the same base); the PR's head on main differs from it only in a comment and one log line's textWhy the numbers hold on main @
39da4155: main and this change were measured on the same base, so the comparison is like for like; the change is the same after the rebase (git range-diff: equal); and none of main's renderer commits sincec507b98c(quads with 8-bit indices, the depth margin of blended draws, pipeline warming and temporary pipelines, memory pressure) changes the scene's passes, the bloom or the DLSS chain measured herec507b98cFlags and settings
Adds
RX_VK_DLSS_PRE_BLOOM.RX_VK_DLSS_PRE_BLOOM=0after, as before=0for an A/B or if the bright-stone shimmer shows in playRX_VK_PARALLELTesting
Tested: Windows 11, RTX 5090, driver 621.24: the game off-screen at the Market spot, main and this PR in turn, 2 runs
each (stills and 24-frame bursts); the log of every PR run says
600 frames drawn (600 before the bloom)and names thebloom's program;
RX_VK_DLSS_PRE_BLOOM=0gives main's route (checked on the earlier base).tests/test_dlss_pre_bloom.pypasses;
tests/run_all.py --changed: 163 pass, 16 fail, 6 skipped; the same 16 fail on main @39da4155on this PC (among them test_switch_table, test_upscaler_rows, test_dlss_feature_size, test_recorder_sync, test_vk_occlusion_queries);tests/test_tested_configurations.pyfails one Windows line-end case on main too.Not tested: a Linux build (standard C++ in the renderer, no OS calls; the Test Farm builds it); on screen in motion; native HDR output and PsychoV35 (written for their RGBA16F scene, not run); areas
other than the Market (a frame whose passes differ falls back to the old place); DLSS frame generation on screen.
Must be tested:
Navi, with and without
RX_VK_DLSS_PRE_BLOOM=0, expecting no new shimmer, halo or brightness change, and steadierbloom on small bright points.
RX_VK_DLSS_PRE_BLOOM=0, expecting the same brightness and highlights as main (look at the sky, the sun on water and Navi's glow).Risks
What could break: NVIDIA DLAA only: a scene whose passes differ from the Market's could run DLAA at the wrong place
(the learning only takes a pass after the last scene draw, and a late scene draw sends the next frame back to the old
place); DLSS's own auto exposure may make static edges change more from frame to frame.
Turning it off:
RX_VK_DLSS_PRE_BLOOM=0, or revert the commit.Compatibility: Nothing changes: no save, options file, cache or ABI change.
Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why.
in Risks.
main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.docs/tested/for each new measured run (format indocs/tested-configurations.md).mainand passing here.tests/that reads changed source updated in this PR, not weakened.Co-Authored-By: Claude Opus 5.5 [email protected]
🤖 Generated with Claude Code
Tested in game: Windows 11 Pro build 26300, NVIDIA GeForce RTX 5090, driver 621.24: Hyrule Market (child) at the tester's saved spot, 5120x2160 NVIDIA DLAA, the game off-screen (HOS_HEADLESS=1) from the control bridge, main @
c507b98cand this change on it in turn, 2 runs each. In every frame of the branch's runs DLAA ran before the bloom (the log's status: 600 frames drawn, 600 before the bloom; the place learned at the bloom's first pass 95937683d9f74e95, no fallback). Stills are slightly sharper, with no colour, halo or brightness change; with the camera still, the bright static stone changes about 20% more from frame to frame and the darker areas up to 33% less. Not yet run on screen in motion.Possibly related, for context:
Measurements: added why the numbers measured on main
c507b98cstill hold on main39da4155, the PR's base after the rebase (both sides on the same base; the change is identical after the rebase).Pictures from the measured runs, the same spot and frames as Measurements: Before: main @
c507b98c(left) | After: this PR @ 4f71ed0c (right). 5120x2160, NVIDIA DLAA, camera still, crops at 2x.Temple stairs, bright stone in the sun (still):
Temple facade (still):
Bench and wall, darker and textured (still):
Temple stairs, 24 consecutive frames with the camera still (the frame-to-frame change in Measurements):