shithub: renderfs

Download patch

ref: df92f606034a287ef2cbd3ca3d5ac7a2622ddb9e
parent: 53dcc34e34cca4453017bae72c0944f2fe1c93fb
author: rodri <rgl@antares-labs.eu>
date: Mon Apr 15 18:27:03 EDT 2024

show pipeline stage times in the stats file.

--- a/fs.c
+++ b/fs.c
@@ -167,6 +167,7 @@
 	placecamera(c, Pt3(0,0,100,1), Pt3(0,0,0,1), Vec3(0,1,0));
 	reloadcamera(c);
 	memset(&c->stats, 0, sizeof c->stats);
+	memset(&c->times, 0, sizeof c->times);
 }
 
 static ulong
@@ -392,11 +393,11 @@
 {
 	Client *c;
 	Framebuf *fb;
-	Memimage *i;
+	Memimage *img;
 	char buf[1024], cbuf[30], *t;
 	uvlong path;
 	ulong off, cnt;
-	int n;
+	int n, i;
 
 	path = r->fid->qid.path;
 	off = r->ifcall.offset;
@@ -426,6 +427,13 @@
 			!c->cam->stats.avg? 0: 1e9/c->cam->stats.avg,
 			!c->cam->stats.min? 0: 1e9/c->cam->stats.min,
 			!c->cam->stats.v? 0: 1e9/c->cam->stats.v);
+		n += snprint(buf+n, sizeof(buf)-n, "times\n");
+		for(i = 0; i < c->cam->times.cur; i++)
+			n += snprint(buf+n, sizeof(buf)-n, "%d\tR\t[%llud %llud] (%.0f µs)\n\tE\t[%llud %llud] (%.0f µs)\n\tTn\t[%llud %llud] (%.0f µs)\n\tRn\t[%llud %llud] (%.0f µs)\n",
+				i, c->cam->times.R[i].t0, c->cam->times.R[i].t1, (c->cam->times.R[i].t1-c->cam->times.R[i].t0)/1e3,
+				c->cam->times.E[i].t0, c->cam->times.E[i].t1, (c->cam->times.E[i].t1-c->cam->times.E[i].t0)/1e3,
+				c->cam->times.Tn[i].t0, c->cam->times.Tn[i].t1, (c->cam->times.Tn[i].t1-c->cam->times.Tn[i].t0)/1e3,
+				c->cam->times.Rn[i].t0, c->cam->times.Rn[i].t1, (c->cam->times.Rn[i].t1-c->cam->times.Rn[i].t0)/1e3);
 		snprint(buf+n, sizeof(buf)-n, "frame #%llud\n", c->cam->stats.nframes);
 		readstr(r, buf);
 		respond(r, nil);
@@ -432,11 +440,11 @@
 		break;
 	case Qframe:
 		fb = c->cam->vp->getfb(c->cam->vp);
-		i = fb->cb;
+		img = fb->cb;
 		if(off < 5*12){
 			n = snprint(buf, sizeof buf, "%11s %11d %11d %11d %11d ",
-				chantostr(cbuf, i->chan),
-				i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y);
+				chantostr(cbuf, img->chan),
+				img->r.min.x, img->r.min.y, img->r.max.x, img->r.max.y);
 			t = estrdup9p(buf);
 
 			if(off > n){
@@ -459,7 +467,7 @@
 		t = malloc(cnt);
 		if(t != nil){
 			r->ofcall.data = t;
-			n = readimg(i, t, i->r, off, cnt);
+			n = readimg(img, t, img->r, off, cnt);
 		}
 
 		if(n < 0){