I'm at a point where my Rust based renderer matches the C++ counterpart pixel by pixel in a lot of cases (example scenes). See my description of the problem I try to solve:
The short version: The C++ code uses arena-based allocation (as described in the PBRT book). The current Rust implementation does not. My main problem so far was that I do not want to deal with references and lifetimes all the time. The description of the problem seems relative easy, but keep in mind that the arena based allocation is used in many places. In my description I focused mainly on BxDFs, which get created and destroyed by many threads in a relative short time. I think the main idea of the C++ code is to make those allocation/de-allocations fast by reusing the allocated memory (blocks). Create the arena per thread (or per bucket), allocate different sized structs/classes a couple of times without caring about releasing the memory exactly at the point where those are not needed anymore. Release the memory once via "
arena.Reset()" and reuse the memory without re-allocation.
I investigated how I could use a crate like bumpalo, but the main problem is that Bump::alloc() returns a "
&mut T" reference, which means I have to use lifetimes nearly everywhere. This is very painful and I really would appreciate another solution. Any suggestions? There seem to be many arena crates out there ...