SQBVH

Discussion related to the implementation of new features & algorithms to the Core Engine.

Moderators: jromang, tomb, zcott, coordinators

SQBVH

Postby Dade » Sun Feb 26, 2012 1:00 pm

It is a while I'm working on an implementation of SQBVH for LuxRender. Today I have obtained the first working rendering.

SBVH has been described in this paper: http://www.nvidia.com/object/nvidia_res ... b_012.html. SBVH is an algorithm involving a different way to build accelerator structures so it is applicable to any BVH (including our SSE hand optimized QBVH). In fact, SQBVH and QBVH share the same traversal core.

Where QBVH uses a single strategy (i.e. object split) to build the BVH, SQBVH uses 2 (object split and space split) and pick the best one. Spatial split is extremely superior in handling triangles with large axis aligned bounding boxes. The result is that SQBVH is as fast as QBVH in the worst case but can be up to 2 time faster or more. The draw back is that the building process is slower and the end result can require slight more memory (i.e. up to a 30%).

This is an example, it is the Sponza model rotate by 45 degree (to not be axis aligned) rendered with QBVH (295 kC/s):

sponza-diagonal-qbvh.png


and rendered with SQBVH (420 kC/s):

sponza-diagonal-sqbvh.png


+42% speed up is even too good to be true :D Keep in mind, this is a best case scenario (and there are sometime subtle bugs that boost performances).

Everything is highly untested and has required far more time than I expected to be implemented (some aspect is very tricky). SQBVH can be used like all other LuxRender accelerator with the name "sqbvh".
User avatar
Dade
Developer
 
Posts: 4798
Joined: Sat Apr 19, 2008 6:04 pm
Location: Italy

Re: SQBVH

Postby SATtva » Sun Feb 26, 2012 1:31 pm

Jesus Christ! :shock: :shock: :shock:

/me deletes his fresh weeklies and quickly resyncs hg...
Linux builds packager
聞くのは一時の恥、聞かぬのは一生の恥
User avatar
SATtva
Developer
 
Posts: 5496
Joined: Tue Apr 07, 2009 12:19 pm
Location: from Siberia with love

Re: SQBVH

Postby Abel » Sun Feb 26, 2012 1:39 pm

Dade wrote:+42% speed up is even too good to be true :D

Unbelievable, great work, I can't wait to test this! :)
User avatar
Abel
Developer
 
Posts: 1414
Joined: Sat Oct 20, 2007 8:13 am
Location: Helsinki, Finland

Re: SQBVH

Postby jensverwiebe » Sun Feb 26, 2012 2:36 pm

Dade, your changes introduced a new nasty crash with QBVH and instanced objects:

Code: Select all
Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000008c5424e80

VM Regions Near 0x8c5424e80:
    CG backing stores      00000001c9749000-00000001c9c30000 [ 5020K] rw-/rw- SM=SHM 
-->
    STACK GUARD            00007fff5bc00000-00007fff5f400000 [ 56.0M] ---/rwx SM=NUL  stack guard for thread 0


Thread 6 Crashed:
0   liblux.dylib                     0x000000010031f69d lux::QBVHAccel::CreateSwizzledLeaf(int, int, unsigned int const*, std::vector<boost::shared_ptr<lux::Primitive>, std::allocator<boost::shared_ptr<lux::Primitive> > > const&) + 349
1   liblux.dylib                     0x000000010031d88c lux::QBVHAccel::QBVHAccel(std::vector<boost::shared_ptr<lux::Primitive>, std::allocator<boost::shared_ptr<lux::Primitive> > > const&, unsigned int, unsigned int, unsigned int) + 1548
2   liblux.dylib                     0x000000010032073e lux::QBVHAccel::CreateAccelerator(std::vector<boost::shared_ptr<lux::Primitive>, std::allocator<boost::shared_ptr<lux::Primitive> > > const&, lux::ParamSet const&) + 302
3   liblux.dylib                     0x00000001001ee983 lux::MakeAccelerator(std::string const&, std::vector<boost::shared_ptr<lux::Primitive>, std::allocator<boost::shared_ptr<lux::Primitive> > > const&, lux::ParamSet const&) + 595
4   liblux.dylib                     0x00000001001d9755 lux::Context::ObjectInstance(std::string const&) + 1333
5   liblux.dylib                     0x00000001001900a2 luxObjectInstance + 50
6   liblux.dylib                     0x00000001001870d8 yyparse() + 472
7   liblux.dylib                     0x0000000100190560 parseFile(char const*) + 192
8   liblux.dylib                     0x00000001001906bb luxParse + 27
9   org.luxrender.luxrender          0x0000000100036e21 0x100000000 + 224801
10  org.luxrender.luxrender          0x000000010004bf17 0x100000000 + 311063
11  org.luxrender.luxrender          0x000000010004be9a 0x100000000 + 310938
12  liblux.dylib                     0x00000001005c80c0 thread_proxy + 160
13  libsystem_c.dylib                0x00007fff975728bf _pthread_start + 335
14  libsystem_c.dylib                0x00007fff97575b75 thread_start + 13



