| 204 | */ |
| 205 | |
| 206 | void castRay(sycl::queue& queue, const RTCTraversable traversable, |
| 207 | float ox, float oy, float oz, |
| 208 | float dx, float dy, float dz, Result* result) |
| 209 | { |
| 210 | queue.submit([=](sycl::handler& cgh) |
| 211 | { |
| 212 | cgh.set_specialization_constant<feature_mask>(required_features); |
| 213 | |
| 214 | cgh.parallel_for(sycl::range<1>(1),[=](sycl::item<1> item, sycl::kernel_handler kh) |
| 215 | { |
| 216 | /* |
| 217 | * The intersect arguments can be used to pass a feature mask, |
| 218 | * which improves performance and JIT compile times on the GPU |
| 219 | */ |
| 220 | RTCIntersectArguments args; |
| 221 | rtcInitIntersectArguments(&args); |
| 222 | |
| 223 | const RTCFeatureFlags features = kh.get_specialization_constant<feature_mask>(); |
| 224 | args.feature_mask = features; |
| 225 | |
| 226 | /* |
| 227 | * The ray hit structure holds both the ray and the hit. |
| 228 | * The user must initialize it properly -- see API documentation |
| 229 | * for rtcIntersect1() for details. |
| 230 | */ |
| 231 | struct RTCRayHit rayhit; |
| 232 | rayhit.ray.org_x = ox; |
| 233 | rayhit.ray.org_y = oy; |
| 234 | rayhit.ray.org_z = oz; |
| 235 | rayhit.ray.dir_x = dx; |
| 236 | rayhit.ray.dir_y = dy; |
| 237 | rayhit.ray.dir_z = dz; |
| 238 | rayhit.ray.tnear = 0; |
| 239 | rayhit.ray.tfar = std::numeric_limits<float>::infinity(); |
| 240 | rayhit.ray.mask = -1; |
| 241 | rayhit.ray.flags = 0; |
| 242 | rayhit.hit.geomID = RTC_INVALID_GEOMETRY_ID; |
| 243 | rayhit.hit.instID[0] = RTC_INVALID_GEOMETRY_ID; |
| 244 | |
| 245 | /* |
| 246 | * There are multiple variants of rtcIntersect. This one |
| 247 | * intersects a single ray with the scene. |
| 248 | */ |
| 249 | rtcTraversableIntersect1(traversable, &rayhit, &args); |
| 250 | |
| 251 | /* |
| 252 | * write hit result to output buffer |
| 253 | */ |
| 254 | result->geomID = rayhit.hit.geomID; |
| 255 | result->primID = rayhit.hit.primID; |
| 256 | result->tfar = rayhit.ray.tfar; |
| 257 | }); |
| 258 | }); |
| 259 | queue.wait_and_throw(); |
| 260 | |
| 261 | printf("%f, %f, %f: ", ox, oy, oz); |
| 262 | if (result->geomID != RTC_INVALID_GEOMETRY_ID) |
| 263 | { |
no test coverage detected