From 89f3837d687c5b685fbea5e7e71242287a735b76 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 6 Feb 2017 12:33:37 +0100 Subject: Displace modifier: Use special version of texture sampling This version will give less spin locks and now well-tested by render engines. This should reduce amount of threading overhead when having multiple objects with displace modifier enabled. In the future this will also help us threading the modifier. There are more modifiers which could benefit from this, but let's first investigate the new behavior with one of them. --- source/blender/modifiers/intern/MOD_displace.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source/blender/modifiers/intern') diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 08d118a2026..48e5d34288d 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -42,6 +42,7 @@ #include "BKE_cdderivedmesh.h" #include "BKE_library.h" #include "BKE_library_query.h" +#include "BKE_image.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_texture.h" @@ -216,6 +217,7 @@ static void displaceModifier_do( float (*vert_clnors)[3] = NULL; float local_mat[4][4]; const bool use_global_direction = dmd->space == MOD_DISP_SPACE_GLOBAL; + struct ImagePool *pool = NULL; if (!dmd->texture && dmd->direction == MOD_DISP_DIR_RGB_XYZ) return; if (dmd->strength == 0.0f) return; @@ -259,6 +261,10 @@ static void displaceModifier_do( copy_m4_m4(local_mat, ob->obmat); } + if (dmd->texture != NULL) { + pool = BKE_image_pool_new(); + } + for (i = 0; i < numVerts; i++) { TexResult texres; float strength = dmd->strength; @@ -272,7 +278,7 @@ static void displaceModifier_do( if (dmd->texture) { texres.nor = NULL; - BKE_texture_get_value(dmd->modifier.scene, dmd->texture, tex_co[i], &texres, false); + BKE_texture_get_value_ex(dmd->modifier.scene, dmd->texture, tex_co[i], &texres, pool, false); delta = texres.tin - dmd->midlevel; } else { @@ -336,6 +342,10 @@ static void displaceModifier_do( } } + if (pool != NULL) { + BKE_image_pool_free(pool); + } + if (tex_co) { MEM_freeN(tex_co); } -- cgit v1.2.3