diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-09-30 22:18:32 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-09-30 22:18:32 +0400 |
commit | b466286c3e0e64860299a4737b9cb13c8fc15618 (patch) | |
tree | 8fd9918ecb93eb8ba44eab113360f62efe1f18d6 /source/blender/editors/space_image/image_draw.c | |
parent | 727745bd49592e1b90f0ce9cb78556404ba518ca (diff) |
Render & Compositing Thread Fixes
* Rendering twice or more could crash layer/pass buttons.
* Compositing would crash while drawing the image.
* Rendering animations could also crash drawing the image.
* Compositing could crash
* Starting to rendering while preview render / compo was
still running could crash.
* Exiting while rendering an animation would not abort the
renderer properly, making Blender seemingly freeze.
* Fixes theoretically possible issue with setting malloc
lock with nested threads.
* Drawing previews inside nodes could crash when those nodes
were being rendered at the same time.
There's more crashes, manipulating the scene data or undo can
still crash, this commit only focuses on making sure the image
buffer and render result access is thread safe.
Implementation:
* Rather than assuming the render result does not get freed
during render, which seems to be quite difficult to do given
that e.g. the compositor is allowed to change the size of
the buffer or output different passes, the render result is
now protected with a read/write mutex.
* The read/write mutex allows multiple readers (and pixel
writers) at the same time, but only allows one writer to
manipulate the data structure.
* Added BKE_image_acquire_ibuf/BKE_image_release_ibuf to access
images being rendered, cases where this is not needed (most
code) can still use BKE_image_get_ibuf.
* The job manager now allows only one rendering job at the same
time, rather than the G.rendering check which was not reliable.
Diffstat (limited to 'source/blender/editors/space_image/image_draw.c')
-rw-r--r-- | source/blender/editors/space_image/image_draw.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index fa736a29ce8..a42fec30c45 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -533,11 +533,14 @@ void draw_image_grease_pencil(bContext *C, short onlyv2d) if (onlyv2d) { /* assume that UI_view2d_ortho(C) has been called... */ SpaceImage *sima= (SpaceImage *)CTX_wm_space_data(C); - ImBuf *ibuf= ED_space_image_buffer(sima); + void *lock; + ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock); /* draw grease-pencil ('image' strokes) */ //if (sima->flag & SI_DISPGP) draw_gpencil_2dimage(C, ibuf); + + ED_space_image_release_buffer(sima, lock); } else { /* assume that UI_view2d_restore(C) has been called... */ @@ -654,6 +657,7 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) ImBuf *ibuf; float zoomx, zoomy; int show_viewer, show_render; + void *lock; /* XXX can we do this in refresh? */ #if 0 @@ -675,11 +679,9 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) } #endif - /* put scene context variable in iuser */ - sima->iuser.scene= scene; /* retrieve the image and information about it */ ima= ED_space_image(sima); - ibuf= ED_space_image_buffer(sima); + ibuf= ED_space_image_acquire_buffer(sima, &lock); ED_space_image_zoom(sima, ar, &zoomx, &zoomy); show_viewer= (ima && ima->source == IMA_SRC_VIEWER); @@ -718,5 +720,7 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) } } #endif + + ED_space_image_release_buffer(sima, lock); } |