diff options
author | rodri <rgl@antares-labs.eu> | 2024-04-24 12:38:42 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2024-04-24 12:38:42 +0000 |
commit | cf3e0cb65c03955ef18624a50b9e33c3f6e8c6e5 (patch) | |
tree | b451aa62630c091fd0291190b4c1f2452fcdb5ef | |
parent | c40a1238f24534b5f433308d92308e1481464141 (diff) | |
download | libgraphics-cf3e0cb65c03955ef18624a50b9e33c3f6e8c6e5.tar.gz libgraphics-cf3e0cb65c03955ef18624a50b9e33c3f6e8c6e5.tar.bz2 libgraphics-cf3e0cb65c03955ef18624a50b9e33c3f6e8c6e5.zip |
render: add rasterizer init params and per-proc identification.
-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){ |