fix(vk): no sky banding with Native HDR's PsychoV35: the scene's render targets in RGBA16F instead of R11G11B10F #2424
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!2424
Loading…
Reference in a new issue
No description provided.
Delete branch "Heliumrich/Longshot:fix/sky-banding"
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 HDR Native + the PsychoV35 tone mapper, the sky no longer bands: gradients, sunsets and the sun's glow are smooth, with no stripes and no colour fringes between them.
What was wrong. OoT draws its scene's light (the sky, the world, the clouds, the sun and the fog over it), the copies the refraction reads and the bloom chain into R11G11B10F render targets. Red and green keep 6 bits of mantissa and blue 5: each step is 1.6 % / 1.6 % / 3.1 % of the light. In a slow sky gradient that is a few dozen levels across the screen. A raw frame dump of Hyrule Field had 28 levels of blue over the top half of a 1440p sky, in bands about 24 rows tall, before the tone map. Every output showed them, PsychoV35 included: its tone map already writes RGBA16F (after RenoDX's zelda-oot-oz), but the light it maps was R11G11B10F. The three channels also round on their own grids, so a band's edge has blue rounding one way and green the other: the colour shifts at each step too.
What changes. While PsychoV35 is on, the host makes the game's R11G11B10F render targets (2D, one level, compressible: what the game's targets are; never a packaged texture) as RGBX16F (10 bits of mantissa per channel, alpha read as one as before):
host/nvn_native.cmade_desc,host/scene_format.h), so the heap sets the larger targets aside itself. At 2560x1440 the scene goes from 0xf00000 to 0x1e00000 bytes: the size of the RGBA16F target the game itself puts at that address later in the frame.RX_VK_LOG_R11_VIEWS=1(new, diag) showed with DLSS, the game's own upscaler and Off; with PsychoV35 those targets are only ever colour. Those modes are unchanged (see Risks).gpu/vk/vk_texture.hscene_view_format), for its views and its pipelines' targets. The temporal upscalers already take an RGBA16F scene under PsychoV35 (temporal_scene_format); the log now saysPsychoV35 DLSS: RGBA16F linear route; scene format 97(was 122).HOS_SCENE_RGBA16F=0(kill switch) keeps R11G11B10F.With frame generation on, its frames still go through 8-bit storage in Native HDR and the bands come back: that is #2414's fix. This pull request fixes the light before the tone map; #2414 the frames after it.
Both are needed for a smooth sky with frame generation.
Read first:
host/scene_format.h, thenmade_descand its four callers inhost/nvn_native.c.Testing
Tested: Windows 11, NVIDIA GeForce RTX 4080, driver 621.35, Alienware AW3225QF (12-bit panel), 4K output, DLSS Quality preset M (1440p), grass 2x, no frame generation, built from this branch with the Builder v3.1.1 tools.
scene format 97.RX_VK_LOG_R11_VIEWS=1through DLSS, FSR 3.1, the game's own and Off logged no R11G11B10F storage seen through another format, nounexpected scene colour formatand noPsychoV35 waits; the targets show inHOS_NVN_LOG_OBJECTSas format 0x71 at twice their size (960x540: 0x4b0000).main(R11G11B10F, the log'sscene format 122).main(#2414).Image quality (raw RGBA32F frame dumps,
RX_VK_DUMP_RAW, Kakariko Village at the same spot, the top 35 % of the screen: the sky; this branch with PsychoV35 against the R11G11B10F scene of the same build; deviation: each pixel against a 15x15 average, in smooth areas):The two dumps are frames of the same place a few minutes apart (the clouds move): the counts are what each format can hold there, not a pixel-for-pixel difference. A dither on the two sky programs was tried first and dropped: it broke up the bands but left a coloured grain (each channel rounding on its own grid) that looked worse.
Checks:
tests/test_scene_format_rgba16f.py(new: the format rule, both ways and every condition, the sizes againsthost/nvn_layout.c, the wiring innvn_native.c,vk_texture.*,vk_temporal.cpp, the switch),tests/test_shadow_slot.pyandtests/test_pipeline_state_portable.py(updated formade_descandscene_view_format),test_switch_table,test_settings_table,test_doc_anchorspass.run_all.py --changed mainon Linux: every failure there fails onmaintoo (test_dev_packs,test_readback_timeout_source,test_target_image_reuse,test_vram_compact,test_flat_map,test_wb_spans,test_rdna2_mesh_only,test_guest_holes), or needs a tool that machine lacks (clang++, the Vulkan and SPIR-V headers).Still to test:
scene format 97(@Beanstalk)libxess.dllhere) with PsychoV35: the sky smooth, nounexpected scene colour formatin the log (@Beanstalk, or by hand)Measurements
Verdict: within the spread: no cost measured.
Setup: Windows 11, RTX 4080, driver 621.35; 4K output, DLSS Quality preset M (2560x1440 render), HDR Native + PsychoV35, grass 2x, no frame generation, frame rate cap 120 (GPU-bound under it); standing still, the same view each run; the median of the log's
vk: N presents, X fpslines over about 45 s after a 30 s warm-up. on: this branch; off: the same build withHOS_SCENE_RGBA16F=0(main's formats, same caches); main: main at90fae88c, built the same way.90fae88cMemory: the R11G11B10F targets double in size while PsychoV35 is on, about 25 MB of video memory at a 1440p render (the scene 15 to 30 MB; its copies and bloom chain the rest). The game's render target heap holds them.
The change, especially with !2414 is enormous ; the banding goes from significantly visible (both bands and color imprecision) to flawless.
Tested on a 4K HDR OLED 12bit
Risks
HOS_SCENE_RGBA16F=0turns it off; a revert is enough.longshot_options.inior the caches.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (The checks that read the changed files ran on Linux; the failures there also fail onmainor need missing tools. The full run is CI's.)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.mainand here, for a change that shows on screen. (To add: HDR screenshots don't survive a PNG; the dump numbers above stand in.)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
https://claude.ai/code/session_01VurVAi1MmNDvxaQzPTRZbq
@review
Recommendation: Request changes. The higher-precision scene removes the reported banding on the tested NVIDIA system, but the default needs validation on the other affected systems.
PsychoV35 scene targets use higher precision, producing smoother sky gradients. The cost is larger render targets and additional bandwidth; the reported 1440p render uses about 25 MB more video memory.
Blocking (1): must change before merging.
PR description / Description follows the template (pull_request_target)fails on this head and passes on the base branch: Failing after 18s.Should fix (1): not blocking, but worth doing before merging.
tests/test_scene_format_rgba16f.py:120: The test treats the entire compiler setting as one executable name, although the test runner accepts CC settings containing compiler arguments. (more on the line) Do: Parse the compiler command into arguments as the runner does and prepend those arguments to the compilation command.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
host/scene_format.h:37: The new default doubles scene-target storage and bandwidth on all supported Vulkan systems, but its compatibility and cost are only reported on an RTX 4080. (more on the line) Do: Run the same scene with the switch on and off on Steam Deck and representative Windows and Linux AMD systems, recording FPS, frame-time lows and VRAM, and verify the sky and upscaler output.gpu/vk/vk_texture.h:195: The wider scene path has not been exercised with FSR 4 or XeSS, or on Intel and Linux NVIDIA as applicable. (more on the line) Do: Run PsychoV35 with FSR 4 and XeSS on supported hardware, and verify the sky and absence of format errors on the remaining affected systems.@fixcan do L1 and L4.Questions (3) (not confirmed from the code; they don't hold the recommendation)
host/nvn_native.c:654: Can a present that changes the tone mapper occur between the size query and initialization of the same scene texture?host/nvn_native.c:649: Can a guest thread create textures concurrently with the guest thread presenting a frame?host/nvn_native.c:652: Can two guest threads call a texture-builder operation that reaches made_desc concurrently before its first initialization completes?Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the reported visual defect on Windows and an RTX 4080: the author reports no visible banding, and sky blue levels increased from 34 to 1,195 in frame dumps. The reported median FPS was within the run spread, but frame-time lows and the cost on lower-bandwidth hardware are not measured.
Other systems: The format change affects render targets and temporal upscalers across Vulkan devices. Windows NVIDIA was tested with DLSS, FSR 3.1, the game upscaler and Off; Linux, RADV, Intel, FSR 4, XeSS and Steam Deck remain untested. Vanilla, SDR and Expanded were reported unchanged.
Switches: HOS_SCENE_RGBA16F is a kill switch, on by default; its visual benefit is shown on NVIDIA, but its cost and compatibility on other affected systems remain unmeasured. RX_VK_LOG_R11_VIEWS is a diagnostic switch, off by default, which is appropriate.
Reviewed:
09ccbd4253against90fae88c13: Read the repository contribution rules, standards, PR template, complete diff, commit message, new header and test, and the changed tests. Read the changed host and renderer functions and relevant callers and format handling; the large host and renderer files were not read in full. The neighboring Tooling AGENTS.md and docs/review-checklist.md were not present. No recorded runs, translations or generated files were changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no code, tests or project scripts were run. The PR reports successful Windows game runs and source checks; CI still has checks running.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -192,0 +192,4 @@/// (longshot) A view's NVN format over a texture of NVN format tex_nvn: R11G11B10F over one of the game's R11G11B10F targets that/// the host made RGBX16F (host/scene_format.h: the scene's light with PsychoV35) is the texture's own, the format it holds; any/// other as it isinline int scene_view_format(int tex_nvn, int view_nvn) {L3 (should fix): The wider scene path has not been exercised with FSR 4 or XeSS, or on Intel and Linux NVIDIA as applicable.
When: Those upscalers and drivers receive the changed scene format under PsychoV35, but the reported runs cover neither their output nor their handling of that format.
Do: Run PsychoV35 with FSR 4 and XeSS on supported hardware, and verify the sky and absence of format errors on the remaining affected systems.
@ -0,0 +34,4 @@if (!on || format != HOS_SCENE_FORMAT_R11G11B10F || target != HOS_SCENE_FORMAT_TARGET_2D || flags != HOS_SCENE_FORMAT_FLAGS ||samples > 1 || levels != 1 || depth > 1 || packaged)return format;return HOS_SCENE_FORMAT_RGBX16F;L2 (should fix): The new default doubles scene-target storage and bandwidth on all supported Vulkan systems, but its compatibility and cost are only reported on an RTX 4080.
When: A Steam Deck or RADV system using PsychoV35 executes the wider scene and bloom passes; the NVIDIA median FPS results do not establish its frame pacing or available memory on that system.
Do: Run the same scene with the switch on and off on Steam Deck and representative Windows and Linux AMD systems, recording FPS, frame-time lows and VRAM, and verify the sky and upscaler output.
@ -0,0 +117,4 @@exe = Path(tmp) / "t.exe"src.write_text(FIXTURE.replace('"../gpu/render/rx_nvn.h"', '"%s"' % (ROOT / "gpu" / "render" / "rx_nvn.h").as_posix()),encoding="utf-8")subprocess.run([a.cc, "-std=c11", "-Wall", "-Wextra", "-Werror", "-I", str(ROOT / "host"), str(src),L1 (should fix): The test treats the entire compiler setting as one executable name, although the test runner accepts CC settings containing compiler arguments.
When: With CC set to a valid command such as "ccache gcc", run_all recognizes the compiler and passes that string as --cc, but subprocess tries to execute a file literally named "ccache gcc" and the check fails.
Do: Parse the compiler command into arguments as the runner does and prepend those arguments to the compilation command.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.