1.3.77
 
Loading...
Searching...
No Matches
OptiX8LaunchParams.h
Go to the documentation of this file.
1
16#ifndef OPTIX8_LAUNCH_PARAMS_H
17#define OPTIX8_LAUNCH_PARAMS_H
18
19// This header is included by both host (.cpp) and device (.cu) code.
20// Only use types compatible with both CUDA and C++.
21#include <stdint.h>
22
23// CUDA vector types (float3, float2, int2, float4, ...) - available in both host and device contexts
24#include <vector_types.h>
25
26// OptiX traversable handle type (host and device)
27#include <optix.h>
28
29#ifndef M_PI
30#define M_PI 3.14159265358979323846f
31#endif
32
33typedef unsigned int uint;
34
35// Maximum number of radiation bands that may be launched together. Used to size the
36// per-band translucent-cover transmittance accumulator in the payload (the payload lives in a
37// per-thread pool, not registers, so this array adds no register pressure). The host validates
38// that the launch band count does not exceed this cap (fail-fast) before launching.
39#ifndef HELIOS_MAX_RADIATION_BANDS
40#define HELIOS_MAX_RADIATION_BANDS 32
41#endif
42
43// ---------------------------------------------------------------------------
44// Per-ray payload. Passed by pointer-in-two-registers.
45// Allocated in a per-thread pool on the device.
46// ---------------------------------------------------------------------------
47struct PerRayData {
48 double strength;
50 bool face;
51 uint seed;
52 unsigned char source_ID;
53 bool hit_periodic_boundary;
54 float3 periodic_hit;
58 float cover_transmittance[HELIOS_MAX_RADIATION_BANDS];
59};
60
61// ---------------------------------------------------------------------------
62// SBT hit-group record data (per primitive type).
63// ---------------------------------------------------------------------------
65 float3* vertices;
66 uint32_t* UUIDs;
67 uint32_t prim_type;
68};
69
70// ---------------------------------------------------------------------------
71// Main launch parameters structure.
72// Passed from host to device via optixLaunch(d_params, ...).
73// Accessible on device as: extern "C" __constant__ OptiX8LaunchParams params;
74// ---------------------------------------------------------------------------
76 // Traversal handle
77 OptixTraversableHandle traversable;
78
79 // ---- Per-ray-data pool (size = launch_dim_x * launch_dim_y) ----
80 PerRayData* prd_pool;
81
82 // ---- Geometry buffers (device pointers) ----
84 uint32_t* primitive_type;
86 uint32_t* primitiveID;
87 uint32_t* objectID;
89 int8_t* twosided_flag;
90 float* primitive_solid_fraction;
91
92 // ---- Global UUID lookup (indexed by global primitive position) ----
93 uint32_t* primitive_uuid;
94
95 // ---- Per-type geometry (also in SBT HitGroupData, mirrored here for easy access) ----
97 uint32_t* patch_UUIDs;
99 uint32_t* triangle_UUIDs;
100 float3* disk_centers;
101 float* disk_radii;
102 float3* disk_normals;
103 uint32_t* disk_UUIDs;
105 uint32_t* tile_UUIDs;
107 uint32_t* voxel_UUIDs;
109 uint32_t* bbox_UUIDs;
110
111 // ---- Material buffers ----
112 float* rho;
113 float* tau;
114 float* rho_cam;
115 float* tau_cam;
116 float* specular_exponent;
117 float* specular_scale;
118
119 // ---- Translucent cover (glass/plastic) material buffers (same layout as rho/tau) ----
120 float* glass_n;
121 float* glass_KL;
122 int8_t* is_glass;
123
124 // ---- Radiation energy buffers ----
132 float* scatter_buff_bottom_cam;
134 float* Rsky;
135
136 // ---- Camera output buffers ----
137 uint32_t* camera_pixel_label;
138 float* camera_pixel_depth;
139
140 // ---- Source buffers ----
141 float3* source_positions;
142 float3* source_rotations;
143 float2* source_widths;
144 uint32_t* source_types;
147
148 // ---- Diffuse/sky buffers ----
158
159 // ---- Band launch flags ----
161
162 // ---- Texture/mask buffers ----
163 uint8_t* mask_data;
164 uint32_t* mask_offsets;
165 int32_t* mask_sizes;
166 int32_t* mask_IDs;
167 float2* uv_data;
168 int32_t* uv_IDs;
169
170 // ---- Scalar parameters ----
171 uint32_t Nprimitives;
172 uint32_t Nsources;
173 uint32_t Ncameras;
174 uint32_t Nbands_global;
175 uint32_t Nbands_launch;
176 uint32_t launch_offset;
177 uint32_t launch_count;
178 uint32_t rays_per_primitive;
179 uint32_t random_seed;
180 uint32_t launch_face;
181 uint32_t scattering_iteration;
182 uint32_t specular_reflection_enabled;
183 uint32_t camera_ID;
184 uint32_t bbox_UUID_base;
185
187 float3 sun_direction;
188 float solar_disk_cos_angle;
190 float3 camera_position;
191 float camera_lens_diameter;
192 float camera_focal_length;
193 float FOV_aspect_ratio;
194 float camera_HFOV;
195 int2 camera_resolution;
196 float camera_viewplane_length;
197 float camera_pixel_solid_angle;
198 int2 camera_pixel_offset;
199 int2 camera_resolution_full;
200
201 // ---- Launch grid ----
202 uint32_t launch_dim_x;
203 uint32_t launch_dim_y;
204};
205
206// ---------------------------------------------------------------------------
207// Helper: pack/unpack 64-bit pointer into two 32-bit OptiX payload registers
208// Device-only (requires OptiX device header)
209// ---------------------------------------------------------------------------
210#ifdef __CUDACC__
211static __forceinline__ __device__ void packPointer(void *ptr, uint32_t &u0, uint32_t &u1) {
212 const uint64_t uptr = reinterpret_cast<uint64_t>(ptr);
213 u0 = static_cast<uint32_t>(uptr >> 32);
214 u1 = static_cast<uint32_t>(uptr & 0xFFFFFFFFULL);
215}
216
217static __forceinline__ __device__ void *unpackPointer(uint32_t u0, uint32_t u1) {
218 const uint64_t uptr = (static_cast<uint64_t>(u0) << 32) | static_cast<uint64_t>(u1);
219 return reinterpret_cast<void *>(uptr);
220}
221
222static __forceinline__ __device__ PerRayData *getPayloadPRD() {
223 const uint32_t u0 = optixGetPayload_0();
224 const uint32_t u1 = optixGetPayload_1();
225 return reinterpret_cast<PerRayData *>(unpackPointer(u0, u1));
226}
227#endif // __CUDACC__
228
229#endif // OPTIX8_LAUNCH_PARAMS_H