fix(vk): map local and shared loads across the reserved register boundary #3039
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3039
Loading…
Reference in a new issue
No description provided.
Delete branch "cuecuemoar/Longshot:fix/ldl-reserved-regs"
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
Four of the game's mesh shaders for the depth-only and shadow-depth passes load 128 bits from local memory (
LDL) into R184-R187, while their reserved registers start at R186. The Ampere-to-Maxwell lowering decides whether an instruction reaches the reserved registers from its destination's width, and it counted that width only for the global loads (#2179). It took the local load for one register, so its four 32-bit loads wrote plain R186 and R187 instead of the extended registers 442 and 443. What this did on screen is not known: the issue's author did not see it, and I did not find a scene that draws these four shaders.What this changes: the local and shared loads (
LDL0x983,LDS0x984) count their full width as the global loads do. They keep their size at the same bits (73-75), as the call-link code (writes_link) already reads it. No shader in the game has a shared load that crosses the boundary (the issue counted 38 with 64- or 128-bit shared loads, none crossing). The shared load is included because a synthetic one had the same fault.Read first: the
load_destline ingpu/vk/eden/shader_recompiler/frontend/ampere/lower_to_maxwell.h, thencheck_scalar_load_widthingpu/vk/tests/regmap_marker_test.cpp.Fixes #2243
Testing
Tested: Windows 10, RTX 4090, NVIDIA 617.42, native mesh shaders. Builds of main @
b40214d2band of this fix @99210a71e. The head,adb7b13d4, has the same fix ond0164fae4: main changed nothing in the lowering between the two, and the head's only other change is to the test.3af1ac7c868ebee8,18341da39b21edb5,11a1afbd0c6737e0,4170159071412496). Each gains one register-map run: in3af1ac7c868ebee8, for example, the 128-bitLDL R184writes184 185 186 187on main and184 185 [R186-R187 mapped to 442-443]here. Each of the four grows by four words. Every other stage lowers to the same words; 42,785 of 42,856 lower on both.kokiri-startsave: the Kokiri Forest entrance, then into Hyrule Field past its event. The draw statistics (RX_VK_DRAW_STATS, three frames a side) list 36 to 41 mesh stages a frame, but none of the four, so these runs show that nothing else broke, not the fix. Both logs report no lowering failure and no refused program. Screenshots of the same spots differ only in moving things (fireflies, Navi, fog).The checks:
gpu/vk/tests/regmap_marker_test.cpplowers a 32-, 64- and 128-bitLDLandLDSinto R204 with the reserved registers from R206 (the UR36 setup from #2179), reads every lowered load's destinations through the prefixes before it, and asserts that the 32- and 64-bit loads get no prefix. On the test commit it fails for the bug's reason:LDL R204 (128-bit) wrote: 204 205 206 207andLDS R204 (128-bit) wrote: 204 205 206 207. It passes on the fix. Taking out0x983alone fails only theLDLcase, and0x984alone only theLDScase; counting every local and shared load as four registers fails the 32- and 64-bitLDScases. The 32- and 64-bit cases and the existing global-load cases pass on both.lower_test.cpp,ldsm_address_test.cppand the twelve Python tests that readlower_to_maxwell.hpass on all three;regmap_marker_test.cppfails only on the test commit.tests/run_all.py --strict: on the headadb7b13d4, 836 passed, 95 failed and 10 skipped, and the same on maind0164fae4. The failing files are the same 95 on both, named in a comment below; no check was skipped for a missing tool. The renderer builds on both, andhost/nn_hid.ccompiles, with the same 65 warnings (checked on69b6983a6, whose code is the head's; only the test differs). The game was not run on Linux.Still to test:
Measurements
Nothing to measure: four words more in four shaders that the measured scenes did not draw; every other shader lowers to the same words.
Risks
Only the four stages above change, each by one register-map prefix before two of its loads, so they write the extended registers 442-443 for R186-R187, as the global loads have done since #2179. If it went wrong, those four shaders' depth or shadow output would be wrong; a revert is enough.
One case is now refused instead of lowered: without a uniform register bank the reserved registers start at R246, so a 128-bit
LDL R244reaches the lowering's own scratch registers and the program is refused ("native program uses lowering scratch registers"), where main lowered it and silently wrote R246-R247. No shader in the game is affected: 42,785 of the 42,856 stages lower on main and here alike. The shader translator's stamp coverseden/, so the program caches are prepared again after updating, as for any translator change.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.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_01VxeaZk9YYKvW5r88gQGguW
Tested in game: Windows 10, RTX 4090, NVIDIA 617.42, native mesh shaders: main
b40214d2band this fix (99210a71e, same code as the headadb7b13d4). All 42,856 of the game's shader stages lowered with both: only the four stages the issue names change, each gaining the R186-R187 -> 442-443 map before its 128-bit LDL. Headless runs from kokiri-start (Kokiri Forest entrance, Hyrule Field) on both builds: no lowering failures or refused programs; the draw statistics list none of the four stages there, so these runs show no regression, not the fix itself.Linux (WSL, Ubuntu 22.04),
tests/run_all.py --stricton the headadb7b13d4and on maind0164fae4: 836 passed, 95 failed, 10 skipped on both. The 95 failing files are the same on both:The 95 files that fail on main too
tests/global_load_16tests/test_astc_upload_chunking.pytests/test_async_astc_upload_chunks.pytests/test_bind_memo.pytests/test_blocks_at_start.pytests/test_bug_report.pytests/test_check_cache.pytests/test_cloth_loops.pytests/test_cloth_sphere.pytests/test_cloth_step12.pytests/test_cloth_step8.pytests/test_cloth_step9.pytests/test_compute_warm_apart.pytests/test_control_picture.pytests/test_coop_spirv.pytests/test_crash_record.pytests/test_crt_options.pytests/test_damage_debug_menu.pytests/test_dav1d_av1.pytests/test_dev_update.pytests/test_dlss5_menu.pytests/test_dlss_actor.pytests/test_dlss_pre_bloom.pytests/test_dlssg_hud_ui.pytests/test_dlssg_hudless_pq.pytests/test_draw_stream_visibility.pytests/test_drawn_page_map.pytests/test_early_split_before_draw.pytests/test_fallback_pipeline_state.pytests/test_flat_map.pytests/test_framegen_hdr.pytests/test_framegen_resources.pytests/test_fsr3_math.pytests/test_fsr3_shaders.pytests/test_fsr3fi_hud_layer.pytests/test_fsr3fi_hudless_colour.pytests/test_fsr_image_retirement.pytests/test_fsr_uniform_ownership.pytests/test_game_boundary.pytests/test_game_font.pytests/test_guest_holes.pytests/test_image_reaper_threads.pytests/test_image_view_retry.pytests/test_import_reach.pytests/test_input_background.pytests/test_keyboard_menu_option.pytests/test_keyboard_option.pytests/test_late_fix_build.pytests/test_late_fix_shaders.pytests/test_lifter.pytests/test_linux_pressure.pytests/test_loaded_modules_drop.pytests/test_log_levels.pytests/test_menu_keys.pytests/test_menu_save_atomic.pytests/test_mesh_unreachable_outputs.pytests/test_mirror_bookkeeping.pytests/test_native_zstd.pytests/test_oot_cloth.pytests/test_oot_occ_raster.pytests/test_option_ids.pytests/test_pass_barrier.pytests/test_perf_send.pytests/test_pipeline_tour.pytests/test_prepare_stall.pytests/test_present_acquire_ahead.pytests/test_present_image_free.pytests/test_present_source_crop.pytests/test_prof_clock.pytests/test_program_cache_cleanup.pytests/test_program_cache_one_variant.pytests/test_reactive_mask.pytests/test_readback_timeout_reuse.pytests/test_recorder_sync.pytests/test_recording_admission.pytests/test_report_words.pytests/test_screensaver.pytests/test_staging_burst.pytests/test_switch_table.pytests/test_target_retention.pytests/test_temporal_present_bandwidth.pytests/test_tex_desc_memo.pytests/test_text_keyboard_policy.pytests/test_ub_snapshot_default.pytests/test_ub_snapshot_gpu_writes.pytests/test_upscaler_round_trip.pytests/test_upscaler_rows.pytests/test_vk_wb_cpu_words_fast.pytests/test_vram_compact.pytests/test_wb_diff_stale_shadow.pytests/test_wb_pending_capture.pytests/test_windows_display_startup.pytests/test_windows_on_linux.pytests/test_wmma16_spirv_val.pytests/test_wrote_regions.pyWIP: fix(vk): map local and shared loads across the reserved register boundaryto fix(vk): map local and shared loads across the reserved register boundary@review
Recommendation: Approve. The code is ready: only testing is left. The synthetic regression test demonstrates the register-mapping fix, but none of the reported game runs drew an affected shader. The affected depth and shadow paths still need an in-game run, and CI is pending. Recommend approval; not approved on the forge.
The change maps local and shared load destinations that cross the reserved-register boundary to extended registers. It fixes the demonstrated lowering error with a small increase in generated code for affected shaders; its visible effect in the game remains unknown.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/eden/shader_recompiler/frontend/ampere/lower_to_maxwell.h:254: The affected shader stages have not been exercised in the game, so their resulting depth and shadow output is still unverified. (more on the line) Do: Find a scene that draws an affected stage and compare the base and this change on native mesh-shader hardware; cover the Tier 1 systems the path can affect.Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven in the game. The reported synthetic 128-bit LDL and LDS cases fail on the base and pass with the fix; four of 42,856 surveyed shader stages change, but none was drawn in the reported scenes.
Other systems: The lowering feeds the Maxwell translator on supported GPUs and operating systems. The author reports identical lowered words for the other surveyed stages and a Windows RTX 4090 run through unaffected stages; the affected stages and Linux, AMD and Steam Deck game runs are not demonstrated.
Switches: None added, changed or removed.
Reviewed:
adb7b13d4cagainstd0164fae43: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, both diffs, the complete regression test, the register-map translator and local/shared-load translator. Read the changed header's register survey, load lowering, prefix emission and retry paths; skimmed the rest of the 3,638-line header. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. No generated files or translations changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no code or tests were run. The supplied CI checks are still running.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -252,0 +251,4 @@// (longshot) the local and shared loads too (LDL 0x983, LDS 0x984: their size at the same bits): a// 128-bit LDL into R204 with the reserved registers from R206 wrote plain R206-R207 (issue 2243)const bool load_dest =f == 0 && (opcode == 0x381 || opcode == 0x981 || opcode == 0x983 || opcode == 0x984);L1 (should fix): The affected shader stages have not been exercised in the game, so their resulting depth and shadow output is still unverified.
When: A scene that draws one of the four changed mesh stages executes a newly mapped local load; the reported Kokiri Forest and Hyrule Field runs did not draw any of them.
Do: Find a scene that draws an affected stage and compare the base and this change on native mesh-shader hardware; cover the Tier 1 systems the path can affect.
@beanstalk
Beanstalk test farm · ❌ failed on windows+nvidia
Commit
adb7b13· approved by HumanBean (reviewed) · dashboard⚠️ Note: No known scene draws an affected stage; the tour is exploratory, and missing stage keys leave that coverage check unjudged. Draw statistics may not expose the keys on every renderer, and a matching run does not by itself prove which screenshot contains the affected draw.
⚠️ Note: The farm cannot run the synthetic register-mapping unit test through this plan, so it cannot directly verify the LDL and LDS destination mappings.
Done (started 2026-12-04 00:17 UTC, last report 2026-12-04 10:05 UTC). Comment
@Beanstalkto run it again.windows+nvidialinux+radvsteamdeckWhy it failed
windows+nvidia:depth-shadow-tourscreenshot.max_diff:0.6 → 0.4; limit 0.2Couldn't be judged: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own.
linux+radv, report 1:Insufficient frame-time evidence for 1 required comparison(s). See rule results.linux+radv, report 2:Insufficient frame-time evidence for 1 required comparison(s). See rule results.steamdeck, report 1:the pr runtime failed (exit 1): …ne 70, in <module>steamdeck, report 2:Insufficient frame-time evidence for 1 required comparison(s). See rule results.What was tested
What will be tested · AI plan (
gpt-6.1-terra)The farm will compare main and the PR on Windows NVIDIA, Linux RADV and Steam Deck, sampling shadow and depth scenes in Hyrule Field, the Market and Kakariko Village. Each side gets three starts, with stationary screenshots and shader draw-statistics logs collected at each location, taking roughly 35 minutes per tester. A crash or a screenshot difference above the allowed threshold fails the PR; the logs will also be searched for the four affected stage keys. If none appears, the run cannot establish that the fix was exercised.
kokiri-start(switchesHOS_FPS_MAX=30,HOS_OUTPUT_RES=1280x720,RX_VK_DRAW_STATS=1), then teleport to Hyrule Field, take the picture field to compare with main, teleport to Market, take the picture market to compare with main, teleport to Kakariko Village, take the picture kakariko to compare with main; 3 runs on each side.Measurements on `windows+nvidia`, for the PR description
Verdict: fail on windows+nvidia (2 reports):
depth-shadow-tour screenshot.max_difffailed.Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu+window
NVIDIA GeForce RTX 4070, 621.24.0AMD Ryzen 9 7900X 12-Core Processor, 64 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpu+window+xessNVIDIA GeForce GTX 980, 582.78.0Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 32 GB RAMScene: depth-shadow-tour, from the repository's save kokiri-start (HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720, RX_VK_DRAW_STATS=1); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); depth-shadow-tour: 3 game starts a side; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)d0164faadb7b13Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `linux+radv`, for the PR description
Verdict: could not be judged on linux+radv (2 reports): required frame-time comparison inconclusive (fewer than two usable starts per side).
Hardware: 1: linux+amd+radv+igpu
AMD Radeon 890M Graphics (RADV STRIX1), 26.1.99AMD Ryzen Z2 Extreme, 32 GB RAM; 2: linux+amd+radv+dgpuAMD Radeon RX 9070 (RADV GFX1201), 26.3.1AMD Ryzen 5 7600X3D 6-Core Processor, 32 GB RAMScene: depth-shadow-tour, from the repository's save kokiri-start (HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720, RX_VK_DRAW_STATS=1); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); depth-shadow-tour: 3 game starts a side; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)d0164faadb7b13Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `steamdeck`, for the PR description
Verdict: could not be judged on steamdeck (2 reports): required frame-time comparison inconclusive (fewer than two usable starts per side).
Hardware: 1: linux+amd+radv+igpu+handheld
AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 16 GB RAM; 2: linux+amd+radv+igpu+handheldAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 16 GB RAMScene: depth-shadow-tour, from the repository's save kokiri-start (HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720, RX_VK_DRAW_STATS=1); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); depth-shadow-tour: 3 game starts a side; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)d0164faadb7b13Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
The testers' hardware
windows+nvidiaNVIDIA GeForce RTX 4070, 621.24.0AMD Ryzen 9 7900X 12-Core Processor, 64 GB RAMwindows+nvidiaNVIDIA GeForce GTX 980, 582.78.0Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 32 GB RAMlinux+radvAMD Radeon 890M Graphics (RADV STRIX1), 26.1.99AMD Ryzen Z2 Extreme, 32 GB RAMlinux+radvAMD Radeon RX 9070 (RADV GFX1201), 26.3.1AMD Ryzen 5 7600X3D 6-Core Processor, 32 GB RAMsteamdeckAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 16 GB RAMsteamdeckAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 16 GB RAMThe farm's Kakariko failure looks like scene noise: re-run on my PC. Windows 10, RTX 4090, driver 617.42; the farm's plan for Kakariko alone: save
kokiri-start,HOS_FPS_MAX=30,HOS_OUTPUT_RES=1280x720,RX_VK_DRAW_STATS=1, headless, teleport to Kakariko Village, 150 frames after arriving, one picture; 6 game starts ABBA (main, PR, PR, main, main, PR). Runtimes: mainb40214d2band this fix on it (99210a71e). Itslower_to_maxwell.hchange is identical to this head's (git range-diff: only the test's extra assertion and the commit message differ).3af1ac7c868ebee8,18341da39b21edb5,11a1afbd0c6737e0,4170159071412496), the same as the farm's "expected line missing" on every run. No lowering failure or refused program in any log.The farm's own numbers say the same for its Market and Field pictures (main against itself 0.61–0.64 in the Market, above the PR's 0.27–0.38). Its Kakariko PR diff was above main's own spread on both of its PCs, with three starts a side; here, with the same pair of runtimes, it is not. With no changed stage drawn, the PR's lowered programs are word for word main's (the offline lowering of all 42,856 stages, in the description), so the pictures can't differ by it. The scene that draws the four stages is still unknown (Still to test).
@review
Recommendation: Approve. The code is ready: only testing is left. The regression test and offline shader comparison support the register mapping fix, but the four affected stages have not been exercised in the game. Their depth and shadow output remains unverified. Recommend approval; not approved on the forge.
The change maps local and shared load destinations across the reserved register boundary, preventing affected loads from writing the wrong registers. It adds a focused game-free regression test and changes four recorded game shader stages, each by four words.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/eden/shader_recompiler/frontend/ampere/lower_to_maxwell.h:254: The affected shader stages have not been exercised in the game, so their resulting depth and shadow output is still unverified. When: A scene that draws one of the four changed mesh stages executes a newly mapped local load; the reported Kokiri Forest and Hyrule Field runs did not draw any of them. Do: Find a scene that draws an affected stage and compare the base and this change on native mesh-shader hardware; cover the Tier 1 systems the path can affect.Since the last review (on
adb7b13d4c)Still open: L1 (The affected shader stages have not been exercised in the game, so their resulting depth a…)
Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven in game: the author reports that the test fails on main and passes with the fix, and that four of 42,856 shader stages change as intended. None of those four stages appeared in the recorded game runs.
Other systems: The lowering is shared across platforms and GPUs. The author reports a Windows NVIDIA game run and Linux checks, but no Linux game run or in-game exercise of the affected stages; a synthetic shared load also exercises the fix.
Switches: None added, changed or removed.
Reviewed:
adb7b13d4cagainstd0164fae43: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the full diff and regmap_marker_test.cpp; read the relevant portions of lower_to_maxwell.h and searched its load and call-link paths. The rest of the 3,638-line lowering header was not read in full. The referenced Tooling AGENTS.md and docs/review-checklist.md were unavailable.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run code were executed. The author reports game-free regression results, Windows NVIDIA game runs that did not draw the affected stages, and matching Linux check results on head and base. CI is still running.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.