diff options
-rw-r--r-- | camera.c | 4 | ||||
-rw-r--r-- | graphics.h | 3 | ||||
-rw-r--r-- | render.c | 7 | ||||
-rw-r--r-- | viewport.c | 7 |
4 files changed, 15 insertions, 6 deletions
@@ -86,17 +86,15 @@ shootcamera(Camera *c, Shadertab *s) job = emalloc(sizeof *job); memset(job, 0, sizeof *job); - job->fb = c->vp->fbctl->fb[c->vp->fbctl->idx^1]; /* address the back buffer */ + job->v = c->vp; job->scene = c->s; job->shaders = s; job->donec = chancreate(sizeof(void*), 0); - c->vp->fbctl->reset(c->vp->fbctl); t0 = nanosec(); sendp(c->rctl->c, job); recvp(job->donec); t1 = nanosec(); - c->vp->fbctl->swap(c->vp->fbctl); chanfree(job->donec); free(job); @@ -176,7 +176,7 @@ struct Renderer struct Renderjob { - Framebuf *fb; + Viewport *v; Scene *scene; Shadertab *shaders; Channel *donec; @@ -215,6 +215,7 @@ struct Viewport void (*draw)(Viewport*, Image*); void (*memdraw)(Viewport*, Memimage*); + Framebuf *(*getfb)(Viewport*); }; struct Camera @@ -509,6 +509,7 @@ renderer(void *arg) job->nrem = sc->nents; job->lastid = 0; job->time0 = nanosec(); + job->v->fbctl->reset(job->v->fbctl); if(jobq.tl == nil){ jobq.tl = jobq.hd = job; @@ -526,7 +527,7 @@ sendparams: if(ent != nil && ent != &sc->ents){ params = emalloc(sizeof *params); memset(params, 0, sizeof *params); - params->fb = job->fb; + params->fb = job->v->getfb(job->v); params->id = job->lastid++; params->frag = rgb(DBlack); params->donec = donec; @@ -548,8 +549,10 @@ sendparams: } break; case DONE: - if(--params2->job->nrem < 1) + if(--params2->job->nrem < 1){ + params2->job->v->fbctl->swap(params2->job->v->fbctl); send(params2->job->donec, nil); + } freememimage(params2->frag); free(params2); @@ -20,6 +20,12 @@ viewport_memdraw(Viewport *v, Memimage *dst) v->fbctl->memdraw(v->fbctl, dst); } +static Framebuf * +viewport_getfb(Viewport *v) +{ + return v->fbctl->fb[v->fbctl->idx^1]; /* address the back buffer */ +} + Viewport * mkviewport(Rectangle r) { @@ -32,6 +38,7 @@ mkviewport(Rectangle r) v->fbctl = mkfbctl(r); v->draw = viewport_draw; v->memdraw = viewport_memdraw; + v->getfb = viewport_getfb; return v; } |