Commit Graph

81 Commits

Author SHA1 Message Date
Sergey Sharybin
27c1262e21 Fix T44908: Blender crashes when trying to use cycles experimental displacement
The issue was caused by the reshuffle needed to make objects flags have proper
object's bounding box to solve regressions in SSS objects intersecting volumes.

There's actually a feedback loop happening here, which is now solved in quite
naive way -- for the true displacement we consider all objects are capable of
intersecting volumes, synchronize object flags prior to displacement shader
tasks runs and then re-update object flags for proper bounding box.

Not sure what will be the proper solution here, we can't do preliminary check
of intersection for displacement shader, but on the other hand we don't really
need this flag for displacement shader anyway.
2015-06-02 00:04:30 +05:00
Sergey Sharybin
828abaf11c Cycles: Split BVH nodes storage into inner and leaf nodes
This way we can get rid of inefficient memory usage caused by BVH boundbox
part being unused by leaf nodes but still being allocated for them. Doing
such split allows to save 6 of float4 values for QBVH per leaf node and 3
of float4 values for regular BVH per leaf node.

This translates into following memory save using 01.01.01.G rendered
without hair:

                   Device memory size   Device memory peak   Global memory peak
Before the patch:  4957                 5051                 7668
With the patch:    4467                 4562                 7332

The measurements are done against current master. Still need to run speed tests
and it's hard to predict if it's faster or not: on the one hand leaf nodes are
now much more coherent in cache, on the other hand they're not so much coherent
with regular nodes anymore.

Reviewers: brecht, juicyfruit

Subscribers: venomgfx, eyecandy

Differential Revision: https://developer.blender.org/D1236
2015-04-20 17:29:51 +05:00
Sergey Sharybin
cd44449578 Cycles: Synchronize images after building mesh BVH
This way memory overhead caused by the BVH building is not so visible and peak
memory usage will be reduced.

Implementing this idea is not so straightforward actually, because we need to
synchronize images used for true displacement before meshes. Detecting whether
image is used for true displacement is not so striaghtforward, so for now all
all displacement types will synchronize images used for them.

Such change brings memory usage from 4.1G to 4.0G with the 01_01_01_D scene
from gooseberry. With 01_01_01_G scene it's 7.6G vs. 6.8G (before and after
the patch).

Reviewers: campbellbarton, juicyfruit, brecht

Subscribers: eyecandy

Differential Revision: https://developer.blender.org/D1217
2015-04-20 17:29:51 +05:00
Sergey Sharybin
2f5dd83759 Cycles: Add some statistics logging
Covers number of entities in the scene (objects, meshes etc), also reports
sizes of textures being allocated.
2015-04-10 15:37:49 +05:00
Sergey Sharybin
7ea4163e1e Cycles: Fix BVH counter on mesh updates 2015-04-09 22:23:59 +05:00
Sergey Sharybin
cca4405437 Cycles: Fix wrong render result in certain configuration of render layer's surface/hair
There were some synchronization missing in cases when only one of those settings
was disabled.

Also added a render test for such configurations now.
2015-04-09 21:22:48 +05:00
Sergey Sharybin
5ff132182d Cycles: Code cleanup, spaces around keywords
This inconsistency drove me totally crazy, it's really confusing
when it's inconsistent especially when you work on both Cycles and
Blender sides.

Shouldn;t cause merge PITA, it's whitespace changes only, Git should
be able to merge it nicely.
2015-03-28 00:15:15 +05:00
Sergey Sharybin
3d305b5a37 Cycles: Code cleanup, make strict flags happy about disabled OSL 2015-03-27 19:10:36 +05:00
Sergey Sharybin
585dd26120 Cycles: Code cleanup, prepare for strict C++ flags 2015-03-27 18:23:31 +05:00
Sergey Sharybin
a83b2d3fd9 Cycles: Fix wrong attribute count calculation in prevous commit
The workaround for generated texture coordinates is to be done before
calculating number of elements for attribute, otherwise counter wouldn't
include those attributes.
2015-02-15 02:55:18 +05:00
Sergey Sharybin
1862fbf203 Cycles: Optimize memory usage when creating mesh attributes
The idea behind the change is to pre-allocate attribute arrays in advance,
which avoids re-allocation of arrays later for each of meshes being handled.

