[Bf-blender-cvs] [9ee3235] soc-2013-paint: Fix deadlock from last commit.
Antony Riakiotakis
noreply at git.blender.org
Fri Mar 28 01:07:26 CET 2014
Commit: 9ee32351e9efad3189e8461a9a93314291482a3c
Author: Antony Riakiotakis
Date: Fri Mar 28 02:07:01 2014 +0200
https://developer.blender.org/rB9ee32351e9efad3189e8461a9a93314291482a3c
Fix deadlock from last commit.
This worked fine on debug builds but not on release. Lazy initialization
is forfeit for now until I can figure this out but we do not look for
old tiles anymore, so waiting should be somewhat shorter.
===================================================================
M source/blender/editors/sculpt_paint/paint_image.c
M source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 8576167..1a042e5 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -266,17 +266,9 @@ void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int x_tile,
undo_copy_tile(tile, *tmpibuf, ibuf, COPY);
-
- /* in projective texturing we need to protect this part */
- if (proj)
- BLI_lock_thread(LOCK_CUSTOM1);
-
undo_paint_push_count_alloc(UNDO_PAINT_IMAGE, allocsize);
BLI_addtail(lb, tile);
- if (proj)
- BLI_unlock_thread(LOCK_CUSTOM1);
-
return tile->rect.pt;
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index f660abc..446b32e 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -175,8 +175,6 @@ BLI_INLINE unsigned char f_to_char(const float val)
/* vert flags */
#define PROJ_VERT_CULL 1
-#define TILE_PENDING SET_INT_IN_POINTER(-1)
-
/* This is mainly a convenience struct used so we can keep an array of images we use
* Thir imbufs, etc, in 1 array, When using threads this array is copied for each thread
* because 'partRedrawRect' and 'touch' values would not be thread safe */
@@ -1399,37 +1397,23 @@ static int project_paint_pixel_sizeof(const short tool)
static int project_paint_undo_subtiles(const TileInfo *tinf, int tx, int ty)
{
ProjPaintImage *pjIma = tinf->pjima;
- bool generate_tile = false;
int tile_index = tx + ty * tinf->tile_width;
- /* double check lock + lazy initialization will ensure we do not get waiting on other threads while
- * tile is copied */
- if (UNLIKELY(!pjIma->undoRect[tile_index])) {
-
- if (tinf->threaded)
- BLI_lock_thread(LOCK_CUSTOM1); /* Other threads could be modifying these vars */
-
- if (!pjIma->undoRect[tile_index]) {
- generate_tile = true;
- pjIma->undoRect[tile_index] = TILE_PENDING;
- }
- if (tinf->threaded)
- BLI_unlock_thread(LOCK_CUSTOM1);
-
- }
+ if (tinf->threaded)
+ BLI_lock_thread(LOCK_CUSTOM1); /* Other threads could be modifying these vars */
- if (generate_tile) {
- void *undorect;
+ if (!pjIma->undoRect[tile_index]) {
if (tinf->masked) {
- undorect = image_undo_push_tile(pjIma->ima, pjIma->ibuf, tinf->tmpibuf, tx, ty, &pjIma->maskRect[tile_index], &pjIma->valid[tile_index], true);
+ pjIma->undoRect[tile_index] = image_undo_push_tile(pjIma->ima, pjIma->ibuf, tinf->tmpibuf, tx, ty, &pjIma->maskRect[tile_index], &pjIma->valid[tile_index], true);
}
else {
- undorect = image_undo_push_tile(pjIma->ima, pjIma->ibuf, tinf->tmpibuf, tx, ty, NULL, &pjIma->valid[tile_index], true);
+ pjIma->undoRect[tile_index] = image_undo_push_tile(pjIma->ima, pjIma->ibuf, tinf->tmpibuf, tx, ty, NULL, &pjIma->valid[tile_index], true);
}
pjIma->ibuf->userflags |= IB_BITMAPDIRTY;
- /* all ready, publish */
- pjIma->undoRect[tile_index] = undorect;
}
+
+ if (tinf->threaded)
+ BLI_unlock_thread(LOCK_CUSTOM1);
return tile_index;
}
@@ -1477,10 +1461,6 @@ static ProjPixel *project_paint_uvpixel_init(
BLI_assert(tile_index < (IMAPAINT_TILE_NUMBER(ibuf->x) * IMAPAINT_TILE_NUMBER(ibuf->y)));
BLI_assert(tile_offset < (IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE));
- /* wait for other thread to initialize the tile */
- while (projima->undoRect[tile_index] == TILE_PENDING)
- ;
-
projPixel->valid = projima->valid[tile_index];
if (ibuf->rect_float) {
More information about the Bf-blender-cvs
mailing list