[Bf-blender-cvs] [6d973b8] master: Fix T39468

Antony Riakiotakis noreply at git.blender.org
Fri Mar 28 21:02:43 CET 2014


Commit: 6d973b87a6c0351510603b118814618333318321
Author: Antony Riakiotakis
Date:   Fri Mar 28 22:01:26 2014 +0200
https://developer.blender.org/rB6d973b87a6c0351510603b118814618333318321

Fix T39468

Issue is that sampling functions did not pass a thread index to the
texture sampler so all threads were contesting for the same pool.

Paint cursors and sculpting that used openmp for threading suffered from
this. Now use omp_get_thread_num to pass the thread number.

===================================================================

M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/editors/sculpt_paint/paint_intern.h
M	source/blender/editors/sculpt_paint/paint_utils.c
M	source/blender/editors/sculpt_paint/sculpt.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 2c25900..a3e69a1 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -61,6 +61,10 @@
  * removed eventually (TODO) */
 #include "sculpt_intern.h"
 
+#ifdef _OPENMP
+#include <omp.h>
+#endif
+
 /* TODOs:
  *
  * Some of the cursor drawing code is doing non-draw stuff
@@ -245,7 +249,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
 					if (col) {
 						float rgba[4];
 
-						paint_get_tex_pixel_col(mtex, x, y, rgba, pool);
+						paint_get_tex_pixel_col(mtex, x, y, rgba, pool, omp_get_thread_num());
 
 						buffer[index * 4]     = rgba[0] * 255;
 						buffer[index * 4 + 1] = rgba[1] * 255;
@@ -253,7 +257,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
 						buffer[index * 4 + 3] = rgba[3] * 255;
 					}
 					else {
-						float avg = paint_get_tex_pixel(mtex, x, y, pool);
+						float avg = paint_get_tex_pixel(mtex, x, y, pool, omp_get_thread_num());
 
 						avg += br->texture_sample_bias;
 
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 6dd4238..af9ac6d 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -198,8 +198,8 @@ void paint_calc_redraw_planes(float planes[4][4],
                               const struct rcti *screen_rect);
 
 float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius);
-float paint_get_tex_pixel(struct MTex *mtex, float u, float v, struct ImagePool *pool);
-void paint_get_tex_pixel_col(struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool);
+float paint_get_tex_pixel(struct MTex *mtex, float u, float v, struct ImagePool *pool, int thread);
+void paint_get_tex_pixel_col(struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread);
 int imapaint_pick_face(struct ViewContext *vc, const int mval[2], unsigned int *index, unsigned int totface);
 void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]);
 void brush_drawcursor_texpaint_uvsculpt(struct bContext *C, int x, int y, void *customdata);
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index e6efba4..de09709 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -164,26 +164,25 @@ float paint_calc_object_space_radius(ViewContext *vc, const float center[3],
 	return len_v3(delta) / scale;
 }
 
-float paint_get_tex_pixel(MTex *mtex, float u, float v, struct ImagePool *pool)
+float paint_get_tex_pixel(MTex *mtex, float u, float v, struct ImagePool *pool, int thread)
 {
 	float intensity, rgba[4];
 	float co[3] = {u, v, 0.0f};
 
 	externtex(mtex, co, &intensity,
-		                   rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool);
+						   rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool);
 
 	return intensity;
 }
 
-void paint_get_tex_pixel_col(MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool)
+void paint_get_tex_pixel_col(MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread)
 {
 	float co[3] = {u, v, 0.0f};
 	int hasrgb;
 	float intensity;
 
 	hasrgb = externtex(mtex, co, &intensity,
-		                   rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool);
-
+						   rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool);
 	if (!hasrgb) {
 		rgba[0] = intensity;
 		rgba[1] = intensity;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 8bbee49..9dbf76b 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -987,7 +987,7 @@ static float tex_strength(SculptSession *ss, Brush *br,
 			x += br->mtex.ofs[0];
 			y += br->mtex.ofs[1];
 
-			avg = paint_get_tex_pixel(&br->mtex, x, y, ss->tex_pool);
+			avg = paint_get_tex_pixel(&br->mtex, x, y, ss->tex_pool, omp_get_thread_num());
 
 			avg += br->texture_sample_bias;
 		}




More information about the Bf-blender-cvs mailing list