84 static bool probe()
noexcept;
98 void updateSources(
const std::vector<RayTracingSource> &sources)
override;
102 const std::vector<helios::vec3> &peak_dir,
103 const std::vector<float> &dist_norm,
104 const std::vector<float> &sky_energy)
override;
106 void updateSkyModel(
const std::vector<helios::vec4> &sky_radiance_params,
107 const std::vector<float> &camera_sky_radiance,
109 const std::vector<float> &solar_disk_radiance,
110 float solar_disk_cos_angle)
override;
120 void getCameraResults(std::vector<float> &pixel_data, std::vector<uint> &pixel_labels,
121 std::vector<float> &pixel_depths,
uint camera_id,
130 const std::vector<float> &radiation_out_bottom)
override;
132 const std::vector<float> &scatter_bottom_cam)
override;
143 OptixDeviceContext optix_context =
nullptr;
144 OptixModule optix_module =
nullptr;
145 OptixPipeline optix_pipeline =
nullptr;
146 CUstream cuda_stream =
nullptr;
149 OptixProgramGroup pg_raygen_direct =
nullptr;
150 OptixProgramGroup pg_raygen_diffuse =
nullptr;
151 OptixProgramGroup pg_raygen_camera =
nullptr;
152 OptixProgramGroup pg_raygen_pixel_label =
nullptr;
154 OptixProgramGroup pg_miss_direct =
nullptr;
155 OptixProgramGroup pg_miss_diffuse =
nullptr;
156 OptixProgramGroup pg_miss_camera =
nullptr;
157 OptixProgramGroup pg_miss_pixel_label =
nullptr;
159 OptixProgramGroup pg_hit_direct =
nullptr;
160 OptixProgramGroup pg_hit_diffuse =
nullptr;
161 OptixProgramGroup pg_hit_camera =
nullptr;
162 OptixProgramGroup pg_hit_pixel_label =
nullptr;
165 OptixTraversableHandle gas_handle = 0;
166 CUdeviceptr d_gas_output = 0;
169 OptixShaderBindingTable sbt = {};
170 CUdeviceptr d_raygen_records = 0;
171 CUdeviceptr d_miss_records = 0;
172 CUdeviceptr d_hitgroup_records= 0;
175 CUdeviceptr d_raygen_record_direct = 0;
176 CUdeviceptr d_raygen_record_diffuse = 0;
177 CUdeviceptr d_raygen_record_camera = 0;
178 CUdeviceptr d_raygen_record_pixel_label = 0;
182 CUdeviceptr d_params = 0;
185 CUdeviceptr d_transform_matrix = 0;
186 CUdeviceptr d_primitive_type = 0;
187 CUdeviceptr d_primitive_positions = 0;
188 CUdeviceptr d_primitiveID = 0;
189 CUdeviceptr d_objectID = 0;
190 CUdeviceptr d_object_subdivisions = 0;
191 CUdeviceptr d_twosided_flag = 0;
192 CUdeviceptr d_primitive_solid_fraction = 0;
195 CUdeviceptr d_patch_vertices = 0;
196 CUdeviceptr d_patch_UUIDs = 0;
197 CUdeviceptr d_triangle_vertices = 0;
198 CUdeviceptr d_triangle_UUIDs = 0;
199 CUdeviceptr d_disk_centers = 0;
200 CUdeviceptr d_disk_radii = 0;
201 CUdeviceptr d_disk_normals = 0;
202 CUdeviceptr d_disk_UUIDs = 0;
203 CUdeviceptr d_tile_vertices = 0;
204 CUdeviceptr d_tile_UUIDs = 0;
205 CUdeviceptr d_voxel_vertices = 0;
206 CUdeviceptr d_voxel_UUIDs = 0;
207 CUdeviceptr d_bbox_vertices = 0;
208 CUdeviceptr d_bbox_UUIDs = 0;
211 CUdeviceptr d_primitive_uuid_arr = 0;
214 CUdeviceptr d_aabbs = 0;
217 CUdeviceptr d_rho = 0;
218 CUdeviceptr d_tau = 0;
219 CUdeviceptr d_rho_cam = 0;
220 CUdeviceptr d_tau_cam = 0;
221 CUdeviceptr d_specular_exponent = 0;
222 CUdeviceptr d_specular_scale = 0;
225 CUdeviceptr d_radiation_in = 0;
226 CUdeviceptr d_radiation_out_top = 0;
227 CUdeviceptr d_radiation_out_bottom = 0;
228 CUdeviceptr d_scatter_buff_top = 0;
229 CUdeviceptr d_scatter_buff_bottom = 0;
230 CUdeviceptr d_radiation_in_camera = 0;
231 CUdeviceptr d_scatter_buff_top_cam = 0;
232 CUdeviceptr d_scatter_buff_bottom_cam= 0;
233 CUdeviceptr d_radiation_specular = 0;
234 CUdeviceptr d_Rsky = 0;
237 CUdeviceptr d_camera_pixel_label = 0;
238 CUdeviceptr d_camera_pixel_depth = 0;
241 CUdeviceptr d_source_positions = 0;
242 CUdeviceptr d_source_rotations = 0;
243 CUdeviceptr d_source_widths = 0;
244 CUdeviceptr d_source_types = 0;
245 CUdeviceptr d_source_fluxes = 0;
246 CUdeviceptr d_source_fluxes_cam = 0;
249 CUdeviceptr d_diffuse_flux = 0;
250 CUdeviceptr d_diffuse_extinction = 0;
251 CUdeviceptr d_diffuse_peak_dir = 0;
252 CUdeviceptr d_diffuse_dist_norm = 0;
253 CUdeviceptr d_sky_radiance_params = 0;
254 CUdeviceptr d_camera_sky_radiance = 0;
255 CUdeviceptr d_solar_disk_radiance = 0;
258 CUdeviceptr d_band_launch_flag = 0;
261 CUdeviceptr d_mask_data = 0;
262 CUdeviceptr d_mask_offsets = 0;
263 CUdeviceptr d_mask_sizes = 0;
264 CUdeviceptr d_mask_IDs = 0;
265 CUdeviceptr d_uv_data = 0;
266 CUdeviceptr d_uv_IDs = 0;
269 bool is_initialized =
false;
270 size_t current_primitive_count = 0;
271 size_t current_patch_count = 0;
272 size_t current_triangle_count = 0;
273 size_t current_disk_count = 0;
274 size_t current_tile_count = 0;
275 size_t current_voxel_count = 0;
276 size_t current_bbox_count = 0;
277 size_t current_source_count = 0;
278 size_t current_band_count = 0;
279 size_t current_camera_count = 0;
280 size_t current_launch_band_count = 0;
281 uint32_t current_camera_launch_id = 0xFFFFFFFFu;
286 void freeCUdeviceptr(CUdeviceptr &ptr);
289 void freeGeometryBuffers();
292 void freeMaterialBuffers();
295 void buildAABBs(
const RayTracingGeometry &geometry);
298 void buildGAS(uint32_t Nprimitives);
304 void uploadLaunchParams();
307 void applyLaunchParams(
const RayTracingLaunchParams ¶ms);
310 void reallocDevice(CUdeviceptr &ptr,
size_t bytes);
313 std::vector<float> downloadFloat(CUdeviceptr ptr,
size_t count)
const;
316 std::vector<uint32_t> downloadUInt32(CUdeviceptr ptr,
size_t count)
const;
319 std::string findDeviceCodeFile()
const;