Jens
User avatar
jensverwiebe
Developer
 
Posts: 2124
Joined: Wed Apr 02, 2008 4:34 pm

Re: SQBVH

Postby Dade » Sun Feb 26, 2012 3:31 pm

jensverwiebe wrote:Dade, your changes introduced a new nasty crash with QBVH and instanced objects:


Does it always happen with instances ? Do you have a scene that shows the problem ?
User avatar
Dade
Developer
 
Posts: 4798
Joined: Sat Apr 19, 2008 6:04 pm
Location: Italy

Re: SQBVH

Postby Dade » Sun Feb 26, 2012 4:33 pm

Dade wrote:
jensverwiebe wrote:Dade, your changes introduced a new nasty crash with QBVH and instanced objects:


Does it always happen with instances ? Do you have a scene that shows the problem ?


I should have fixed this problem.

P.S. like I said, the above results are in a best case scenario ;)
User avatar
Dade
Developer
 
Posts: 4798
Joined: Sat Apr 19, 2008 6:04 pm
Location: Italy

Re: SQBVH

Postby bighouse » Sun Feb 26, 2012 11:39 pm

Is plain QVBH supposed to work still? Lux segfaults when I try to use it...

Code: Select all
GNU gdb (Gentoo 7.3.1 p2) 7.3.1
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>...
Reading symbols from /home/bighouse/luxrender/marxbox/lux/luxconsole...done.
(gdb) run -t1 luxtime.lxs
Starting program: /home/bighouse/luxrender/marxbox/lux/luxconsole -t1 luxtime.lxs
[Thread debugging using libthread_db enabled]
[Lux 2012-Feb-26 23:29:43 INFO : 0] Lux version 0.9 (dev) of Feb 26 2012 at 23:12:11
[Lux 2012-Feb-26 23:29:43 INFO : 0] Threads: 1
[New Thread 0x7ffff5a12700 (LWP 3566)]
[Lux 2012-Feb-26 23:29:43 INFO : 0] Loading FreeImage Texture: 'res/wood.jpeg'...
[Lux 2012-Feb-26 23:29:43 INFO : 0] Memory used for imagemap 'res/wood.jpeg': 2644KBytes
[Lux 2012-Feb-26 23:29:43 INFO : 0] Loading FreeImage Texture: 'res/zblatt-bumps.jpeg'...
[Lux 2012-Feb-26 23:29:44 INFO : 0] Memory used for imagemap 'res/zblatt-bumps.jpeg': 6024KBytes
[Lux 2012-Feb-26 23:29:44 INFO : 0] Loading FreeImage Texture: 'res/zblatt-beschr-i.png'...
[Lux 2012-Feb-26 23:29:44 INFO : 0] Memory used for imagemap 'res/zblatt-beschr-i.png': 16384KBytes
[Lux 2012-Feb-26 23:29:44 INFO : 0] Shape #0 (plymesh): Loading PLY mesh file: 'Scene/BandNahtStichBendMesh_0000_m000.ply'...
[Lux 2012-Feb-26 23:29:44 INFO : 0] Shape #0 (plymesh): Mesh: splitting 48 quads
[Lux 2012-Feb-26 23:29:44 INFO : 0] Shape #0 (plymesh): Applying 2 levels of loop subdivision to 112 triangles
[Lux 2012-Feb-26 23:29:44 INFO : 0] Shape #0 (plymesh): Subdivision complete, got 1792 triangles
[Lux 2012-Feb-26 23:29:44 WARNING : 43] Shape #0 (plymesh): Inconsistent shading normals in 4 triangles

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff5a12700 (LWP 3566)]
0x00007ffff7895f66 in boost::shared_ptr<lux::Primitive>::get (this=0x8be1b00)
    at /usr/include/boost-1_46/boost/smart_ptr/shared_ptr.hpp:424
424             return px;
(gdb) bt
#0  0x00007ffff7895f66 in boost::shared_ptr<lux::Primitive>::get (this=0x8be1b00)
    at /usr/include/boost-1_46/boost/smart_ptr/shared_ptr.hpp:424
#1  0x00007ffff7899967 in lux::QBVHAccel::CreateSwizzledLeaf (this=0x88bf20, parentIndex=264, childIndex=3, primsIndexes=0x88bfa0,
    vPrims=std::vector of length 1792, capacity 2048 = {...})
    at /home/bighouse/luxrender/marxbox/lux/accelerators/qbvhaccel.cpp:633
#2  0x00007ffff78997e7 in lux::QBVHAccel::PreSwizzle (this=0x88bf20, nodeIndex=264, primsIndexes=0x88bfa0,
    vPrims=std::vector of length 1792, capacity 2048 = {...})
    at /home/bighouse/luxrender/marxbox/lux/accelerators/qbvhaccel.cpp:612
#3  0x00007ffff7899832 in lux::QBVHAccel::PreSwizzle (this=0x88bf20, nodeIndex=260, primsIndexes=0x88bfa0,
    vPrims=std::vector of length 1792, capacity 2048 = {...})
    at /home/bighouse/luxrender/marxbox/lux/accelerators/qbvhaccel.cpp:614
