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,
111 const std::vector<float> &camera_diffuse_flux,
112 const std::vector<uint32_t> &band_emission_flag)
override;
122 void getCameraResults(std::vector<float> &pixel_data, std::vector<uint> &pixel_labels,
123 std::vector<float> &pixel_depths,
uint camera_id,
132 const std::vector<float> &radiation_out_bottom)
override;
134 const std::vector<float> &scatter_bottom_cam)
override;
145 OptixDeviceContext optix_context =
nullptr;
146 OptixModule optix_module =
nullptr;
147 OptixPipeline optix_pipeline =
nullptr;
148 CUstream cuda_stream =
nullptr;
151 OptixProgramGroup pg_raygen_direct =
nullptr;
152 OptixProgramGroup pg_raygen_diffuse =
nullptr;
153 OptixProgramGroup pg_raygen_camera =
nullptr;
154 OptixProgramGroup pg_raygen_pixel_label =
nullptr;
156 OptixProgramGroup pg_miss_direct =
nullptr;
157 OptixProgramGroup pg_miss_diffuse =
nullptr;
158 OptixProgramGroup pg_miss_camera =
nullptr;
159 OptixProgramGroup pg_miss_pixel_label =
nullptr;
161 OptixProgramGroup pg_hit_direct =
nullptr;
162 OptixProgramGroup pg_hit_diffuse =
nullptr;
163 OptixProgramGroup pg_hit_camera =
nullptr;
164 OptixProgramGroup pg_hit_pixel_label =
nullptr;
167 OptixTraversableHandle gas_handle = 0;
168 CUdeviceptr d_gas_output = 0;
171 OptixShaderBindingTable sbt = {};
172 CUdeviceptr d_raygen_records = 0;
173 CUdeviceptr d_miss_records = 0;
174 CUdeviceptr d_hitgroup_records= 0;
177 CUdeviceptr d_raygen_record_direct = 0;
178 CUdeviceptr d_raygen_record_diffuse = 0;
179 CUdeviceptr d_raygen_record_camera = 0;
180 CUdeviceptr d_raygen_record_pixel_label = 0;
184 CUdeviceptr d_params = 0;
187 CUdeviceptr d_transform_matrix = 0;
188 CUdeviceptr d_primitive_type = 0;
189 CUdeviceptr d_primitive_positions = 0;
190 CUdeviceptr d_primitiveID = 0;
191 CUdeviceptr d_objectID = 0;
192 CUdeviceptr d_object_subdivisions = 0;
193 CUdeviceptr d_twosided_flag = 0;
194 CUdeviceptr d_primitive_solid_fraction = 0;
197 CUdeviceptr d_patch_vertices = 0;
198 CUdeviceptr d_patch_UUIDs = 0;
199 CUdeviceptr d_triangle_vertices = 0;
200 CUdeviceptr d_triangle_UUIDs = 0;
201 CUdeviceptr d_disk_centers = 0;
202 CUdeviceptr d_disk_radii = 0;
203 CUdeviceptr d_disk_normals = 0;
204 CUdeviceptr d_disk_UUIDs = 0;
205 CUdeviceptr d_tile_vertices = 0;
206 CUdeviceptr d_tile_UUIDs = 0;
207 CUdeviceptr d_voxel_vertices = 0;
208 CUdeviceptr d_voxel_UUIDs = 0;
209 CUdeviceptr d_bbox_vertices = 0;
210 CUdeviceptr d_bbox_UUIDs = 0;
213 CUdeviceptr d_primitive_uuid_arr = 0;
216 CUdeviceptr d_aabbs = 0;
219 CUdeviceptr d_rho = 0;
220 CUdeviceptr d_tau = 0;
221 CUdeviceptr d_rho_cam = 0;
222 CUdeviceptr d_tau_cam = 0;
223 CUdeviceptr d_specular_exponent = 0;
224 CUdeviceptr d_specular_scale = 0;
225 CUdeviceptr d_glass_n = 0;
226 CUdeviceptr d_glass_KL = 0;
227 CUdeviceptr d_is_glass = 0;
230 CUdeviceptr d_radiation_in = 0;
231 CUdeviceptr d_radiation_out_top = 0;
232 CUdeviceptr d_radiation_out_bottom = 0;
233 CUdeviceptr d_scatter_buff_top = 0;
234 CUdeviceptr d_scatter_buff_bottom = 0;
235 CUdeviceptr d_radiation_in_camera = 0;
236 CUdeviceptr d_scatter_buff_top_cam = 0;
237 CUdeviceptr d_scatter_buff_bottom_cam= 0;
238 CUdeviceptr d_radiation_specular = 0;
239 CUdeviceptr d_Rsky = 0;
242 CUdeviceptr d_camera_pixel_label = 0;
243 CUdeviceptr d_camera_pixel_depth = 0;
246 CUdeviceptr d_source_positions = 0;
247 CUdeviceptr d_source_rotations = 0;
248 CUdeviceptr d_source_widths = 0;
249 CUdeviceptr d_source_types = 0;
250 CUdeviceptr d_source_fluxes = 0;
251 CUdeviceptr d_source_fluxes_cam = 0;
254 CUdeviceptr d_diffuse_flux = 0;
255 CUdeviceptr d_diffuse_extinction = 0;
256 CUdeviceptr d_diffuse_peak_dir = 0;
257 CUdeviceptr d_diffuse_dist_norm = 0;
258 CUdeviceptr d_sky_radiance_params = 0;
259 CUdeviceptr d_camera_sky_radiance = 0;
260 CUdeviceptr d_solar_disk_radiance = 0;
261 CUdeviceptr d_camera_diffuse_flux = 0;
262 CUdeviceptr d_band_emission_flag = 0;
265 CUdeviceptr d_band_launch_flag = 0;
268 CUdeviceptr d_mask_data = 0;
269 CUdeviceptr d_mask_offsets = 0;
270 CUdeviceptr d_mask_sizes = 0;
271 CUdeviceptr d_mask_IDs = 0;
272 CUdeviceptr d_uv_data = 0;
273 CUdeviceptr d_uv_IDs = 0;
276 bool is_initialized =
false;
277 size_t current_primitive_count = 0;
278 size_t current_patch_count = 0;
279 size_t current_triangle_count = 0;
280 size_t current_disk_count = 0;
281 size_t current_tile_count = 0;
282 size_t current_voxel_count = 0;
283 size_t current_bbox_count = 0;
284 size_t current_source_count = 0;
285 size_t current_band_count = 0;
286 size_t current_camera_count = 0;
287 size_t current_launch_band_count = 0;
288 uint32_t current_camera_launch_id = 0xFFFFFFFFu;
293 void freeCUdeviceptr(CUdeviceptr &ptr);
296 void freeGeometryBuffers();
299 void freeMaterialBuffers();
302 void buildAABBs(
const RayTracingGeometry &geometry);
305 void buildGAS(uint32_t Nprimitives);
311 void uploadLaunchParams();
314 void applyLaunchParams(
const RayTracingLaunchParams ¶ms);
317 void reallocDevice(CUdeviceptr &ptr,
size_t bytes);
320 std::vector<float> downloadFloat(CUdeviceptr ptr,
size_t count)
const;
323 std::vector<uint32_t> downloadUInt32(CUdeviceptr ptr,
size_t count)
const;
326 std::string findDeviceCodeFile()
const;