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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-09-30 22:18:32 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-09-30 22:18:32 +0400
commitb466286c3e0e64860299a4737b9cb13c8fc15618 (patch)
tree8fd9918ecb93eb8ba44eab113360f62efe1f18d6 /source/blender/windowmanager/intern/wm_jobs.c
parent727745bd49592e1b90f0ce9cb78556404ba518ca (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/windowmanager/intern/wm_jobs.c')
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index bef3268920d..9e16ce4082f 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -107,6 +107,7 @@ struct wmJob {
/* internal */
void *owner;
+ int flag;
short suspended, running, ready, do_update, stop;
/* once running, we store this separately */
@@ -123,7 +124,7 @@ struct wmJob {
/* returns current or adds new job, but doesnt run it */
/* every owner only gets a single job, adding a new one will stop running stop and
when stopped it starts the new one */
-wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner)
+wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, int flag)
{
wmJob *steve;
@@ -137,6 +138,7 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner)
BLI_addtail(&wm->jobs, steve);
steve->win= win;
steve->owner= owner;
+ steve->flag= flag;
}
return steve;
@@ -198,20 +200,25 @@ static void *do_job_thread(void *job_v)
}
/* dont allow same startjob to be executed twice */
-static void wm_jobs_test_suspend(wmWindowManager *wm, wmJob *test)
+static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test)
{
wmJob *steve;
+ int suspend= 0;
- for(steve= wm->jobs.first; steve; steve= steve->next)
- if(steve!=test)
- if(steve->running)
- if(steve->startjob==test->startjob)
- break;
-
- if(steve)
- test->suspended= 1;
- else
- test->suspended= 0;
+ for(steve= wm->jobs.first; steve; steve= steve->next) {
+ if(steve==test || !steve->running) continue;
+ if(steve->startjob!=test->startjob && !(test->flag & WM_JOB_EXCL_RENDER)) continue;
+ if((test->flag & WM_JOB_EXCL_RENDER) && !(steve->flag & WM_JOB_EXCL_RENDER)) continue;
+
+ suspend= 1;
+
+ /* if this job has higher priority, stop others */
+ if(test->flag & WM_JOB_PRIORITY)
+ steve->stop= 1;
+ }
+
+ /* possible suspend ourselfs, waiting for other jobs, or de-suspend */
+ test->suspended= suspend;
}
/* if job running, the same owner gave it a new job */
@@ -225,7 +232,7 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve)
else {
if(steve->customdata && steve->startjob) {
- wm_jobs_test_suspend(wm, steve);
+ wm_jobs_test_suspend_stop(wm, steve);
if(steve->suspended==0) {
/* copy to ensure proper free in end */