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

Method new

examples/cuda/cpu/path_tracer/src/optix/mod.rs:36–115  ·  view source on GitHub ↗
(ctx: &mut DeviceContext, stream: &Stream, scene: &Scene)

Source from the content-addressed store, hash-verified

34
35impl OptixRenderer {
36 pub fn new(ctx: &mut DeviceContext, stream: &Stream, scene: &Scene) -> Result<Self> {
37 let module_compile_options = ModuleCompileOptions {
38 max_register_count: 100,
39 debug_level: Default::default(),
40 opt_level: Default::default(),
41 };
42
43 let pipeline_compile_options = PipelineCompileOptions::new()
44 .pipeline_launch_params_variable_name("PARAMS")
45 .uses_motion_blur(false)
46 .num_attribute_values(7)
47 .num_payload_values(2)
48 .traversable_graph_flags(TraversableGraphFlags::ALLOW_SINGLE_GAS)
49 .exception_flags(ExceptionFlags::NONE);
50
51 let (module, _log) = OptixModule::new(
52 ctx,
53 &module_compile_options,
54 &pipeline_compile_options,
55 OPTIX_PTX,
56 )?;
57
58 let pgdesc_raygen = ProgramGroupDesc::raygen(&module, "__raygen__render");
59 let (pg_raygen, _log) = ProgramGroup::new(ctx, &[pgdesc_raygen])?;
60
61 let pgdesc_miss = ProgramGroupDesc::miss(&module, "__miss__miss");
62 let (pg_miss, _log) = ProgramGroup::new(ctx, &[pgdesc_miss])?;
63
64 let pgdesc_sphere_hitgroup = ProgramGroupDesc::hitgroup(
65 Some((&module, "__closesthit__sphere")),
66 None,
67 Some((&module, "__intersection__sphere")),
68 );
69 let (pg_sphere_hitgroup, _log) = ProgramGroup::new(ctx, &[pgdesc_sphere_hitgroup])?;
70
71 let accel = Self::build_accel_from_scene(ctx, stream, scene)?;
72
73 let rec_raygen: Vec<_> = pg_raygen
74 .iter()
75 .map(|pg| RaygenRecord::pack(0, pg).expect("failed to pack raygen record"))
76 .collect();
77
78 let rec_miss: Vec<_> = pg_miss
79 .iter()
80 .map(|pg| MissRecord::pack(0, pg).expect("failed to pack miss record"))
81 .collect();
82 let rec_sphere_hitgroup =
83 Self::build_scene_hitgroup_records(scene, &pg_sphere_hitgroup[0])?;
84
85 let buf_raygen = DeviceBuffer::from_slice(&rec_raygen)?;
86 let buf_miss = DeviceBuffer::from_slice(&rec_miss)?;
87 let buf_sphere_hitgroup = DeviceBuffer::from_slice(&rec_sphere_hitgroup)?;
88
89 let sbt = ShaderBindingTable::new(&buf_raygen)
90 .miss(&buf_miss)
91 .hitgroup(&buf_sphere_hitgroup);
92
93 let mut program_groups = Vec::new();

Callers

nothing calls this directly

Calls 12

newFunction · 0.85
exception_flagsMethod · 0.80
num_payload_valuesMethod · 0.80
num_attribute_valuesMethod · 0.80
uses_motion_blurMethod · 0.80
iterMethod · 0.80
set_stack_sizeMethod · 0.80
expectMethod · 0.45
hitgroupMethod · 0.45
missMethod · 0.45

Tested by

no test coverage detected