#4  0x00007ffff7899832 in lux::QBVHAccel::PreSwizzle (this=0x88bf20, nodeIndex=238, primsIndexes=0x88bfa0,
    vPrims=std::vector of length 1792, capacity 2048 = {...})
    at /home/bighouse/luxrender/marxbox/lux/accelerators/qbvhaccel.cpp:614
#5  0x00007ffff7899832 in lux::QBVHAccel::PreSwizzle (this=0x88bf20, nodeIndex=160, primsIndexes=0x88bfa0,
    vPrims=std::vector of length 1792, capacity 2048 = {...})
    at /home/bighouse/luxrender/marxbox/lux/accelerators/qbvhaccel.cpp:614
#6  0x00007ffff7899832 in lux::QBVHAccel::PreSwizzle (this=0x88bf20, nodeIndex=0, primsIndexes=0x88bfa0,
    vPrims=std::vector of length 1792, capacity 2048 = {...})
    at /home/bighouse/luxrender/marxbox/lux/accelerators/qbvhaccel.cpp:614
#7  0x00007ffff7897f8f in lux::QBVHAccel::QBVHAccel (this=0x88bf20, p=std::vector of length 1792, capacity 1792 = {...}, mp=4,
    fst=16, sf=1) at /home/bighouse/luxrender/marxbox/lux/accelerators/qbvhaccel.cpp:332
#8  0x00007ffff789a6dc in lux::QBVHAccel::CreateAccelerator (prims=std::vector of length 1792, capacity 1792 = {...}, ps=...)
    at /home/bighouse/luxrender/marxbox/lux/accelerators/qbvhaccel.cpp:830
#9  0x00007ffff76e9a88 in lux::MakeAccelerator (name="qbvh", prims=std::vector of length 1792, capacity 1792 = {...}, paramSet=...)
    at /home/bighouse/luxrender/marxbox/lux/core/dynload.cpp:213
#10 0x00007ffff76c89cb in lux::Context::ObjectInstance (this=0x7a2bc0, n="BandNahtStichBendMesh_0000_m000")
    at /home/bighouse/luxrender/marxbox/lux/core/context.cpp:820
#11 0x00007ffff766dcdf in luxObjectInstance (name=0x7ffff59dfdd0 "BandNahtStichBendMesh_0000_m000")
    at /home/bighouse/luxrender/marxbox/lux/core/api.cpp:455
#12 0x00007ffff76647b6 in yyparse () at /home/bighouse/luxrender/marxbox/lux/core/luxparse.y:436
#13 0x00007ffff766e15e in parseFile (filename=0x7a75d8 "luxtime.lxs") at /home/bighouse/luxrender/marxbox/lux/core/api.cpp:533
#14 0x00007ffff766e2cc in luxParse (filename=0x7a75d8 "luxtime.lxs") at /home/bighouse/luxrender/marxbox/lux/core/api.cpp:549
#15 0x000000000044674d in engineThread () at /home/bighouse/luxrender/marxbox/lux/console/luxconsole.cpp:65
#16 0x00000000004645d7 in boost::detail::thread_data<void (*)()>::run (this=0x7a7a00)
    at /usr/include/boost-1_46/boost/thread/detail/thread.hpp:61
#17 0x00007ffff6b24ecb in thread_proxy () from /usr/lib64/libboost_thread-mt-1_46.so.1.46.1
#18 0x000000302b007e7c in start_thread () from /lib64/libpthread.so.0
#19 0x000000302a4e9f4d in clone () from /lib64/libc.so.6
(gdb)
bighouse
 
Posts: 22
Joined: Mon Sep 06, 2010 11:48 pm

Re: SQBVH

Postby SATtva » Mon Feb 27, 2012 1:55 am

bighouse wrote:Is plain QVBH supposed to work still? Lux segfaults when I try to use it...

Same here.
Linux builds packager
聞くのは一時の恥、聞かぬのは一生の恥
User avatar
SATtva
Developer
 
Posts: 5496
Joined: Tue Apr 07, 2009 12:19 pm
Location: from Siberia with love

Re: SQBVH

Postby J the Ninja » Mon Feb 27, 2012 2:04 am

SATtva wrote:
bighouse wrote:Is plain QVBH supposed to work still? Lux segfaults when I try to use it...

Same here.


Did you recompile with Dade's fix? IIRC, he pushed it after your weekly went up.

http://src.luxrender.net/lux/rev/927a53da1187
-Jason

Material DB Admin
User avatar
J the Ninja
Developer
 
Posts: 2210
Joined: Wed May 19, 2010 9:54 pm
Location: Portland, USA

Re: SQBVH

Postby SATtva » Mon Feb 27, 2012 2:10 am

Ah, i missed that. Recompiling now.

EDIT: Yes, the problem is fixed now.
Linux builds packager
聞くのは一時の恥、聞かぬのは一生の恥
User avatar
SATtva
Developer
 
Posts: 5496
Joined: Tue Apr 07, 2009 12:19 pm
Location: from Siberia with love

Next

Return to Architecture & Design

Who is online

Users browsing this forum: No registered users and 1 guest