Blender Git Commit Log

Git Commits -> Revision 1f86434

Revision 1f86434 by Sergey Sharybin (cycles_bvh)
June 10, 2016, 14:13 (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_smooth_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.

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. Current formulation of indices required doing
two level lookup, which destroys cache and leads to poor performance,
causing up to 8% slowdown here. In order to solve this couple of things
were made.

Firstly, added an array to look up global triangle offset directly from
primitive index. This doesn't affect on overall number of textures
because we're getting rid of _-tri_storage anyway.

Secondly, did some types changes to avoid casts which are not really
coming for free.

After doing those tricks it seems slowdown is withing 2% here on my
desktop, but today it behaves flackey and doesn't give totally
consistent results, so need to doublecheck that).

On a positive site we've achived:

- 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. On bunny.blend it's hard to measure
against current master because beefy machine is occupied atm, but
let's put it this way: before this change i was unable to render
full bunny on my machine (and it is on 12gig machine, but remember
beefy machine was reporting 9 gig peak) and now the scene renders just
fine and using 3.3gig.

Commit Details:

Full Hash: 1f86434ff1374e45bdf9e90c2b21867a74d2991b
Parent Commit: 0e393a3
Lines Changed: +114, -144

9 Modified Paths:

/intern/cycles/bvh/bvh.cpp (+17, -46) (Diff)
/intern/cycles/bvh/bvh.h (+2, -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 (+2, -2) (Diff)
/intern/cycles/render/mesh.cpp (+27, -29) (Diff)
/intern/cycles/render/mesh.h (+4, -1) (Diff)
/intern/cycles/render/scene.h (+2, -2) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021