This reduces peak memory used by Cycles database from 1.3G to 0.9G for
victor.blend from Gooseberry.

It doesn't mean every file will benefit from this change since peak memory
usage is happening in the different places of the rendering code.

Also, unfortunately, attributes export might not cause the peak of render
preparation stage. That said, it's actually object_to_mesh() which causes
the memory to peak in the same test file. So we really need to optimize that
part first in order to get visible results for artists. But in any case it's
now quite easy to track hotspots in Cycles itself which is good.
2015-02-15 02:01:48 +05:00
Sergey Sharybin
cb2007906f Cycles: Use bool for is_lead array
This way we save 3 bytes per BVH node while building BVH, which overall
gives 100Mb memory save when preparing Frank for render.

It's not really much comparing to overall memory usage (which is 11Gb
during scene preparation here) but still doesn't harm to have solved.
2015-01-31 01:49:41 +05:00
Sergey Sharybin
7fd4c440ec Fix T43311: using displacement shader crashes blender
Issue was caused by wrong order of scene device update, which could
lead to missing object flags in shader kernel.

This patch solves a bit more than that making sure objects flags are
always properly updated, so adding/removing volume BSDF will properly
reflect on viewport where camera might become being in volume and so.
2015-01-19 19:23:21 +05:00
Thomas Dinges
ee36e75b85 Cleanup: Fix Cycles Apache header.
This was already mixed a bit, but the dot belongs there.
2014-12-25 02:50:24 +01:00
Sergey Sharybin
0feba652f7 Cycles: Enable QBVH optimization structure for SSE2 CPUs
This commit enables QBVH optimization structure automatically if rendering
with CPU and SSE2 support is detected.

This brings render time of agent shot back to the speed it used to be before
the watertight intersections commit, single koro and sponza scenes are about
7% faster here.
2014-12-25 02:50:49 +05:00
Sergey Sharybin
03f28553ff Cycles: Implement QBVH tree traversal
This commit implements traversal for QBVH tree, which is based on the old loop
code for traversal itself and Embree for node intersection.

This commit also does some changes to the loop inspired by Embree:

- Visibility flags are only checked for primitives.

  Doing visibility check for every node cost quite reasonable amount of time
  and in most cases those checks are true-positive.

  Other idea here would be to do visibility checks for leaf nodes only, but
  this would need to be investigated further.

- For minimum hair width we extend all the nodes' bounding boxes.

  Again doing curve visibility check is quite costly for each of the nodes and
  those checks returns truth for most of the hierarchy anyway.

There are number of possible optimization still, but current state is good
enough in terms it makes rendering faster a little bit after recent watertight
commit.

Currently QBVH is only implemented for CPU with SSE2 support at least. All
other devices would need to be supported later (if that'd make sense from
performance point of view).

The code is enabled for compilation in kernel. but blender wouldn't use it
still.
2014-12-25 02:50:49 +05:00
Sergey Sharybin
80a3f4fecf Cycles: Fix for possibly uninitialized variable
That's rather harmless in the master, just could cause some issues with the patches.
2014-10-17 10:57:19 +02:00
Sergey Sharybin
0fa7e4c853 Cycles: Decouple object flags update to a separate update step
This way there's much less cross-references between objects and meshes
device update functions.

The only thing remained s the object bounds calculation which is needed
by bvh update. This could also be decoupled, but it's not that crucial
yet because its's how it used to be for ages now.
2014-10-03 12:13:41 +02:00
Sergey Sharybin
a654512356 Cycles: Implement preliminary test for volume stack update from SSS
This adds an AABB collision check for objects with volumes and if there's a
collision detected then the object will have SD_OBJECT_INTERSECTS_VOLUME flag.

This solves a speed regression introduced by the fix for T39823 by skipping
volume stack update in cases no volumes intersects the current SSS object.
2014-10-03 10:52:04 +02:00
Sergey Sharybin
7dabfb2048 Cycles: Speedup of kernel side camera-in-volume detection
The idea is to only count intersections with objects which has volumetric shader
and ignore all other objects.

