Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-11-15 19:59:58 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-11-15 19:59:58 +0400
commit5c6f6301b02a68c6569e14a70b3968a69fa099e7 (patch)
tree2245e539979eb97feb3931639b38bf91061bc5a7 /source/blender/blenkernel/BKE_image.h
parent613cf7ae376b0994c9bd7c57b13123d72831bd3a (diff)
Image thread safe improvements
This commit makes BKE_image_acquire_ibuf referencing result, which means once some area requested for image buffer, it'll be guaranteed this buffer wouldn't be freed by image signal. To de-reference buffer BKE_image_release_ibuf should now always be used. To make referencing working correct we can not rely on result of image_get_ibuf_threadsafe called outside from thread lock. This is so because we need to guarantee getting image buffer from list of loaded buffers and it's referencing happens atomic. Without lock here it is possible that between call of image_get_ibuf_threadsafe and referencing the buffer IMA_SIGNAL_FREE would be called. Image signal handling too is blocking now to prevent such a situation. Threads are locking by spinlock, which are faster than mutexes. There were some slowdown reports in the past about render slowdown when using OSX on Xeon CPU. It shouldn't happen with spin locks, but more tests on different hardware would be really welcome. So far can not see speed regressions on own computers. This commit also removes BKE_image_get_ibuf, because it was not so intuitive when get_ibuf and acquire_ibuf should be used. Thanks to Ton and Brecht for discussion/review :)
Diffstat (limited to 'source/blender/blenkernel/BKE_image.h')
-rw-r--r--source/blender/blenkernel/BKE_image.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 1875fd66628..1f9630d9fce 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -48,6 +48,9 @@ struct Main;
#define IMA_MAX_SPACE 64
+void BKE_images_init(void);
+void BKE_images_exit(void);
+
/* call from library */
void BKE_image_free(struct Image *me);
@@ -133,14 +136,13 @@ enum {
#define IMA_CHAN_FLAG_RGB 2
#define IMA_CHAN_FLAG_ALPHA 4
-/* depending Image type, and (optional) ImageUser setting it returns ibuf */
-/* always call to make signals work */
-struct ImBuf *BKE_image_get_ibuf(struct Image *ima, struct ImageUser *iuser);
+/* checks whether there's an image buffer for given image and user */
+int BKE_image_has_ibuf(struct Image *ima, struct ImageUser *iuser);
/* same as above, but can be used to retrieve images being rendered in
* a thread safe way, always call both acquire and release */
struct ImBuf *BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **lock_r);
-void BKE_image_release_ibuf(struct Image *ima, void *lock);
+void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock);
/* returns a new image or NULL if it can't load */
struct Image *BKE_image_load(const char *filepath);