Intel® Embree Documentation
repository·master·Indexed 25 days ago
https://github.com/renderkit/embreeA high-performance ray tracing library optimized for x86 and ARM CPUs and Intel GPUs. It provides optimized kernels for primitive types and acceleration structure construction. Features include support for SYCL on Xe HPC and HPG GPUs, multi-segment motion blur, point queries, collision detection, and SIMD-optimized ray packets. Includes guidance on CMake build configuration, RTCDevice and RTCScene management, and migration from Embree 3 to Embree 4.
What's inside Embree
- Intel® Embree is a high-performance, open-source (Apache 2.0) ray tracing library designed to improve the performance of photo-realistic rendering applications. It is optimized for production rendering with a focus on incoherent ray performance, high-quality acceleration structure construction, accurate primitive intersection, and low memory consumption.
Check Embree platform and CPU compatibility
masterEmbree supports the following platforms and hardware requirements:
CPU Support
- Windows: x86 (32-bit and 64-bit). ARM support is currently experimental.
- Linux: x86 (64-bit) and ARM (64-bit).
- macOS: x86 (64-bit) and ARM (e.g., Apple M1).
- Minimum Requirement: An x86 CPU with SSE2 support or an Apple M1 CPU.
GPU Support
Embree supports Intel GPUs with the following microarchitectures:
- Intel® Arc™ GPU (Xe HPG): Supported on Linux and Windows.
- Intel® Data Center GPU Flex Series and Intel® Data Center GPU Max Series (Xe HPC): Supported on Linux.
Programming Interfaces: ISPC and SYCL
masterEmbree offers specialized interfaces for different programming models:
- Intel® ISPC Interface: Supports applications written with the Intel® Implicit SPMD Program Compiler (ISPC), allowing developers to write renderers that automatically vectorize and leverage SSE, AVX, AVX2, and AVX-512 instructions.
- SYCL Interface: Supports Intel GPUs through the SYCL open standard. This allows developers to write a single-source C++ renderer that executes efficiently on both CPUs and GPUs (specifically Xe HPG and Xe HPC microarchitectures), improving productivity and ensuring consistency.
View projects using Embree
masterEmbree is utilized by various high-fidelity visualization and rendering engines. Notable projects include:
- OSPRay: A ray tracing based rendering engine for high-fidelity visualization.
- Corona Renderer
- FluidRay RT
- SimLab Composer
- Brighter3D: A rendering plugin for SketchUp.
- Visual Designer 3D
- Glise
- Meso Star
- LibThree: 3D visualization tool.
- Bella Renderer
- Autodesk Maya 2014 viewport plugin: Based on the Embree Example Renderer.
If you are using Embree in your product and would like it to be listed, you can contact the support team at
embree_support@intel.com.Implement motion blur for instanced geometry
masterFor multi-segment motion blur on instances, you must:
- Specify the number of time steps using
rtcSetGeometryTimeStepCount. - Provide a transformation for each time step using
rtcSetGeometryTransform.
- Specify the number of time steps using
Manage memory for Embree SYCL with USM shared memory
masterTo share data buffers (like vertex or index buffers) between the host and device, the easiest method is to allocate them as SYCL USM shared memory. This ensures the data is accessible to Embree during ray tracing. Use
sycl::mallocorsycl::aligned_allocwith thesycl::usm::alloc::sharedproperty.void* ptr = sycl::aligned_alloc(16, bytes, queue, sycl::usm::alloc::shared);Implement face-varying interpolation for subdivision meshes
masterTo support face-varying data (like texture coordinates with different topologies), you can bind multiple topologies to a single subdivision mesh:
- Define Topologies: Each topology
irequires its own index buffer (RTC_BUFFER_TYPE_INDEXat buffer sloti) and its own subdivision mode set viartcSetGeometrySubdivisionMode. - Bind Attributes: Use
rtcSetGeometryVertexAttributeTopologyto assign a specific topology to a vertex attribute buffer (RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE) bound at slotj. - Shared Face Buffer: Note that the face buffer (
RTC_BUFFER_TYPE_FACE) is shared across all topologies; then-th primitive always has the same number of vertices for every topology, even if the indices differ.
- Define Topologies: Each topology
Compile Embree with SYCL support on Linux
masterTo enable GPU support via SYCL, you must use either the open source "oneAPI DPC++ Compiler" or the "Intel(R) oneAPI DPC++/C++ Compiler". Other SYCL compilers are not supported.
Using oneAPI DPC++ Compiler (unpacked):
- Set environment variables to point to your unpacked compiler:
export SYCL_BUNDLE_ROOT=path_to_dpcpp_compiler export PATH=$SYCL_BUNDLE_ROOT/bin:$PATH export CPATH=$SYCL_BUNDLE_ROOT/include:$CPATH export LIBRARY_PATH=$SYCL_BUNDLE_ROOT/lib:$LIBRARY_PATH export LD_LIBRARY_PATH=$SYCL_BUNDLE_ROOT/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=$SYCL_BUNDLE_ROOT/linux/lib/x64:$LD_LIBRARY_PATH - Configure and build:
cmake -B build -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DEMBREE_SYCL_SUPPORT=ON cmake --build build -j 8
Using Intel(R) oneAPI DPC++/C++ Compiler (installed):
- Source the environment script:
source /opt/intel/oneAPI/compiler/latest/env/vars.sh - Configure and build:
cmake -B build -DCMAKE_CXX_COMPILER=icpx -DCMAKE_C_COMPILER=icx -DEMBREE_SYCL_SUPPORT=ON cmake --build build -j 8
Note: To run SYCL code on Intel Xe HPG/HPC GPUs, install the latest GPGPU drivers and the
intel-level-zero-gpu-raytracingpackage viaapt.# Example for oneAPI DPC++ Compiler cmake -B build \ -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_C_COMPILER=clang \ -DEMBREE_SYCL_SUPPORT=ON cmake --build build -j 8- Set environment variables to point to your unpacked compiler:
Build Embree SYCL Applications with JIT Compilation
masterFor SYCL applications, use Just-In-Time (JIT) compilation. Add specific flags to the compilation phase for all C++ files containing SYCL code, and add corresponding flags to the linking stage.Manage Embree Geometry objects
masterA
RTCGeometryobject holds the raw data for primitives (e.g., triangle meshes, curves, etc.).Workflow:
- Create a geometry with
rtcNewGeometry. - Bind buffers (e.g., vertex and index buffers) using
rtcSetSharedGeometryBuffer. - Call
rtcCommitGeometryto finalize the geometry data. - Attach the geometry to a scene using
rtcAttachGeometryorrtcAttachGeometryById.
Motion Blur: To support multi-segment motion blur, specify the number of time steps with
rtcSetGeometryTimeStepCount(range 2 to 129) and bind a vertex buffer for each time step. Optionally, define the time range withrtcSetGeometryTimeRange.- Create a geometry with
Compile Embree on Windows
masterTo compile Embree on Windows, use Visual Studio (2017, 2019, or 2022) and CMake 3.1 or higher.
Key Requirements:
- TBB: Embree uses TBB as its tasking system. You can use the TBB version provided with the Intel® Compiler or install it manually and place it in a
tbbfolder in the Embree root. Ensuretbb.dllandtbb_malloc.dllare in yourPATH. - ISPC (Optional): If using Intel® ISPC, ensure it is compatible with your Visual Studio version and add it to your
PATHor setEMBREE_ISPC_EXECUTABLE.
Building via Command Line: Use the Visual Studio command prompt to build:
cd path\to\embree mkdir build cd build cmake -G "Visual Studio 16 2019" .. cmake --build . --config ReleaseBuilding via IDE (cmake-gui):
- Run
cmake-guiand point to the Embree source and build directories. - Click Configure and select your Generator (e.g., "Visual Studio 12 2013 Win64").
- To use Clang instead of MSVC, set the "Optional toolset to use (-T parameter)" to
LLVM_v142. - Click Generate and open
embree4.slnin Visual Studio.
- TBB: Embree uses TBB as its tasking system. You can use the TBB version provided with the Intel® Compiler or install it manually and place it in a
GPU Performance Recommendations for SYCL
masterWhen using Embree with SYCL, follow these best practices for performance:
- Low Code Complexity: Split your renderer into separate kernels instead of using a single "Uber kernel" to avoid spill code generation. Use SYCL specialization constants to enable only required features.
- Feature Flags: Use SYCL specialization constants and feature flags in
rtcIntersect1andrtcOccluded1to JIT compile minimal code. Use JIT caching if compilation times are an issue. - Inline Indirect Calls: Do not attach user geometry or intersection filter callbacks to geometries. Instead, pass the callback function directly through the
RTCIntersectArguments(orRTCOccludedArguments) struct tortcIntersect1(orrtcOccluded1). This allows the SYCL compiler to inline the call. Do not read the function pointer from memory before passing it. - 7-Bit Ray Mask: Use only the lower 7 bits of the ray and geometry mask whenever possible. While Embree supports 32-bit masks, hardware acceleration is optimized for 8-bit masks. Using bits 7-31 requires software intervention and reduces performance. To use 32-bit masks, enable
RTC_FEATURE_FLAG_32_BIT_RAY_MASK. - Motion Blur: For SYCL, keep primitive motion relatively small. If geometry moves fast, place the geometry into an instance and apply motion blur to the instance itself.
// Example of passing an intersection filter directly for SYCL inlining RTC_SYCL_INDIRECTLY_CALLABLE void intersectionFilter( const RTCFilterFunctionNArguments* args ) { /* ... */ } RTCIntersectArguments args; rtcInitIntersectArguments(&args); args.filter = intersectionFilter; rtcIntersect1(scene, &ray, &args);