This is probably as fast as we can go without involving some forth level magic.
2014-10-03 12:55:31 +06:00
Sergey Sharybin
faa10d1ced Cycles: optimization of panoramic camera in volume
Now we do much better preliminary check for panoramic camera is inside the
volume object boundings.

Also we're now cacheing the has_volume in the mesh, which makes it unneeded
iterations for each object's shaders.

Should be no functional changes, just faster sync and panoramic-in-volume
rendering.
2014-10-02 20:45:30 +02:00
Martijn Berger
25ec0d97f9 make "tri_shader" an int instead of a float
tri_shader does no longer need to a float.

Reviewers: dingto, sergey

Reviewed By: dingto, sergey

Subscribers: dingto

Projects: #cycles

Differential Revision: https://developer.blender.org/D789
2014-09-24 13:34:28 +02:00
Sergey Sharybin
2a44844870 Fix T41532: Some files bounce back and forth between 'packing BVH nodes' and 'Copying Transforms to Device'
This was originally caused by a6ae12a where i didn't foresee unclear distinguishing
between empty and non-synced meshes will give issues for the viewport. They're the
same for final rendering, but for viewport we need to be accurate here.
2014-08-25 14:05:00 +06:00
Sergey Sharybin
bfaf4f2d0d Fix T41219: Cycles backface detection doesn't work properly
Root of the issue goes back to the on-fly normals commit and the
latest fix for it wasn't actually correct. I've mixed two fixes
in there.

So the idea here goes back to storing negative scaled object flag
and flip runtime-calculated normal if this flag is set, which is
pretty much the same as the original fix for the issue from me.

The issue with motion blur wasn't caused by the rumtime normals
patch and it had issues before, because it already did runtime
normals calculation. Now made it so motion triangles takes the
negative scale flag into account.

This actually makes code more clean imo and avoids rather confusing
flipping code in mesh.cpp.
2014-08-13 16:35:54 +06:00
Sergey Sharybin
eb8f85d8be Fix T41116: Motion Blur causes random black surfaces on rigged models
Fix T41115: Motion Blur renders Objects Black - But not in Viewport Preview

This actually extends previous fix to normals and makes it all much nicer now.

Worth doing some intense testing, quick one worked just fine but there always
could be some corner cases.
2014-07-23 18:01:35 +06:00
Sergey Sharybin
a8233d7c44 Fix T40797: Crash on render on specific file with volumentrics and 'use hair' clicked on render layer 2014-06-28 01:20:07 +06:00
Tamito Kajiyama
0a0e4e0e69 Fix for DeviceScene::attributes_uchar4 not released properly
Reviewed by: dingto
Differential Revision: https://developer.blender.org/D620
2014-06-27 08:56:57 +02:00
Thomas Dinges
0ce3a755f8 Cycles: Add support for uchar4 attributes.
* Added support for uchar4 attributes to Cycles' attribute system.
* This is used for Vertex Colors now, which saves some memory (4 unsigned characters, instead of 4 floats).
* GPU Texture Limit on sm_20 and sm_21 decreased from 95 to 94, because we need a new texture for the uchar4 attributes. This is no problem for sm_30 or newer.

Part of my GSoC 2014.
2014-06-13 23:40:54 +02:00
Thomas Dinges
49df707496 Cycles: Calculate face normal on the fly.
Instead of pre-calculation and storage, we now calculate the face normal during render.
This gives a small slowdown (~1%) but decreases memory usage, which is especially important for GPUs,
where you have limited VRAM.

Part of my GSoC 2014.
2014-06-13 21:59:13 +02:00
19bddbfc54 Fix T40079: cycles crash with objects that have hair motion blur, but no triangle motion. 2014-05-08 15:27:49 +02:00
Campbell Barton
dc13969e48 Style cleanup: indentation, braces 2014-05-05 02:19:08 +10:00
Bastien Montagne
e29698d3cd Split Normals I (5/5): Add support of split normals to Cycles.
Idea and code by Brecht, many thanks!

Reviewers: brecht

Reviewed By: brecht

