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

Function render

examples/cuda/gpu/path_tracer_gpu/src/render_kernels.rs:6–21  ·  view source on GitHub ↗
(fb: *mut Vec3, view: Viewport, scene: &Scene, rand_states: *mut DefaultRand)

Source from the content-addressed store, hash-verified

4
5#[kernel]
6pub unsafe fn render(fb: *mut Vec3, view: Viewport, scene: &Scene, rand_states: *mut DefaultRand) {
7 let idx = thread::index_2d();
8 if idx.x >= view.bounds.x as u32 || idx.y >= view.bounds.y as u32 {
9 return;
10 }
11 let px_idx = idx.y as usize * view.bounds.x + idx.x as usize;
12
13 // generate a tiny offset for the ray for antialiasing
14 let rng = &mut *rand_states.add(px_idx);
15 let offset = Vec2::from(rng.normal_f32_2());
16
17 let ray = generate_ray(idx, &view, offset);
18
19 let color = scene.ray_color(ray, rng);
20 *fb.add(px_idx) += color;
21}
22
23/// Scales an accumulated buffer by the sample count, storing each pixel in the corresponding `out` pixel.
24#[kernel]

Callers

nothing calls this directly

Calls 5

index_2dFunction · 0.85
generate_rayFunction · 0.85
addMethod · 0.80
normal_f32_2Method · 0.80
ray_colorMethod · 0.80

Tested by

no test coverage detected