MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / final_image

Method final_image

examples/cuda/cpu/path_tracer/src/cpu/mod.rs:87–110  ·  view source on GitHub ↗
(&mut self, cur_sample: usize)

Source from the content-addressed store, hash-verified

85 }
86
87 pub fn final_image(&mut self, cur_sample: usize) -> (&[Vec3<u8>], Duration) {
88 let start = std::time::Instant::now();
89
90 let Self {
91 accumulated_buffer,
92 out_buffer,
93 ..
94 } = self;
95
96 out_buffer
97 .par_iter_mut()
98 .zip(accumulated_buffer.par_iter())
99 .for_each(|(px, acc)| {
100 let scaled = acc / cur_sample as f32;
101 let gamma_corrected = scaled.sqrt();
102
103 *px = (gamma_corrected * 255.0)
104 .clamped(Vec3::zero(), Vec3::broadcast(255.0))
105 .numcast()
106 .unwrap();
107 });
108
109 (&self.out_buffer, start.elapsed())
110 }
111
112 pub fn render(&mut self) -> Duration {
113 // rustc has some problems with borrows even though it should be fine in this case,

Callers 1

renderMethod · 0.45

Calls 2

sqrtMethod · 0.80
elapsedMethod · 0.80

Tested by

no test coverage detected