CC: campbellbarton, dingto

Differential Revision: https://developer.blender.org/D369
2014-04-13 12:51:13 +02:00
27043b8e40 Cycles code internals: add support for mesh voxel grid attributes.
These are internally stored as a 3D image textures, but accessible like e.g.
UV coordinates though the attribute node and getattribute().

This is convenient for rendering e.g. smoke objects where data like density is
really a property of the mesh, and it avoids having to specify the smoke object
in a texture node, instead the material will work with any smoke domain.
2014-03-29 13:03:48 +01:00
e2184c653e Cycles: add support for curve deformation motion blur. 2014-03-29 13:03:47 +01:00
6020d00990 Cycles: add support for mesh deformation motion blur. 2014-03-29 13:03:47 +01:00
8f33538fab Cycles code refactor: add motion sampled normals attribute. 2014-03-29 13:03:46 +01:00
99f5993088 Cycles code refactor: improve vertex motion attribute storage and export.
This now supports multiple steps and subframe sampling of motion.

There is one difference for object and camera transform motion blur. It still
only supports two steps there, but the transforms are now sampled at subframe
times instead of the previous and next frame and then interpolated/extrapolated.
This will give different render results in some cases but it's more accurate.

Part of the code is from the summer of code project by Gavin Howard, but it has
been significantly rewritten and extended.
2014-03-29 13:03:46 +01:00
934767cf7f Cycles code refactor: change curve key to float4 for easier storage as attribute. 2014-03-29 13:03:46 +01:00
0509553b5e Cycles code refactor: changes to make adding new primitive types easier. 2014-03-29 13:03:46 +01:00
24ad7e0bea Cycles code refactor: add support for motion vertex attributes. 2014-03-29 13:03:46 +01:00
9cd2b19999 Cycles Volume Render: generated texture coordinates for volume render.
This does not support staying fixed while the surface deforms, but for static
meshes it should match up with the surface texture coordinates. Implemented
as a matrix transform from objects space to mesh texture space.

Making this work for deforming surfaces would be quite complicated, you might
need something like harmonic coordinates as used in the mesh deform modifier,
probably will not be possible anytime soon.
2013-12-31 17:38:26 +01:00
Brecht Van Lommel
60e5abe71f Fix a few issues reported by coverity scan. 2013-09-03 22:39:21 +00:00
Brecht Van Lommel
b9ce231060 Cycles: relicense GNU GPL source code to Apache version 2.0.
More information in this post:
http://code.blender.org/

Thanks to all contributes for giving their permission!
2013-08-18 14:16:15 +00:00
Brecht Van Lommel
cad3406c81 Fix some unnecessary memory allocation slowness in cycles mesh export. 2013-07-14 12:51:41 +00:00
Thomas Dinges
9e4914e055 Cycles:
* Revert r57203 (len() renaming)
There seems to be a problem with nVidia OpenCL after this and I haven't figured out the real cause yet. 
Better to selectively enable native length() later, after figuring out what's wrong. 

This fixes [#35612].
2013-06-04 17:20:00 +00:00
Thomas Dinges
c5ed6765b9 Cycles / Math functions:
* Rename some math functions:
len -> length
len_squared -> length_squared
normalize_len -> normalize_length

* This way OpenCL uses its inbuilt length() function, rather than our own. The other two functions have been renamed for consistency. 
* Tested CPU, CUDA and OpenCL compile, should be no functional changes.
2013-06-02 20:39:32 +00:00
Brecht Van Lommel
ac849f98f5 Fix #35102: crash with experimental cycles displacement feature due to
uninitialized memory usage.
2013-04-27 02:54:24 +00:00
Brecht Van Lommel
34707c19f2 Fix 34764: cycles issue rendering instanced mesh with NaN coordinates. 2013-04-09 20:48:53 +00:00
Thomas Dinges
cb75d64f7d Cycles:
* Compile fix when building without OSL.
2013-02-14 19:30:25 +00:00
Brecht Van Lommel
adbd84c320 Fix #34121: OSL + persistent images option was not freeing shader memory properly,
causing memory to increase continuously during animation render.
2013-02-14 16:11:47 +00:00