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

Function scale_buffer

examples/cuda/gpu/path_tracer_gpu/src/render_kernels.rs:25–37  ·  view source on GitHub ↗
(fb: *const Vec3, out: *mut Vec3, samples: u32, view: Viewport)

Source from the content-addressed store, hash-verified

23/// Scales an accumulated buffer by the sample count, storing each pixel in the corresponding `out` pixel.
24#[kernel]
25pub unsafe fn scale_buffer(fb: *const Vec3, out: *mut Vec3, samples: u32, view: Viewport) {
26 let idx_2d = thread::index_2d();
27 if idx_2d.x >= view.bounds.x as u32 || idx_2d.y >= view.bounds.y as u32 {
28 return;
29 }
30 let idx = idx_2d.y as usize * view.bounds.x + idx_2d.x as usize;
31 let original = &*fb.add(idx);
32 let out = &mut *out.add(idx);
33
34 let scale = 1.0 / samples as f32;
35 let scaled = original * scale;
36 *out = scaled;
37}
38
39/// Postprocesses a (scaled) buffer into a final u8 buffer.
40#[kernel]

Callers

nothing calls this directly

Calls 2

index_2dFunction · 0.85
addMethod · 0.80

Tested by

no test coverage detected