jalberse / shimmer

Physically based rendering in Rust
Apache License 2.0
33 stars 0 forks source link

Remove Unsafe get_mut_unchecked() in core render loop #79

Open jalberse opened 3 months ago

jalberse commented 3 months ago

An alternative approach which does not require unsafe Rust may be possible; it's likely possible to create a system where \verb|FilmSample| objects are accumulated in some \verb|FilmTile| which are then stitched together sequentially once the threads are joined. This would avoid concurrency issues as no threads are writing to the shared Film in parallel. This approach would also consume less memory than than simply accumulating \verb|FilmSamples|, as the \verb|FilmTile| would only need to store running averages, rather than the full set of samples.

jalberse commented 1 month ago

21a1b63 mentions this but it's not actually correct to do that. That deals with light preprocessing, which is a different instance where we use get_mut_unchecked(). Whoops. In either case, if we want to move off of the nightly compiler, both usages of get_mut_unchecked() would need to be removed.