Embree for GPU

Hi, I try to build your branch on Linux and got error:

   [ 14%] Building CXX object intern/cycles/bvh/CMakeFiles/cycles_bvh.dir/bvh_embree.cpp.o
cc1plus: warning: ‘-Werror=’ argument ‘-Werror=implicit-function-declaration’ is not valid for C++
In file included from /home/pepo/blender-git/blender/intern/cycles/bvh/bvh_embree.cpp:57:
/home/pepo/blender-git/blender/intern/cycles/bvh/bvh_embree_converter.h:62:50: error: ‘BVHPrimitive’ does not name a type
   62 |   BVHNode* createLeaf(unsigned int nbPrim, const BVHPrimitive prims[]);
      |                                                  ^~~~~~~~~~~~
/home/pepo/blender-git/blender/intern/cycles/bvh/bvh_embree_converter.h:64:51: error: ‘BVHPrimitive’ does not name a type
   64 |   BVHNode *createCurve(unsigned int nbPrim, const BVHPrimitive prims[]);
      |                                                   ^~~~~~~~~~~~
In file included from /home/pepo/blender-git/blender/intern/cycles/bvh/bvh_embree.cpp:42:
/home/pepo/blender-git/blender/intern/cycles/bvh/../bvh/bvh_embree.h: In constructor ‘ccl::BVHEmbree::BVHEmbree(const ccl::BVHParams&, const ccl::vector<ccl::Object*>&)’:
/home/pepo/blender-git/blender/intern/cycles/bvh/../bvh/bvh_embree.h:68:13: warning: ‘ccl::BVHEmbree::bvh_layout’ will be initialized after [-Wreorder]
   68 |   BVHLayout bvh_layout;
      |             ^~~~~~~~~~
/home/pepo/blender-git/blender/intern/cycles/bvh/bvh_embree.cpp:300:25: warning:   base ‘ccl::BVH2’ [-Wreorder]
  300 |       dynamic_scene(true)
      |                         ^
/home/pepo/blender-git/blender/intern/cycles/bvh/bvh_embree.cpp:289:1: warning:   when initialized here [-Wreorder]
  289 | BVHEmbree::BVHEmbree(const BVHParams &params_, const vector<Object *> &objects_)
      | ^~~~~~~~~
make[2]: *** [intern/cycles/bvh/CMakeFiles/cycles_bvh.dir/build.make:141: intern/cycles/bvh/CMakeFiles/cycles_bvh.dir/bvh_embree.cpp.o] Fehler 1
make[1]: *** [CMakeFiles/Makefile2:1066: intern/cycles/bvh/CMakeFiles/cycles_bvh.dir/all] Fehler 2
make: *** [Makefile:163: all] Fehler 2

I build Embree by myself as install_deps.sh --build or --force-embree does nothing.
May you can look in to.

Thanks, mib

Did you compile the updated version of Embree ? (availible here github.com/tinou98/embree)
If so, check that it is this version that is used while building blender (you can check in CMake that EMBREE_INCLUDE_DIR point to the right install folder, this variable is only visible in advanced mode).

It is weird that install_deps.sh does nothing. Can you try with ./build_files/build_environment/install_deps.sh --with-embree --build-embree --force-embree

Depending on your OS, it is possible that install_deps used your package manager to install Embree.

