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

Function postprocess

examples/cuda/gpu/path_tracer_gpu/src/render_kernels.rs:41–56  ·  view source on GitHub ↗
(fb: *const Vec3, out: *mut vek::Vec3<u8>, view: Viewport)

Source from the content-addressed store, hash-verified

39/// Postprocesses a (scaled) buffer into a final u8 buffer.
40#[kernel]
41pub unsafe fn postprocess(fb: *const Vec3, out: *mut vek::Vec3<u8>, view: Viewport) {
42 let idx_2d = thread::index_2d();
43 if idx_2d.x >= view.bounds.x as u32 || idx_2d.y >= view.bounds.y as u32 {
44 return;
45 }
46 let idx = idx_2d.y as usize * view.bounds.x + idx_2d.x as usize;
47 let original = &*fb.add(idx);
48 let out = &mut *out.add(idx);
49 // gamma=2.0
50 let gamma_corrected = original.sqrt();
51
52 *out = (gamma_corrected * 255.0)
53 .clamped(Vec3::zero(), Vec3::broadcast(255.0))
54 .numcast()
55 .unwrap();
56}

Callers

nothing calls this directly

Calls 3

index_2dFunction · 0.85
addMethod · 0.80
sqrtMethod · 0.80

Tested by

no test coverage detected