Page MenuHome

(WIP) Initial Implementation of Embree
AbandonedPublic

Authored by Thomas Dinges (dingto) on Oct 7 2014, 11:51 AM.

Details

Summary

Just posting this here for reference..

Initial implementation of Embree API.

Issues: Too many, but it renders a cube. ;) Also lib path is hardcoded for Mac OS.

Idea: We probably cannot use Embree API for all the features we have in Cycles, but as a reference or even beneficial for simpler scenes (with mostly geometry), like BMW, this might be great. Embree releases new versions every 2-3 months atm, by using the API we can simply upgrade a lib and benefit from the latest improvements.

Diff Detail

Event Timeline

Thomas Dinges (dingto) retitled this revision from to (WIP) Initial Implementation of Embree.
Thomas Dinges (dingto) updated this object.

Missed to include new geom_bvh_embree.h.

Some changes to the scene building function.

Hey Sergey,
maybe you can help me here. :)

There is something wrong with this still, for the default cube a face is missing, and scenes like bmw have severe artefacts. I suspect the prim_index to be wrong / different between our BVH and this.

Anyway, it does not need to be pretty imho, but it would be nice to have a hacky integration working, so we can measure performance in simple scenes like BMW, and compare to our own implementation. Would be interesting to see how big the performance gap is between Embrees QBVH and D819.

We're calculating barycentric coordinates different from Embree, so at least you need to change triangle winding to (2, 0, 1) afair.

intern/cycles/kernel/kernel_shadow.h
70

This doesn't seem to support transparent shadows.

@Sergey Sharybin (sergey): Sorry, not sure what you mean exactly, where does this need to be changed?

Also CC'ing @Brecht Van Lommel (brecht), as he hacked in Embree a while back, maybe he has an idea too. :)

Wherever you pass triangles from Cycles to Embree i bet.

  • Fix some index issues and create Embree class in scene.

This is still not fully working, but I could render a Sky + Suzanne with subsurf 5.
The issue here is, that tri_index and therefore all related data is different between Embree and our own BVH code, so on runtime the lookup might fail. This seems to only fail with more than 1 Object though.

In this simple test though (with current patch), I get a nice speedup with Embree.

Embree off: 21.33 seconds
Embree on: 15.38 seconds

That is a speedup of ~28%. Image looks 100% the same. I need to fix the index issue though, because once I add more objects I get visible errors.

Sergey Sharybin (sergey) requested changes to this revision.Jan 28 2015, 7:18 PM

We talked about this in email actually. The speedup is nice but it really worth studying where the speedup is coming from. For example, if it's because of QBVH (which is already in master), or is it because of more extense intrinsics usage (single ray to multiple triangles intersection), or is it because of smarter approach to shadow rays? or because of using SPMD? It all worth checking on it's own.

I don't really see what we can achieve by using external library and what we can not do with just doing a proper sources port into kernel.

But there's a pile of issues you would never solve by doing such a port. For example, 2x memory usage, much fatter blender and so.

Would really rather see people doing sources port, not the library usage.

P.S. This could be a nice experiment, but would not expect it to be accepted to blender's master.

This revision now requires changes to proceed.Jan 28 2015, 7:18 PM

I agree, and we discussed this already, so can be closed. :)