perf(vk): default DLSS to CNN preset E on < 7 GB GPUs #1096
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!1096
Loading…
Reference in a new issue
No description provided.
Delete branch "flix331/Longshot:perf/vk-dlss-cnn-6gb-default"
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: perf · Risk: low · Tested on: Windows 11, NVIDIA GeForce RTX 3050 Laptop (6 GB VRAM) · Needs: none
Why
Split out from
#637per review feedback (REQUEST_CHANGES). On< 7 GBNVIDIA GPUs (such as 6 GB RTX 3050 Laptop cards), DLSS defaults to Transformer Preset K (11), which consumes85 MBof internal NGX workspace (143 MBtotal with58 MBimages) and higher Tensor Core GPU time per frame than CNN Preset E (5), while texture caches sit tightly against the driver's5,233 MBallowance. Following the sensible-defaults principle, cards with< 7 GBphysical VRAM should default theMODEL_Kslot to CNN Preset E automatically instead of adding extra menu rows or performance claims.See #637.
What changed
Automatically selects DLSS CNN Preset E (
5) on GPUs with< 7 GBphysical VRAM whenopts.dlss_modelis at its defaultMODEL_K(0) andRX_VK_DLSS_PRESETis unset, leaving>= 7 GBcards, explicitM/L/NVIDIA defaultchoices, andRX_VK_DLSS_PRESEToverrides untouched.wanted_preset()ingpu/vk/vk_dlss.cppincludesvk_internal.hand returns5(NVSDK_NGX_DLSS_Hint_Render_Preset_E) whendevice_vram_bytes()is non-zero and< 7ull << 30,opts.dlss_model == upscaler_rows::MODEL_K, andRX_VK_DLSS_PRESETis unset.5f3b51fb): the rule is one function ingpu/vk/upscaler_rows.h,cnn_for_vram(model, vram)(passed throughmodel_preset/dlss_preset, preset E namedkPresetEand checked against the SDK's invk_dlss.cpp'sstatic_assert), used bywanted_preset()and by the menu: on such a card the DLSS model row reads CNN (E), its help says it was chosen for the card's memory (translated in all 13 menu languages), and the bug report lists the DLSS model's default as depending on this PC.wanted_preset()readsRX_VK_DLSS_PRESETthroughpreset_env, so a value that names no preset leaves E, as the row already did. Game-free checks:tests/test_upscaler_rows.cpp/.py(the rule by behaviour, and that DLSS, the row and the report use it) andtests/test_bug_report_defaults.py'smodel-small-card; the README's DLSS model row and paragraph; adevice_vram_bytesstand-in inscripts/screenshots/menu.cpp.Measurements
Verdict: On the same
main(02903b04) build withnvngx_dlss.dllv310.9.16, NGX honored PresetsK,E, andFwithout mapping them back to Transformer. PresetFwas slowest (33.00 msGPU time). In matched fixed-camera Market runs at identical draws (~1,763–1,771), PresetEsaved1.55 msGPU time (-9.8%,14.20vs15.75 ms), improved average FPS by+3.03 fps(+7.2%,44.97vs41.94 fps), reduced steady-state longest submission from4.9–5.4 msto3.6–3.8 ms(-26%), and saved27 MBof internal NGX VRAM (its own:58 MBvs85 MB) with indistinguishable visual quality (01-dlss-k-vs-e.png).Hardware: Windows 11 (Optimus), NVIDIA GeForce RTX 3050 Laptop (6,001 MB physical VRAM, 5,233 MB driver allowance, driver 610.62), 16 GB RAM, 12 threads
Scene: Market (
Market_Child, daytime),1920x1080output,DLSS Performance (50%)(960x540 -> 1920x1080),sharpness=80Method: Same
main(02903b04) build withRX_VK_DLSS=1,RX_VK_DLSS_LOG=1,RX_VK_DLSS_PRESET=K/E/F; parsedlongshot_log.txtper-120-present samples (draws >= 500) and 600-framevk: status:summaries, both during a Market walkthrough (KvsEvsF) and in a stationary fixed-camera Market spot (KvsE).How to reproduce: Launch with
RX_VK_DLSS=1 RX_VK_DLSS_LOG=1andRX_VK_DLSS_PRESET=K,E, orFinMarket_Child.02903b0493f695f21,7711,76341.94 fps44.97 fps(+3.03 fps,+7.2%)15.75 ms(steady15.3 ms)14.20 ms(steady14.1 ms,-1.55 ms)4.9–5.4 ms(8.27 msavg)3.6–3.8 ms(6.11 msavg)its images+its own)58 + 85 = 143 MB58 + 58 = 116 MB(-27 MB)K/E/Fon02903b04)K: 30.46 ms/18.32 fpsE: 29.21 ms/19.29 fps(F: 33.00 ms/17.78 fps)Flags and settings
None — no new flags, menu rows, or ini keys were added. Existing
RX_VK_DLSS_PRESETand explicitDLSS modelchoices (M,L,NVIDIA default) remain unchanged.Testing
Tested:
python -I -B tests/test_upscaler_rows.py --cxx g++(upscaler rows: all checks passed),python -I -B tests/test_dlss_checks.py --cxx g++(dlss checks: ok), andpython -I -B tests/run_all.py(578 passed, 45 failed, 42 skippedin Windows sandbox — all DLSS/upscaler/NGX checks passed; the 45 failures are unrelated Windows/sandbox environment checks such astest_linux_preflight.py,test_run_all_changed.py,test_job_queue.py, andnx2/test_*.py).KvsEvsFwalkthrough and stationary fixed-cameraKvsEA/B onmain @ 02903b04withnvngx_dlss.dll v310.9.16.Not tested:
5f3b51fb: read, not built or run before they were pushed (the forge's checks run the game-free ones); "CNN (E)" in the menu on a 6 GB card not seen in the game.static_assertthen fails the build).>= 8 GBNVIDIA GPUs (by inspection,device_vram_bytes() < (7ull << 30)evaluates false sowanted_preset()returns the unchangedPreset K).LONGSHOT_NGX_SDK.Must be tested:
>= 8 GBWindows/Linux DLSS build sanity check if desired).Risks
What could break: Nothing expected on
>= 7 GBGPUs (code path is bypassed). On< 7 GBGPUs,DLSS modelrow at default0(Transformer (K)) uses CNN Preset E internally; users who explicitly want Transformer K on< 7 GBcan still setRX_VK_DLSS_PRESET=K.Turning it off: Set
RX_VK_DLSS_PRESET=K, pick another option inDLSS model, or revert the single commit ingpu/vk/vk_dlss.cpp.Compatibility: Nothing changes for saves,
longshot_options.ini, or shader/pipeline caches.Issues
See #637
Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (578 passed, 42 skipped, 45 unrelated Windows-sandbox failures named in Testing; all DLSS/upscaler tests pass).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.Thanks for splitting this out of #637. The measurements are good: preset E really is cheaper on the 6 GB 3050 at Performance (−1.55 ms GPU, −27 MB of NGX memory, same picture). The
wanted_preset()change itself is small and correct for the case it targets. It needs changes before it can merge, though, mainly because the menu and the bug report now name a different network from the one that draws:1. The DLSS model row and the bug report say "Transformer (K)" while E draws (blocking). On a card under 7 GB, value 0 still reads
Transformer (K)intx_dlss_model(vk_menu.cpp), with the hint "NVIDIA's transformer model: the one tested most here.", and the bug report prints the same label (tests/test_bug_report_defaults.pydrivestx_dlss_model). So a player sees K, and a report someone files says K, but the feature is made with E. The row also can't choose K on these cards any more, because value 0 means both "the default" and "K". The description points toRX_VK_DLSS_PRESET=K, but an environment switch isn't something a player can reach. Something like this would fix it:upscaler_rows.h, e.g.model_preset(int model, uint64_t vram)/dlss_preset(model, env, vram), sowanted_preset(),tx_dlss_modelandhn_dlss_modelall use the one function. On < 7 GB, value 0 then reads e.g.CNN (E)with a hint saying why (less video memory and GPU time on this card), and the bug report says E;tests/test_upscaler_rows.py: 6 GB + K row + no env gives 5; 8 GB gives 11; M/L/default unchanged; a valid env wins; an invalid env (see 2) still gives E.How the row should read is your call. It just has to say what draws.
2. An invalid
RX_VK_DLSS_PRESETskips the E default.wanted_preset()checksenv && *envitself, butdlss_presetand the menu (dlss_preset_env) useupscaler_rows::preset_env, which ignores a value that isn't a letter or0(e.g.RX_VK_DLSS_PRESET=1). With such a value the row shows plainTransformer (K)and theKrow's preset is used, but the new branch is skipped, so a 6 GB card gets K and not E. Checkingupscaler_rows::preset_env(env)would keep the two in step, and doing that is easier once the rule lives in upscaler_rows.h (point 1).3. E for every quality mode was measured at Performance only. The preset goes to all six hints (DLAA, Quality, Balanced, Performance, Ultra Performance, Ultra Quality), so a 6 GB card on DLAA or Ultra Performance also gets E now. The numbers only cover Performance (960x540 → 1080p). Either say in the description why E is still right for DLAA/Ultra Performance on these cards (a run of either would do), or limit the rule to the modes measured. This one isn't blocking if you can explain it.
Smaller things (not blocking):
return 5is a bare literal. The feature code already hasstatic_assert(NVSDK_NGX_DLSS_Hint_Render_Preset_K == 11 && ...), so addNVSDK_NGX_DLSS_Hint_Render_Preset_E == 5to it, or name it inupscaler_rows.has a constant like the others.upscaler_rows.hcomment on the row ("0 the transformer, preset K (the default here, the one tested)") are now wrong on < 7 GB cards. Please update both.device_vram_bytes()is called on everyprepare(). It's only a loop over the memory heaps, so it doesn't matter. Thevk_internal.hinclude is fine too: vk_xess.cpp and vk_fsr4.cpp include it as well.pr statuswarns that the measurements were taken on02903b04. The one commit on main since then (#1095, dev_build.py) doesn't touch the renderer, so one line saying the numbers still hold is enough. Add the two "When it applies" boxespr statussuggests, too (a check reading vk_dlss.cpp, and Windows + Linux builds).Overlaps: #637 (same author) still carries the DLSS CNN presets this was split from. Once this lands, drop that part from it so the two don't both change
wanted_preset(). Nothing else open toucheswanted_preset()or the DLSS model row.Reviewed by reading the code only; nothing was built or run.
🤖 Generated with Claude Code
@ -314,2 +315,3 @@/// DLSS's preset: the DLSS model row's, RX_VK_DLSS_PRESET over it (upscaler_rows.h dlss_preset)/// DLSS's preset: the DLSS model row's, RX_VK_DLSS_PRESET over it (upscaler_rows.h dlss_preset)./// On < 7 GB GPUs, the default K slot automatically selects CNN Preset E (-27 MB NGX VRAM, lower GPU time)The file header (lines 13-14, "K by default") and the row's comment in upscaler_rows.h ("preset K (the default here, the one tested)") need the same note about < 7 GB cards.
@ -317,2 +320,3 @@static const char* const env = getenv("RX_VK_DLSS_PRESET");return upscaler_rows::dlss_preset(opts.dlss_model, env && *env ? env : nullptr);const unsigned p = upscaler_rows::dlss_preset(opts.dlss_model, env && *env ? env : nullptr);if ((!env || !*env) && opts.dlss_model == upscaler_rows::MODEL_K) {This checks
env && *env, but the row anddlss_presetuseupscaler_rows::preset_env(env), so an invalid value (e.g.RX_VK_DLSS_PRESET=1) skips E here while the menu shows the plain K row.!upscaler_rows::preset_env(env)keeps them in step. Better still, move this rule intoupscaler_rows.hso the menu label/hint and the bug report can use it too (see the review).@ -319,0 +321,4 @@const unsigned p = upscaler_rows::dlss_preset(opts.dlss_model, env && *env ? env : nullptr);if ((!env || !*env) && opts.dlss_model == upscaler_rows::MODEL_K) {const uint64_t vram = device_vram_bytes();if (vram && vram < (7ull << 30)) return 5; // NVSDK_NGX_DLSS_Hint_Render_Preset_EPlease add
NVSDK_NGX_DLSS_Hint_Render_Preset_E == 5to the existingstatic_assertin the feature code (or name the 5 in upscaler_rows.h), so the literal is checked against the SDK like K/L/M are.WIP:perf(vk): default DLSS to CNN preset E on < 7 GB GPUsto perf(vk): default DLSS to CNN preset E on < 7 GB GPUs5f3b51fb3b97b6f701e4Approved at the request of a maintainer. Rebased onto main
d76feb2d, which brought in #1041. Two conflicts, both resolved without a decision:gpu/vk/menu_i18n.h: each language's text count is main's plus this PR's one new hint. The counts match the entries, and every table is still sorted with no text twice.tests/test_bug_report_defaults.py: the cases list keeps 1041'sframegen-by-no-dlssand this PR'smodel-small-card.The review's points are in
5f3b51fb(now97b6f701):upscaler_rows.hand used by DLSS, the row, its help and the bug report;preset_envdecides the switch;Still open, as the description says: DLAA and Ultra Performance with E on a small card, and the SDK marking preset E deprecated.
🤖 Generated with Claude Code