Walther / clovers

Ray Tracing in Rust
https://walther.github.io/clovers/clovers/
13 stars 1 forks source link

refactor: massive lifetime refactoring #179

Closed Walther closed 1 year ago

Walther commented 1 year ago

Making all the various Hitable structs to contain a reference &Material instead of owning their own Copy of a Material.

Cons: This sadly requires spamming quite a lot of <'scene> lifetimes around Pros: This reduces the memory usage on some scenes quite significantly - directly proportional to the amount of triangles using a shared material

this branch

just cli -i scenes/dragon.json  714.97s user 3.72s system 713% cpu 1:40.78 total
64M reserved

just cli -i scenes/gltf_scifi_helmet.json  535.42s user 2.65s system 736% cpu 1:13.04 total
122M reserved

main 305d52388fe2067bf93f7fdc4a804cf00e8eb3bc

just cli -i scenes/dragon.json  728.58s user 5.51s system 733% cpu 1:40.13 total
150M reserved

just cli -i scenes/gltf_scifi_helmet.json  544.08s user 4.35s system 722% cpu 1:15.90 total
132M reserved

There's still a lot of additional work to do in later PRs - e.g.