diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-11-25 15:38:12 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-11-25 15:43:44 +0300 |
commit | 415b5a43690b3b823506871335281df717309f72 (patch) | |
tree | e3d063ad4a9071a0e44ab3d34423dee7ff66be4d /source/blender/render | |
parent | 328208a6a646448246f002a2aa144633c67197e7 (diff) |
Fix T46646: Point Cloud Density crashes on real time rendering
The issue was caused by possible use of object->derivedFinal from the render
thread, The patch tries to eliminate (or at least minimize, huh) amount of
access to the derivedFinal of a source object. It's still possible that in
the case of particle source derived mesh will be still unsafely used, but
with the patch applied we can easily change runtime part of the code and
cache derived mesh on the preparation stage.
Some ideas for the future:
- Check whether cache() was called on the point density node when calling
calc().
- Cache derivedMesh in the runtime part of point density node to avoid
possible remained thread conflicts.
- NULL the runtime part of the node on .blend load
Reviewers: campbellbarton, plasmasolutions
Reviewed By: plasmasolutions
Differential Revision: https://developer.blender.org/D1614
Diffstat (limited to 'source/blender/render')
-rw-r--r-- | source/blender/render/extern/include/RE_render_ext.h | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/pointdensity.c | 25 |
2 files changed, 24 insertions, 5 deletions
diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h index 85a9dc9fccd..81d1a00702d 100644 --- a/source/blender/render/extern/include/RE_render_ext.h +++ b/source/blender/render/extern/include/RE_render_ext.h @@ -63,6 +63,10 @@ void RE_sample_material_color( struct PointDensity; +void RE_cache_point_density(struct Scene *scene, + struct PointDensity *pd, + const bool use_render_params); + void RE_sample_point_density(struct Scene *scene, struct PointDensity *pd, const int resolution, diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 9b58bde730a..4028d80fd86 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -715,6 +715,21 @@ static void particle_system_minmax(Scene *scene, } } +void RE_cache_point_density(Scene *scene, + PointDensity *pd, + const bool use_render_params) +{ + float mat[4][4]; + /* Same matricies/resolution as dupli_render_particle_set(). */ + unit_m4(mat); + BLI_mutex_lock(&sample_mutex); + cache_pointdensity_ex(scene, pd, mat, mat, 1, 1, use_render_params); + BLI_mutex_unlock(&sample_mutex); +} + +/* NOTE 1: Requires RE_cache_point_density() to be called first. + * NOTE 2: Frees point density structure after sampling. + */ void RE_sample_point_density(Scene *scene, PointDensity *pd, const int resolution, @@ -724,7 +739,11 @@ void RE_sample_point_density(Scene *scene, const size_t resolution2 = resolution * resolution; Object *object = pd->object; size_t x, y, z; - float min[3], max[3], dim[3], mat[4][4]; + float min[3], max[3], dim[3]; + + /* TODO(sergey): Implement some sort of assert() that point density + * was cached already. + */ if (object == NULL) { sample_dummy_point_density(resolution, values); @@ -766,11 +785,7 @@ void RE_sample_point_density(Scene *scene, return; } - /* Same matricies/resolution as dupli_render_particle_set(). */ - unit_m4(mat); - BLI_mutex_lock(&sample_mutex); - cache_pointdensity_ex(scene, pd, mat, mat, 1, 1, use_render_params); for (z = 0; z < resolution; ++z) { for (y = 0; y < resolution; ++y) { for (x = 0; x < resolution; ++x) { |