From fb2c8083f028676d0c46e0d9a89de78b3f129552 Mon Sep 17 00:00:00 2001 From: rodri Date: Sat, 7 Sep 2024 18:39:36 +0000 Subject: remove unnecessary copying. profile individual stage procs. --- camera.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'camera.c') diff --git a/camera.c b/camera.c index 0562769..d5d660d 100644 --- a/camera.c +++ b/camera.c @@ -86,17 +86,6 @@ updatestats(Camera *c, uvlong v) c->stats.nframes++; } -static void -updatetimes(Camera *c, Renderjob *j) -{ - c->times.R[c->times.cur] = j->times.R; - c->times.E[c->times.cur] = j->times.E; - c->times.Tn[c->times.cur] = j->times.Tn; - c->times.Rn[c->times.cur] = j->times.Rn; - c->times.last = c->times.cur; - c->times.cur = ++c->times.cur % nelem(c->times.R); -} - static void verifycfg(Camera *c) { @@ -208,6 +197,26 @@ aimcamera(Camera *c, Point3 focus) c->by = crossvec3(c->bz, c->bx); } +static void +printtimings(Renderjob *job) +{ + int i; + + if(!job->rctl->doprof) + return; + + fprint(2, "R %llud %llud\nE %llud %llud\n", + job->times.R.t0, job->times.R.t1, + job->times.E.t0, job->times.E.t1); + for(i = 0; i < job->rctl->nprocs/2; i++) + fprint(2, "T%d %llud %llud\n", i, + job->times.Tn[i].t0, job->times.Tn[i].t1); + for(i = 0; i < job->rctl->nprocs/2; i++) + fprint(2, "r%d %llud %llud\n", i, + job->times.Rn[i].t0, job->times.Rn[i].t1); + fprint(2, "\n"); +} + void shootcamera(Camera *c, Shadertab *s) { @@ -224,6 +233,7 @@ shootcamera(Camera *c, Shadertab *s) job = emalloc(sizeof *job); memset(job, 0, sizeof *job); + job->rctl = c->rctl; job->fb = fbctl->getbb(fbctl); job->camera = emalloc(sizeof *c); *job->camera = *c; @@ -233,7 +243,7 @@ shootcamera(Camera *c, Shadertab *s) fbctl->reset(fbctl, c->clearcolor); t0 = nanosec(); - sendp(c->rctl->c, job); + sendp(c->rctl->jobq, job); recvp(job->donec); delscene(job->scene); /* destroy the snapshot */ /* @@ -251,7 +261,7 @@ shootcamera(Camera *c, Shadertab *s) reloadcamera(job->camera); job->scene = dupscene(skyboxscene); job->shaders = &skyboxshader; - sendp(c->rctl->c, job); + sendp(c->rctl->jobq, job); recvp(job->donec); delscene(job->scene); } @@ -259,7 +269,9 @@ shootcamera(Camera *c, Shadertab *s) fbctl->swap(fbctl); updatestats(c, t1-t0); - updatetimes(c, job); + printtimings(job); +// free(job->times.Tn); +// free(job->times.Rn); chanfree(job->donec); free(job->camera); -- cgit v1.2.3