(ctx: &mut DeviceContext, stream: &Stream, scene: &Scene)
| 34 | |
| 35 | impl 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(); |
nothing calls this directly
no test coverage detected