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

Method new

examples/cuda/cpu/path_tracer/src/cuda/data.rs:38–65  ·  view source on GitHub ↗
(dimensions: Vec2<usize>, camera: &Camera, scene: &Scene)

Source from the content-addressed store, hash-verified

36
37impl CudaRendererBuffers {
38 pub fn new(dimensions: Vec2<usize>, camera: &Camera, scene: &Scene) -> CudaResult<Self> {
39 let accumulated_buffer = Self::image_buffer(dimensions)?;
40 let out_buffer = Self::image_buffer(dimensions)?;
41 let denoised_buffer = Self::image_buffer(dimensions)?;
42 let scaled_buffer = Self::image_buffer(dimensions)?;
43
44 let objects = scene.objects.as_unified_buf()?;
45 let materials = scene.materials.as_unified_buf()?;
46
47 let mut viewport = Viewport::default();
48 camera.as_viewport(&mut viewport);
49 viewport.bounds = dimensions;
50
51 let rand_states = DefaultRand::initialize_states(SEED, dimensions.product())
52 .as_slice()
53 .as_unified_buf()?;
54
55 Ok(Self {
56 accumulated_buffer,
57 scaled_buffer,
58 out_buffer,
59 denoised_buffer,
60 viewport,
61 objects,
62 materials,
63 rand_states,
64 })
65 }
66
67 /// Resets and reallocates the entire scene. This may be slow because it needs to reallocate
68 /// all of the GPU scene buffers.

Callers

nothing calls this directly

Calls 3

as_unified_bufMethod · 0.80
as_viewportMethod · 0.80
as_sliceMethod · 0.45

Tested by

no test coverage detected