diff options
-rw-r--r-- | camera.c | 4 | ||||
-rw-r--r-- | internal.h | 24 | ||||
-rw-r--r-- | render.c | 36 |
3 files changed, 38 insertions, 26 deletions
@@ -108,9 +108,9 @@ shootcamera(Camera *c, Shadertab *s) t1 = nanosec(); c->vp->fbctl->swap(c->vp->fbctl); + updatestats(c, t1-t0); updatetimes(c, job); + chanfree(job->donec); free(job); - - updatestats(c, t1-t0); } @@ -1,21 +1,29 @@ typedef struct Tilerparam Tilerparam; +typedef struct Rasterparam Rasterparam; typedef struct Rastertask Rastertask; -struct Rastertask -{ - SUparams *params; - Rectangle wr; /* working rect */ - Primitive p; -}; - struct Tilerparam { + int id; Channel *paramsc; - Channel **tasksc; /* Channel*[nproc] */ + Channel **taskchans; /* Channel*[nproc] */ Rectangle *wr; /* Rectangle[nproc] */ ulong nproc; }; +struct Rasterparam +{ + int id; + Channel *taskc; +}; + +struct Rastertask +{ + SUparams *params; + Rectangle wr; /* working rect */ + Primitive p; +}; + /* alloc */ void *emalloc(ulong); void *erealloc(void*, ulong); @@ -358,18 +358,18 @@ rasterize(Rastertask *task) static void rasterizer(void *arg) { - Channel *taskc; + Rasterparam *rp; Rastertask *task; SUparams *params; Memimage *frag; uvlong t0; - threadsetname("rasterizer"); - - taskc = arg; + rp = arg; frag = rgb(DBlack); - while((task = recvp(taskc)) != nil){ + threadsetname("rasterizer %d", rp->id); + + while((task = recvp(rp->taskc)) != nil){ t0 = nanosec(); params = task->params; @@ -411,19 +411,19 @@ tilerdurden(void *arg) Point3 n; /* surface normal */ Primitive *p; /* primitives to raster */ Rectangle *wr, bbox; - Channel **taskc; + Channel **taskchans; ulong Δy, nproc; int i, np; uvlong t0; - threadsetname("tilerdurden"); - tp = arg; p = emalloc(sizeof(*p)*16); - taskc = tp->tasksc; + taskchans = tp->taskchans; nproc = tp->nproc; wr = emalloc(nproc*sizeof(Rectangle)); + threadsetname("tilerdurden %d", tp->id); + while((params = recvp(tp->paramsc)) != nil){ t0 = nanosec(); if(params->job->times.Tn.t0 == 0) @@ -437,7 +437,7 @@ tilerdurden(void *arg) task = emalloc(sizeof *task); memset(task, 0, sizeof *task); task->params = params; - sendp(taskc[i], task); + sendp(taskchans[i], task); } } continue; @@ -555,7 +555,7 @@ tilerdurden(void *arg) task->p.v[0] = dupvertex(&p[np].v[0]); task->p.v[1] = dupvertex(&p[np].v[1]); task->p.v[2] = dupvertex(&p[np].v[2]); - sendp(taskc[i], task); + sendp(taskchans[i], task); } //skiptri: delvattrs(&p[np].v[0]); @@ -571,8 +571,9 @@ tilerdurden(void *arg) static void entityproc(void *arg) { - Channel *paramsin, **paramsout, **taskc; + Channel *paramsin, **paramsout, **taskchans; Tilerparam *tp; + Rasterparam *rp; SUparams *params, *newparams; OBJElem **eb, **ee; char *nprocs; @@ -591,18 +592,21 @@ entityproc(void *arg) free(nprocs); paramsout = emalloc(nproc*sizeof(*paramsout)); - taskc = emalloc(nproc*sizeof(*taskc)); + taskchans = emalloc(nproc*sizeof(*taskchans)); for(i = 0; i < nproc; i++){ paramsout[i] = chancreate(sizeof(SUparams*), 8); tp = emalloc(sizeof *tp); + tp->id = i; tp->paramsc = paramsout[i]; - tp->tasksc = taskc; + tp->taskchans = taskchans; tp->nproc = nproc; proccreate(tilerdurden, tp, mainstacksize); } for(i = 0; i < nproc; i++){ - taskc[i] = chancreate(sizeof(Rastertask*), 32); - proccreate(rasterizer, taskc[i], mainstacksize); + rp = emalloc(sizeof *rp); + rp->id = i; + rp->taskc = taskchans[i] = chancreate(sizeof(Rastertask*), 32); + proccreate(rasterizer, rp, mainstacksize); } while((params = recvp(paramsin)) != nil){ |