Blender Git Loki

Git Commits -> Revision 17e7454

Revision 17e7454 by Sergey Sharybin (master)
July 7, 2016, 15:25 (GMT)
Cycles: Reduce memory usage by de-duplicating triangle storage

There are several internal changes for this:

First idea is to make __tri_verts to behave similar to __tri_storage,
meaning, __tri_verts array now contains all vertices of all triangles
instead of just mesh vertices. This saves some lookup when reading
triangle coordinates in functions like triangle_normal().

In order to make it efficient needed to store global triangle offset
somewhere. So no __tri_vindex.w contains a global triangle index which
can be used to read triangle vertices.

Additionally, the order of vertices in that array is aligned with
primitives from BVH. This is needed to keep cache as much coherent as
possible for BVH traversal. This causes some extra tricks needed to
fill the array in and deal with True Displacement but those trickery
is fully required to prevent noticeable slowdown.

Next idea was to use this __tri_verts instead of __tri_storage in
intersection code. Unfortunately, this is quite tricky to do without
noticeable speed loss. Mainly this loss is caused by extra lookup
happening to access vertex coordinate.

Fortunately, tricks here and there (i,e, some types changes to avoid
casts which are not really coming for free) reduces those losses to
an acceptable level. So now they are within couple of percent only,

On a positive site we've achieved:

- Few percent of memory save with triangle-only scenes. Actual save
in this case is close to size of all vertices.

On a more fine-subdivided scenes this benefit might become more
obvious.

- Huge memory save of hairy scenes. For example, on koro.blend
there is about 20% memory save. Similar figure for bunny.blend.

This memory save was the main goal of this commit to move forward
with Hair BVH which required more memory per BVH node. So while
this sounds exciting, this memory optimization will become invisible
by upcoming Hair BVH work.

But again on a positive side, we can add an option to NOT use Hair
BVH and then we'll have same-ish render times as we've got currently
but will have this 20% memory benefit on hairy scenes.

Commit Details:

Full Hash: 17e745426375fe76f5011992d582c01b682d348b
Parent Commit: 1eacbf4
Lines Changed: +275, -176

9 Modified Paths:

/intern/cycles/bvh/bvh.cpp (+53, -35) (Diff)
/intern/cycles/bvh/bvh.h (+5, -3) (Diff)
/intern/cycles/kernel/geom/geom_motion_triangle.h (+16, -16) (Diff)
/intern/cycles/kernel/geom/geom_triangle.h (+28, -33) (Diff)
/intern/cycles/kernel/geom/geom_triangle_intersect.h (+16, -12) (Diff)
/intern/cycles/kernel/kernel_textures.h (+3, -3) (Diff)
/intern/cycles/render/mesh.cpp (+116, -65) (Diff)
/intern/cycles/render/mesh.h (+35, -6) (Diff)
/intern/cycles/render/scene.h (+3, -3) (Diff)
Tehnyt: Miika HämäläinenViimeksi päivitetty: 07.11.2014 14:18MiikaH:n Sivut a.k.a. MiikaHweb | 2003-2021