fix(vk): preserve 10-bit frame generation in Native HDR #2414
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2414
Loading…
Reference in a new issue
No description provided.
Delete branch "midas48/Longshot:fix/native-hdr-frame-generation"
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?
Summary
With Native HDR and frame generation at 2×, compare a smooth sky gradient with frame generation enabled and disabled. The shared interpolation path used RGBA8 for the game frames and generated frames. This rounded the 10-bit PQ codes before they reached the HDR10 swapchain and could produce visible bands.
Allocate RGB10A2 for Native HDR frames and RGBA8 for SDR frames. DLSS FG receives the actual image format and HDR flag. FSR 3.1 FG and the built-in interpolator use the same format for their colour output. For FSR, the HDR HUD mask uses the packed alpha channel for its binary mask. Queued frames carry their format into presentation. When the GPU cannot use the HDR storage shaders, Longshot presents the original HDR frames.
Start with
framegen_recordandensure_sizeingpu/vk/vk_framegen.cpp,dlss_fg_framesingpu/vk/vk_dlss.cpp, andtests/test_framegen_hdr.py. Related work includes the 10-bit window scaling pass in #307 and the Native HDR FSR HUD handling in #2169.Testing
Tested: Windows 11, RTX 4080 SUPER, NVIDIA 621.24, 4K Native HDR with DLSS FG 2× in Hyrule Field.
mainat90fae88, with head4c3ef6b. The intervening upstream commits changed the job queue, release workflow, and their tests and docs. The latest branch commit updates test fixtures. The game and renderer sources are identical to9ffcf96, the head used for the runtime measurements below.9b44ce1onmainat209389ffails because Native HDR allocates RGBA8 and adjacent PQ codes collapse. It passes at9ffcf96, including a same-size SDR -> HDR -> SDR transition and presentation fallback when HDR storage is unavailable. Temporarily forcing the HDR allocation back to RGBA8 also fails the regression.9ffcf96builds with llvm-mingw and the NVIDIA NGX SDK. All 25 focused strict checks pass. Ruff 0.12.0 andgit diff --checkpass. glslang 16.6.0 regenerated the embedded modules. The three SDR SPIR-V modules have identical words before and after the change.209389fand the renderer pack at9ffcf96on Windows 11, RTX 4080 SUPER, NVIDIA 621.24. Both used the same game executable, DLSS runtime, Hyrule Field save and 3840×2160 Native HDR settings. The baseline passes RGBA8 to NGX invk_dlss.cpp. The patched log reports RGB10A2 (format 64) for both the frame-generation buffers and the NGX feature. The HDR10 PQ swapchain remained format 64 in both runs. NGX reported generated frames and zero refusals in the logged sample on each side. The reference run with FG off kept the PQ swapchain and presented no generated frames.tests/run_all.py --strict --jobs 1suite (themise run testcommand) on Ubuntu 24.04 on WSL atff78040. The run found five fixtures that still used the old frame-generation or presentation signatures.4c3ef6bupdates those fixtures. All five passed on rerun, along with the HDR, FSR HUD and UTF-8 regressions. Across the full run and the fixture rerun, 943 checks passed, 19 failures also reproduced on cleanmainat90fae88, and 18 declared platform or hardware skips remained. The only changes after the full run are the fixture updates.90fae88:test_amd_subgroup_profiles,test_appimage_package_retry,test_crt_options,test_dev_packs,test_flat_map,test_guest_holes,test_linux_saves_move,test_menu_save_atomic,test_menu_text_field,test_nonuniform_image_arrays,test_pipeline_share,test_rdna2_mesh_only,test_readback_timeout_source,test_rumble_menu,test_shader_profile_caps,test_target_image_reuse,test_vibration_menu,test_vram_compact, andtest_wb_spans.test_present_aspect_vulkan.pypassed all seven authored offscreen cases on the RTX 4080 SUPER. The workflow fixture checks passed too. Ruff 0.12.0 andgit diff --checkpass on the final source diff.4c3ef6bwith Clang in a UTF-8 work path, and checked its symbols. Windows llvm-mingw built the same renderer source at9ffcf96. The native UTF-8 path fixtures passed on Linux and Windows.Still to test:
Measurements
Verdict: Native HDR keeps the intermediate 10-bit PQ values through frame generation. The 8-bit grid share in the sky crop fell from 95.4% to 23.6%.
Setup: Windows 11, RTX 4080 SUPER, NVIDIA 621.24. Hyrule Field, 3840×2160, Native HDR, DLSS FG 2×. The runtime A/B used the same game executable and DLSS runtime. The tested renderer sources match the rebased head.
Baseline: The measured revisions below still cover the change. The rebase and fixture updates leave the base and patched game and renderer sources unchanged from the tested revisions.
209389f9ffcf96The fixture uses the renderer's image allocation code. Both formats use four bytes per pixel.
For the in-game stills, decode the original half-float scRGB files. Convert to Rec. 2020 and ST 2084, then round to 10-bit PQ codes. For the 760×220 sky region from x=1440 and y=80, count samples on the 256 codes obtained by expanding 8-bit to 10-bit. The before and after samples come from different frames of the same scene. This comparison measures the quantization grid in the captures.
Risks
A format transition drains queued sets and recreates interpolation history. Native HDR requires the device to support RGB10A2 storage images. Frame generation can be turned off using the existing option. The change requires no save, settings or cache migration.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.mainand here, for a change that shows on screen.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Tested in game: Windows 11, RTX 4080 SUPER (NVIDIA 621.24), 3840x2160, Native HDR and DLSS FG 2x in Hyrule Field. The patched renderer passed RGB10A2 (format 64) to NGX and generated frames on an HDR10 PQ swapchain. The share of samples on the 8-bit grid in a sky crop fell from 95.4% to 23.6%. In-game run at 9ffcf96; the game and renderer sources are identical at the rebased head
ff78040.Possibly related, for context:
Full strict Ubuntu 24.04 run plus the fixture rerun at
4c3ef6b: 943 passed, 19 reproduced with the same diagnostics on main at90fae88, and 18 declared skips. The follow-up fixes five stale frame-generation/presentation fixtures. The Linux renderer built and linked from a UTF-8 work path; all seven Windows offscreen Vulkan cases passed. The measured builds still apply because the game and renderer sources match the tested versions.WIP: fix(vk): preserve 10-bit frame generation in Native HDRto fix(vk): preserve 10-bit frame generation in Native HDRThank you, FG made sky really ugly (banding and color imprecision) when running HDR on my AW3225QF 12bit OLED.
Though there still is a bit of banding, and it is fixed by !2424
This one fixes the banding in general (for PsychoV35), while yours fixes FG banding.
You need both to truly fix the banding with FG
Another PR could be made to fix banding in other modes than PsychoV35, but it's a bit more touchy, and imho the other HDR modes are way worse than native+PsychoV35, so not worth it. (Especially HDR Extended, which is crappy SDR->HDR ITM)
If you want to try to fix HDR native+vanilla, you may want to look at PR !2424 as it talks why it needs to be handled a bit differently.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.