embree3 0.4.0

Safe Rust bindings to Embree 3.13.5, Intel's high-performance ray-tracing kernels.
Documentation

embree3

Rust bindings to Embree, Intel's high-performance ray-tracing kernels. Targets Embree 3.13.5.

This is a fork of Twinklebear/embree-rs (originally by Will Usher), reworking the unsafe FFI layer for memory safety: heap-owned callback closures reached through a lock-free per-geometry callback table, a GeometryBuilder/Geometry typestate that enforces embree's "modify only what you uniquely own" rule, and a typed, zero-copy buffer API.

CI

First public release. The core Embree 3 API is wrapped behind a safe, tested interface and is usable today. It is pre-1.0, so the API may still change between minor releases, and some Embree functions are not yet wrapped.

Features

  • Safe, capturing callbacks: user-geometry intersect/occluded, filter, bounds, displacement, and progress callbacks take ordinary Rust closures, bridged to Embree with no leaks or use-after-free.
  • Single, packet, and stream ray queries: intersect/occluded, the {4,8,16}-wide packet variants with a typed, 16-byte-aligned ValidMaskN, and the stream APIs; per-ray context extensions are recoverable inside callbacks.
  • User geometry with ergonomic lane iteration (for_each_active_lane) and an unchecked fast path for hot filter loops.
  • Standalone BVH builder (Device::create_bvh, Bvh::build_scoped): bring-your-own node layout over rtcBuildBVH, with handles confined to the build scope.
  • Scene-vs-scene collision (Scene::collide) for broad-phase candidate pairs.
  • Typed, zero-copy buffers across Embree-managed, geometry-local, and shared host memory.

Building

The build links the native embree3 library, so it needs EMBREE_DIR pointing at an Embree 3.13.5 install (a directory containing lib/):

wget https://github.com/embree/embree/releases/download/v3.13.5/embree-3.13.5.x86_64.linux.tar.gz
tar -xf embree-3.13.5.x86_64.linux.tar.gz
export EMBREE_DIR="$PWD/embree-3.13.5.x86_64.linux/"
export LD_LIBRARY_PATH="$EMBREE_DIR/lib:$LD_LIBRARY_PATH"

cargo build
cargo test

Documentation

Build the API docs locally with cargo doc --open. Embree's own API reference is here, and examples/ has sample applications using the bindings.

License

MIT - see LICENSE.md. The native Embree library is licensed separately (Apache-2.0) by Intel.