Ray tracing: reading title memory in place (no copies) took my fork from ~14 to ~31 fps #8

Open
opened 2026-12-01 07:41:02 +00:00 by github-bot · 1 comment
Owner

@⁠luisaugustz on GitHub · 2026-11-29 15:26 UTC · original

Sharing a result from my fork, in case it is useful. It is experimental and the code is not pushed yet.

Setup: Ryzen 7 5800X, 32 GB, RX 9070 XT, Arch, patched Mesa with unified memory, 3440x1440 output with FSR balanced, software ray tracing (VICTORY_BVH_BUILDER=1). My fork is ca97da241 merged with my own changes.

Idea: with unified memory, don't copy title memory for the shaders that read it by address. Point the directory entry of a page at the unified-memory mirror, so the traversal and builder shaders use title memory itself.

Spot With copies No copies
Inside a house 13.7 fps 31 to 32.6 fps
A doorway about 11 fps 26 to 33 fps

CPU time spent keeping those copies up to date went from at least 38 ms per frame to 0. These are separate runs at about the same spots, not a controlled benchmark.

How (memory.rs)

  • New map_in_place(page), tried first when a page needs a place, behind VICTORY_BVH_IN_PLACE=1.
  • Needs the page to be placeable in unified memory. Views are made over the mirror in stretches of 128 MiB (up to 1024), numbered from the top of the copy range.
  • A page where a title buffer already has a copy of its own keeps the copy, so bound and by-address access stay one memory.
  • A page unmapped later reads zeros (the driver's mirror).
  • There is also a =vram mode (only pages that lie in video memory). I built it but never ran it.

Caveats

  • Shaders now write title memory directly. I have only run it in short sessions.
  • I had graphics ring hangs in ray tracing sessions with this on (one also had other experiments enabled, one had debug counters). I don't know whether no-copy is involved.
  • Lighting with software ray tracing is wrong at my test doorway (white glare, black walls) both with and without no-copy. In debug counters, most box tests that missed were on nodes whose child bounds are all zero, in title memory too. I have not found the cause.

I can share the patch or open a PR if you want it.

**@⁠luisaugustz** on GitHub · 2026-11-29 15:26 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/8) Sharing a result from my fork, in case it is useful. It is experimental and the code is not pushed yet. **Setup:** Ryzen 7 5800X, 32 GB, RX 9070 XT, Arch, patched Mesa with unified memory, 3440x1440 output with FSR balanced, software ray tracing (`VICTORY_BVH_BUILDER=1`). My fork is `ca97da241` merged with my own changes. **Idea:** with unified memory, don't copy title memory for the shaders that read it by address. Point the directory entry of a page at the unified-memory mirror, so the traversal and builder shaders use title memory itself. | Spot | With copies | No copies | |---|---|---| | Inside a house | 13.7 fps | 31 to 32.6 fps | | A doorway | about 11 fps | 26 to 33 fps | CPU time spent keeping those copies up to date went from at least 38 ms per frame to 0. These are separate runs at about the same spots, not a controlled benchmark. **How (`memory.rs`)** - New `map_in_place(page)`, tried first when a page needs a place, behind `VICTORY_BVH_IN_PLACE=1`. - Needs the page to be placeable in unified memory. Views are made over the mirror in stretches of 128 MiB (up to 1024), numbered from the top of the copy range. - A page where a title buffer already has a copy of its own keeps the copy, so bound and by-address access stay one memory. - A page unmapped later reads zeros (the driver's mirror). - There is also a `=vram` mode (only pages that lie in video memory). I built it but never ran it. **Caveats** - Shaders now write title memory directly. I have only run it in short sessions. - I had graphics ring hangs in ray tracing sessions with this on (one also had other experiments enabled, one had debug counters). I don't know whether no-copy is involved. - Lighting with software ray tracing is wrong at my test doorway (white glare, black walls) **both with and without** no-copy. In debug counters, most box tests that missed were on nodes whose child bounds are all zero, in title memory too. I have not found the cause. I can share the patch or open a PR if you want it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 07:41:02 +00:00
Author
Owner

@⁠lobomfz on GitHub · 2026-11-29 15:41 UTC · original

nice result, thanks for writing it up. yes please, open a PR against main. keeping it behind VICTORY_BVH_IN_PLACE=1 like you have it is fine, and don't worry about the untested =vram mode or the doorway lighting, that one happens here too and is a separate bug.

**@⁠lobomfz** on GitHub · 2026-11-29 15:41 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/8#issuecomment-7258294268) nice result, thanks for writing it up. yes please, open a PR against main. keeping it behind `VICTORY_BVH_IN_PLACE=1` like you have it is fine, and don't worry about the untested `=vram` mode or the doorway lighting, that one happens here too and is a separate bug.
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/lobomfz--VIctory-xmem#8
No description provided.