Hi and thank you for fast reply.
I will check today on my Opensuse system.
Btw. I use Linux as my main system and tests with the Windows build from Graphicall result often with crash. (https://blender.community/c/graphicall/ddbbbc/)
Where should I report these crashes?

Cheers, mib
EDIT: Noticed Graphicall build is from 2019-07-27, poke LazyDodo already.

Hi again, I use your updated (patched?) version and got it to build.
Testing now.

Many thanks, mib

You can report your crash here. If the crash is happening on a specific scene, it should be great to have information on the scene. Currently it is “normal” to have crash on scene with motion blur and curves. I’m working on that, and the next commit should fix that part. Apart from that, every crash are abnormal and will need to be fixed.

Hi, got some time to test but it is impossible to open a file in file manager, I have to use drag and drop. I cant select anything in 3D view.
This happens with last build from Graphicall and my own build from latest branch.
They are both not really up to date.

https://blender.community/c/graphicall/ddbbbc/ for example is from 2019-07-27

Can you please update your GSoC branch or provide a build if you find some time.
I can build on Linux but not on Windows.

Cheers, mib

As you mentioned, they are a few bug in the GUI selection. I have no idea why they are here, but if you merge master into the branch before compiling, the bug is gone.

I’m seeing with my mentors if it’s possible to rebase or merge the branch.

With the latest fix, it should not crash anymore (before it could crash on unsupported features)

OK, thank you. I will try to fiddle with Git when I find some time.

Cheers, mib

Hi, tried to rebase today but before I merge I update master and your branch.
If I build your branch without merge I get error:

>     [ 14%] Built target cycles_render
>     [ 14%] Building CXX object intern/cycles/bvh/CMakeFiles/cycles_bvh.dir/bvh_embree_converter.cpp.o
>     cc1plus: warning: ‘-Werror=’ argument ‘-Werror=implicit-function-declaration’ is not valid for C++
>     /home/pepo/blender-git/blender/intern/cycles/bvh/bvh_embree_converter.cpp: In member function ‘ccl::BVHNode* ccl::BVHEmbreeConverter::getBVH4()’:
>     /home/pepo/blender-git/blender/intern/cycles/bvh/bvh_embree_converter.cpp:400:9: error: ‘struct RTCBVHExtractFunction’ has no member named ‘setUnalignedLinearBounds’; did you mean ‘setUnalignedBounds’?
>       400 |   param.setUnalignedLinearBounds = [](void* node, const RTCAffineSpace &affSpace, const RTCBounds &bounds, void* userData) {
>           |         ^~~~~~~~~~~~~~~~~~~~~~~~
>           |         setUnalignedBounds
>     make[2]: *** [intern/cycles/bvh/CMakeFiles/cycles_bvh.dir/build.make:206: intern/cycles/bvh/CMakeFiles/cycles_bvh.dir/bvh_embree_converter.cpp.o] Fehler 1
>     make[1]: *** [CMakeFiles/Makefile2:1066: intern/cycles/bvh/CMakeFiles/cycles_bvh.dir/all] Fehler 2
>     make: *** [Makefile:163: all] Fehler 2

I think I should solve the error in soc-2019-embree-gpu first before merge.
May you look in to.

Cheers, mib

Hello @tinou98 . Could you share some sample scenes where render speed is faster with embree in GPU?.
Thank you.

@mib2berlin I pushed the merged version, selection bug is fixed. But you will need to recompile Embree (from embree repository)

@YAFU Scene with motion blur should render faster. It should be even better with motion blur + hair, but the build step can take a long time. You can take for instance the sample scene provided in the task https://developer.blender.org/T54113, which lead to approximately 10% improvement.

1 Like

OK, got it to build and rebuild Embree.
Crash with setting “Embree, then convert” with this file (125MB):

It is a reduced copy of Blender 2.80 - Spring from https://www.blender.org/download/demo-files/

I have no debug build but here is the backtrace after crash:

(gdb) bt
#0  0x0000000001add642 in ccl::BVH_bvh_intersect_hair(ccl::KernelGlobals*, ccl::Ray const*, ccl::Intersection*, unsig
ned int) ()                                                                                                           
#1  0x0000000001b8cbe7 in ccl::kernel_path_trace(ccl::KernelGlobals*, float*, int, int, int, int, int) ()
#2  0x000000000170c0aa in ccl::CPUDevice::thread_render(ccl::DeviceTask&) ()
#3  0x000000000227fe63 in ccl::TaskScheduler::thread_run(int) ()
#4  0x000000000228189e in ccl::thread::run(void*) ()
#5  0x00007ffff4ef7ec0 in ?? () from /usr/lib64/libstdc++.so.6
#6  0x00007ffff532af2a in start_thread () from /lib64/libpthread.so.0
#7  0x00007ffff52554af in clone () from /lib64/libc.so.6
(gdb)

Opensuse Tumbleweed x86_64
Intel i5 3570K 16 GB RAM
GTX 760 4 GB /Display card
Driver 435.21
Vivaldi 2.9.1675.11 (Official Build) snapshot (64-bit)

Cheers, mib

I was not able to fully render the scene (my pc has not enough RAM) but I fixed a bug that might be related. Can you try again with the latest commit 421159e6

Hi, no crash anymore but render result is not correct.
System starts swapping with embree setting but not with embree, then convert.
May you can provide a Windows build on Blender Artists to get more testers.

embree

embree_convert

Cheers, mib
EDIT: Other files render OK with embree, then convert. Will check other files from b.org.