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/makesrna | |
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/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_image.c | 23 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 14 |
2 files changed, 29 insertions, 8 deletions
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 4c2689d4f64..521756b8539 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -84,8 +84,9 @@ static void rna_Image_fields_update(bContext *C, PointerRNA *ptr) { Image *ima= ptr->id.data; ImBuf *ibuf; + void *lock; - ibuf= BKE_image_get_ibuf(ima, NULL); + ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); if(ibuf) { short nr= 0; @@ -96,6 +97,8 @@ static void rna_Image_fields_update(bContext *C, PointerRNA *ptr) if(nr) BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE); } + + BKE_image_release_ibuf(ima, lock); } static void rna_Image_reload_update(bContext *C, PointerRNA *ptr) @@ -157,14 +160,22 @@ static int rna_Image_has_data_get(PointerRNA *ptr) static int rna_Image_depth_get(PointerRNA *ptr) { Image *im= (Image*)ptr->data; - ImBuf *ibuf= BKE_image_get_ibuf(im, NULL); + ImBuf *ibuf; + void *lock; + int depth; + + ibuf= BKE_image_acquire_ibuf(im, NULL, &lock); - if (!ibuf) return 0; + if(!ibuf) + depth= 0; + else if(ibuf->rect_float) + depth= 128; + else + depth= ibuf->depth; - if (ibuf->rect_float) - return 128; + BKE_image_release_ibuf(im, lock); - return ibuf->depth; + return depth; } #else diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index df956670eb3..422283c940f 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -191,7 +191,8 @@ static EnumPropertyItem dc_z_items[] = {DC_RGB, DC_Z, DC_LCMS, DC_ZERO}; static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *C, PointerRNA *ptr, int *free) { SpaceImage *sima= (SpaceImage*)ptr->data; - ImBuf *ibuf= ED_space_image_buffer(sima); + ImBuf *ibuf; + void *lock; int zbuf, alpha; if(C==NULL) { @@ -199,9 +200,13 @@ static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *C, P return dc_all_items; } + ibuf= ED_space_image_acquire_buffer(sima, &lock); + alpha= ibuf && (ibuf->channels == 4); zbuf= ibuf && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels==1)); + ED_space_image_release_buffer(sima, lock); + if(alpha && zbuf) return dc_all_items; else if(alpha) @@ -215,8 +220,13 @@ static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *C, P static void rna_SpaceImageEditor_curves_update(bContext *C, PointerRNA *ptr) { SpaceImage *sima= (SpaceImage*)ptr->data; + ImBuf *ibuf; + void *lock; + + ibuf= ED_space_image_acquire_buffer(sima, &lock); + curvemapping_do_ibuf(sima->cumap, ibuf); + ED_space_image_release_buffer(sima, lock); - curvemapping_do_ibuf(sima->cumap, ED_space_image_buffer(sima)); WM_event_add_notifier(C, NC_IMAGE, sima->image); } |