Intel® Embree Ray Tracing Kernels
Discussion forum on the open source ray tracing kernels for fast photo-realistic rendering on Intel® CPU(s)

embree thread safety


I noticed in the release notes for embree v3.7.0 this feature:

rtcCommitScene can now get called during rendering from multiple threads to lazily build geometry

... combined with next bullet:

Geometries can now get attached to multiple scenes at the same time

Taken together, I'm now confused about the thread safety limitations of the library.

Can geometries from different RTCDevice's co-exist in the same scene? 

Can `rtcNewScene(device)` be safely called from different threads for the same device?

Our current application has separate RTCDevice's for different application threads (with no sharing of RTCGeometry's, tho the underlying vertex data is) due to the lack of clarity around what is thread-safe and what is not.  Are we being overly cautious?




0 Kudos
2 Replies

No, Geometries from different devices cannot co-exist in the same scene.

One app should normally just create one device anyway. Use of multiple devices is supposed to be used when different components of an app use Embree. E.g. if you use a third party library that also builds on Embree, then that library and your app should both use a separate Embree device, such that some device settings to not cause conflicts.

Yes, rtcNewScene can get called from multiple threads.

Yes, you are overly cautious. Just create one device. Modifications to one geometry are not thread safe, but you can modify different geometries, each in a separate thread. Scene modifications are thread safe, thus you can for instance let each thread create some geometry and attach to the same scene in a multi-threaded way.

0 Kudos

Good to know.

In my defense, the docs do say:

In general, API calls that access the same object are not thread-safe, unless specified differently.

... and rtcNewScene() does not specify differently which leads to the path we are currently on.

0 Kudos