Fluid sim would stop or crash with node editor.

Bug was a real bad one - the code for giving out WM jobs was messed up for long.
It was giving a running fluid job to the compositer even... tsk!

I will go over jobs code carefully next days to see if it all behaves. Now it
allows per owner multiple jobs, provided it has different job_type set.

Also fixed: preview renders (material) were deadslow once a while - caused
by icon render setting miniature tile render sizes. Now it's fast again,
but there are still 3 icon jobs running per UI change... need to check what.
This commit is contained in:
Ton Roosendaal
2012-11-06 15:54:04 +00:00
parent acc8c654fc
commit 7b60529517
3 changed files with 42 additions and 28 deletions

View File

@@ -237,6 +237,14 @@ static int preview_mat_has_sss(Material *mat, bNodeTree *ntree)
return 0;
}
static Scene *preview_get_scene(void)
{
if (pr_main == NULL) return NULL;
return pr_main->scene.first;
}
/* call this with a pointer to initialize preview scene */
/* call this with NULL to restore assigned ID pointers in preview scene */
static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPreview *sp)
@@ -244,9 +252,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
Scene *sce;
Base *base;
if (pr_main == NULL) return NULL;
sce = pr_main->scene.first;
sce = preview_get_scene();
if (sce) {
/* this flag tells render to not execute depsgraph or ipos etc */
@@ -665,8 +671,23 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
char name[32];
int sizex;
/* in case of split preview, use border render */
if (split) {
if (first) sizex = sp->sizex / 2;
else sizex = sp->sizex - sp->sizex / 2;
}
else sizex = sp->sizex;
/* we have to set preview variables first */
sce = preview_get_scene();
if (sce) {
sce->r.xsch = sizex;
sce->r.ysch = sp->sizey;
sce->r.size = 100;
}
/* get the stuff from the builtin preview dbase */
sce = preview_prepare_scene(sp->scene, id, idtype, sp); // XXX sizex
sce = preview_prepare_scene(sp->scene, id, idtype, sp);
if (sce == NULL) return;
if (!split || first) sprintf(name, "Preview %p", sp->owner);
@@ -694,17 +715,6 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
sce->r.mode |= R_OSA;
}
/* in case of split preview, use border render */
if (split) {
if (first) sizex = sp->sizex / 2;
else sizex = sp->sizex - sp->sizex / 2;
}
else sizex = sp->sizex;
/* allocates or re-uses render result */
sce->r.xsch = sizex;
sce->r.ysch = sp->sizey;
sce->r.size = 100;
/* callbacs are cleared on GetRender() */
if (ELEM(sp->pr_method, PR_BUTS_RENDER, PR_NODE_RENDER)) {

View File

@@ -320,9 +320,9 @@ enum {
WM_JOB_SUSPEND = (1 << 3)
};
/* identifying jobs by owner alone is unreliable, this isnt saved, order can change */
/* identifying jobs by owner alone is unreliable, this isnt saved, order can change (keep 0 for 'any') */
enum {
WM_JOB_TYPE_ANY = -1,
WM_JOB_TYPE_ANY = 0,
WM_JOB_TYPE_COMPOSITE,
WM_JOB_TYPE_RENDER,
WM_JOB_TYPE_RENDER_PREVIEW, /* UI preview */

View File

@@ -131,31 +131,34 @@ struct wmJob {
};
/* finds:
* 1st priority: job with same owner and name
* 2nd priority: job with same owner
* if type, compare for it, otherwise any matching job
*/
static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const char *name)
static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type)
{
wmJob *wm_job, *found = NULL;
wmJob *wm_job;
for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next)
if (wm_job->owner == owner) {
found = wm_job;
if (name && strcmp(wm_job->name, name) == 0)
if (job_type) {
if ( wm_job->job_type == job_type)
return wm_job;
}
else
return wm_job;
}
return found;
return NULL;
}
/* ******************* public API ***************** */
/* 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
/* every owner only gets a single job, adding a new one will stop running job and
* when stopped it starts the new one */
wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag, int job_type)
{
wmJob *wm_job = wm_job_find(wm, owner, name);
wmJob *wm_job = wm_job_find(wm, owner, job_type);
if (wm_job == NULL) {
wm_job = MEM_callocN(sizeof(wmJob), "new job");
@@ -167,6 +170,7 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *
wm_job->job_type = job_type;
BLI_strncpy(wm_job->name, name, sizeof(wm_job->name));
}
/* else: a running job, be careful */
return wm_job;
}
@@ -192,7 +196,7 @@ int WM_jobs_test(wmWindowManager *wm, void *owner, int job_type)
float WM_jobs_progress(wmWindowManager *wm, void *owner)
{
wmJob *wm_job = wm_job_find(wm, owner, NULL);
wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
if (wm_job && wm_job->flag & WM_JOB_PROGRESS)
return wm_job->progress;
@@ -202,7 +206,7 @@ float WM_jobs_progress(wmWindowManager *wm, void *owner)
char *WM_jobs_name(wmWindowManager *wm, void *owner)
{
wmJob *wm_job = wm_job_find(wm, owner, NULL);
wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
if (wm_job)
return wm_job->name;