feat(vk-rt): ray tracing on the mod API: AO, sun shadows, GI, reflections, lamp shadows, lantern lights #2966
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2966
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:rt-ray-tracing"
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
Experimental ray tracing for the Vulkan renderer: ambient occlusion, sun shadows, global illumination and reflections (the work of #727 by winterelfeas), plus lamp shadows (from #2755), and lantern lights, glowing panes and specular highlights (from #1151 by Drommedhar, bulbs, panes and highlights only). Off by default, and turning it on needs no restart.
[EXPERIMENTAL], as DLSS 5's does.[[settings]]of the graphics system mod.RX_VK_RT=<bits>overrides them for a run.RX_VK_RT_REFIT=0builds each frame).RX_VK_RT_LOG=1: per-pass GPU timings. The acceleration structures are freed after the rows have been off for 900 presents.Read first:
gpu/vk/vk_rt_scene.cpp(structures),vk_rt_lit.cpp(variants),vk_rt_gi.cpp,vk_rt_lamps.cpp,vk_rt_di.cpp; the doc isdocs/dev/reference/ray-tracing.md.Known problems, not fixed here:
Testing
Tested: Linux, RTX 3090, headless. The head,
a626e569, is77d3f1adrebased ontomain@6dbebabe, with the menu code moved to main'sgpu/vk/settings/and the help texts tagged: the runtime builds andcargo check --workspace --all-targetspasses but for two test targets this PR does not change (build-driver'sdrivertest andmodtool's lib tests do not compile). No tests were run and nothing was played. At77d3f1ad: all parts on at Kokiri start, Market entrance and the castle gate, Kokiri also withRX_VK_RT_OMM=0, and Kokiri withRX_VK_RT_OMM=0 RX_VK_MESH_SHADERS=compute(the path AMD takes on Linux); screenshots match5672bf5dapart from what moves, and the logs show no device loss. No validation layers are installed, so none ran.At
5672bf5d, with screenshots: Kokiri start, Market entrance and the castle gate with rays off and all parts on; the castle gate also withRX_VK_RT_OMM=0and all parts on under Native HDR (forced in headless gamescope). The logs show the parts running. At earlier heads of this branch: each part alone under Native HDR, switching the HDR setting mid-game, and Expanded HDR. The screenshots are in a comment below.A tester ran
3ec4959don an RX 7900 XT, Windows: it works, with the cost and the turf flicker above.Still to test:
Measurements
Verdict: the whole feature is not measured against
mainat this head. The character refit was measured against5672bf5dand is a small gain.Refit and foliage capture against
5672bf5d(Linux, RTX 3090,RX_VK_RT=63, one timed run a side,RX_VK_RT_LOG=1lines; frame time was at the 60 fps cap):Recording those builds on the CPU went from 0.117 to 0.074 ms (Kokiri) and 0.247 to 0.147 ms (Market). The foliage capture change showed no measurable gain with native mesh shaders; on the compute path, where it could, it is not measured.
Older numbers, from before the rebases and fixes (Linux, RTX 3090, Kokiri Forest, 67 % render scale, uncapped, 45 s, 3 interleaved runs each): rows off 166 fps (5.9 to 6.3 ms), AO + sun + GI + reflections 74 to 81 fps (12.1 to 12.8 ms). Rows off against ray tracing disabled was within the spread.
From the tester's log at
3ec4959d(RX 7900 XT, 3440x1440, no upscaler; GPU time a frame, one session, not a controlled run):Risks
Everything is off by default, and
RX_VK_RT=0disables it completely.With the rows off, a GPU that can ray trace still gets a different device from main: the ray tracing extensions and features are enabled and pool buffers carry the acceleration structure build input usage, so that a row can be turned on without a restart. Startup time, memory, AMD and Intel are not measured with this.
The new settings keys are frozen in
tests/test_menu_ini_keys.py. A link failure of a patched lit program turns reflections off, not the game.Checklist
Ready for review
main; the title is a Conventional Commit. (On main @6dbebabeat the last rebase.)mise run testpasses. (Not run since the rebase. At77d3f1ad: 911 passed, 1 failed, 13 skipped:test_lifterfails in build-driver on files this PR does not change, but was not confirmed onmain.)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible (#727, #2755, #1151 are GPL).When it applies
gpu/vk/switches.def. (The 17RX_VK_RT*rows are there; no measurements chose them.)tests/that reads changed source is updated, not weakened.mainand here, for a change that shows on screen. (Rays off against on, both on this PR.)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_017vw8e1HDsYuvW83jB4TRWM
Tested in game: Linux, RTX 3090, the starting area and Kokiri Forest with all seven rows on: no flicker, no flashes at resolution changes, the water and lanterns draw, no device loss.
3428ab8b094571673dc6Rebased onto
mod-api@b15d47e3(old head3428ab8b, new head4571673d).Conflicts:
scripts/shaders.pyis gone onmod-api: the 52 ray tracing builds are now ingpu/vk/shaders/recipes.toml, and the tests and doc that named the script read or name that file.settings_at_startis host API version 89, aftermod-api'scursor(88).schema-gen.Checked on Linux:
dev.py rtbuilds with 0 failures (nothing run in game since the rebase).schema-gen --checkandffi-gen --checkpass;cargo fmt --checkandcargo test -p gen-shaders -p schemapass.test_late_fix_build.pyfails to compile (wb_cpu_words_fastundeclared), and does the same againstmod-api's ownvk_memory.cpp.4571673dc6464228827fRebased again, onto
mod-api@2393f086(old head4571673d, new head46422882).No text conflicts. One compile error after the clean merge:
mod-apimovedfallback_records_address's declaration below the PR'sfallback_records_now()invk_draw.cpp, so the function now sits after it.Checked on Linux:
dev.py rtbuilds with 0 failures; shaders compile;schema-genandffi-gen --check,cargo fmt --check,cargo test -p gen-shaders -p schemaand 45 of 45 selected Python checks pass (test_late_fix_build.pypasses now). Nothing was run in game, and nothing was built for Windows.@review
Recommendation: Request changes. It conflicts with its base branch: bring it up to date (
@fixor@rebasetry first). (L4) The feature has not been run in game at this head, and its effects on other supported hardware remain untested. The review is also incomplete: the change is too large for the code inspected here to support a merge recommendation.This adds optional Vulkan ray-traced lighting, shadows and reflections. The reported older run shows the effects in two areas, with a substantial GPU cost when enabled; the current head and several lighting features still need validation.
Blocking (1): must change before merging.
@fixor@rebasetry first). (for the author)Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)
More: does it help, other systems, switches, what was read
Does it help: Unproven at this head. The author reports 74–81 fps with four effects enabled versus 166 fps with rows off on an RTX 3090, and reports that the picture worked before the rebases; neither is an in-game run of
46422882.Other systems: The change affects Vulkan device creation even with the rows off, as well as rendering, GPU memory and timing when enabled. Windows, AMD, Intel, Steam Deck and devices without ray queries have not been validated for this head in the supplied reports.
Switches: The change adds or changes numerous RX_VK_RT switches and seven graphics settings. The effects default off; the roughness setting defaults to Medium. A complete switch-by-switch review was not completed.
Reviewed:
464228827fagainst2393f0865b: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the commit message, vk_rt_lit.cpp and test_rt_budget.py. Read portions of standards.md, the device setup, settings integration, draw hooks, retirement logic, test runner and recorded runs; skimmed the file list and remaining diff. Most changed renderer files, shaders, tests and documentation were not read in full. docs/review-checklist.md was absent.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run, as requested. The author reports a Linux build and selected checks passing at this head, but no in-game run after the rebase.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
464228827faa597d03f7aa597d03f7c8a865c919c8a865c919dc2091f9e5dc2091f9e53ec4959d7a3ec4959d7a0f566ad1b60f566ad1b65672bf5d0dRebased onto
main@1c8c2634and fixed (old head46422882, new head5672bf5d).Screenshots, Linux, RTX 3090, headless: left rays off, right all parts on; Kokiri start, Market entrance, castle gate, and the castle gate under Native HDR (raw HDR output, so it looks washed out). The fairy is in a different place in each run, which changes how Link is lit.
5672bf5d0d77d3f1ad80Pushed
77d3f1ad(old head5672bf5d), not rebased.RX_VK_RT_REFIT=0turns it off).Neither change affects anything with ray tracing off. Not run on AMD or Windows.
For whoever reported the turf shadow flicker (RX 7900 XT, Windows): could you try a build of
77d3f1ad?RX_VK_RT_LOG=1for the run.longshot_log.txt.For frame rate in the meantime: in your earlier log, GPU time was 42 to 88 ms with Reflections: max roughness at Max, and 20 to 34 ms at 0.35 or less. Try Medium or Low.
The flicker was never reproduced here, so this run is what tells us whether it is fixed.
77d3f1ad803e734c741aRebased onto
main@b77c2f4b(old head77d3f1ad, new head3e734c74). Three conflicts, both sides kept: the user docs' settings table, a menu test, and a draw hook invk_draw.cpp. It builds on Linux; the tests and the game have not been run on the new head.For the turf flicker test asked above, use
3e734c74.Ray Tracing does not work currently with PsychoV35, HDR Tone Mapper. With PsychoV35 on, Ray Tracing gets turned off.
Windows 11
9800x3d
Rtx 5080, nvidia drivers 617.42
48gb ram.
@Noa@NoahClue wrote in #2966 (comment):
Thanks. Which commit is your build from? Could you try
3e734c74with RX_VK_RT_LOG=1, turn on ray tracing and PsychoV35, and attach longshot_log.txt? Also: does the Ray tracing setting itself change to Off, or do the effects just disappear? And are DLSS or frame generation on?3e734c741ad37c4a8979Rebased onto
main@f8b54338(old head3e734c74, new headd37c4a89). Conflicts with the new Volumetric Fog settings (menu layout, strings, menu test, user docs) were resolved keeping both, as were two includes invk_main.cpp; the settings ABI was regenerated. Not built, tested or run.@HumanBean wrote in #2966 (comment):
Problem is solved with
3e734c74, i was using an old commit! Works with DLSS 5, Frame gen and PsychoV35 on.d37c4a897944bf048b43Rebased onto
main@150c8bcc; force-pushed, old headd37c4a89, new head44bf048b.gpu/vk/settings/, so ray tracing's pieces moved there too.[EXPERIMENTAL], as DLSS 5's does.builder/crates/build-driver/tests/driver.rsandmodtool's lib tests (src/import.rs). No tests were run and nothing was played; Windows was not compiled.44bf048b43af0f09f9d3Rebased onto
main@df19b740; force-pushed, old head44bf048b, new headaf0f09f9.Only the generated settings files conflicted. Compile check only (Linux): the runtime builds, and the Rust workspace checks except the same two test targets as above, which this PR does not change. No tests were run and nothing was played.
af0f09f9d3a626e56966Rebased onto
main@6dbebabe; force-pushed, old headaf0f09f9, new heada626e569.Only the generated settings files conflicted. Compile check only (Linux): the runtime builds, and the Rust workspace checks except the same two test targets, which this PR does not change. No tests were run and nothing was played.
WIP: feat(vk-rt): ray tracing on the mod API: AO, sun shadows, GI, reflections, lamp shadows, lantern lightsto feat(vk-rt): ray tracing on the mod API: AO, sun shadows, GI, reflections, lamp shadows, lantern lights