shithub: libgraphics

Download patch

ref: 2fd16cbf190d5c37fc627f79bf586f66129fea46
parent: 9f4d2e578fa2b874d65fd85d28f9b9f31e88dd0f
author: rodri <rgl@antares-labs.eu>
date: Thu Sep 19 17:33:17 EDT 2024

get rid of the turbopool (the experiment was futile.)

--- a/fb.c
+++ b/fb.c
@@ -205,25 +205,6 @@
 	free(blk);
 }
 
-//typedef struct Ldimgtask Ldimgtask;
-//struct Ldimgtask
-//{
-//	Image *dst;
-//	Rectangle dr;
-//	uchar *src;
-//	ulong len;
-//	Channel *done;	/* task completion signal */
-//};
-//static void
-//ldimgtask(void *arg)
-//{
-//	Ldimgtask *t;
-//
-//	t = arg;
-//	loadimage(t->dst, t->dr, t->src, t->len);
-//	nbsend(t->done, nil);
-//}
-
 static void
 framebufctl_draw(Framebufctl *ctl, Image *dst, char *name, Point off, Point scale)
 {
@@ -266,54 +247,6 @@
 	sr = rectaddpt(fb->r, off);
 	dr = rectsubpt(dst->r, dst->r.min);
 	if(rectinrect(sr, dr)){
-//		Ldimgtask *tasks;
-//		Rectangle blkr;
-//		ulong len, stride;
-//		int Δy, i;
-//		static Display **disps;
-//		static Image **imgs;
-//		static int loaded;
-//
-//		assert(turbodrawingpool != nil);
-//
-//		if(!loaded){
-//			disps = emalloc(turbodrawingpool->nprocs * sizeof(*disps));
-//			imgs = emalloc(turbodrawingpool->nprocs * sizeof(*imgs));
-//			for(i = 0; i < turbodrawingpool->nprocs; i++){
-//				disps[i] = initdisplay(nil, nil, nil);
-//				if(disps[i] == nil)
-//					sysfatal("initdisplay: %r");
-//				imgs[i] = namedimage(disps[i], "screenb");
-//				if(imgs[i] == nil)
-//					sysfatal("namedimage: %r");
-////fprint(2, "d %#p i %#p → %#p\n", disps[i], imgs[i], imgs[i]->display);
-//			}
-//			loaded++;
-//		}
-//
-//		len = Dx(r->r)*Dy(r->r)*4;
-//		Δy = Dy(sr)/turbodrawingpool->nprocs;
-//		dr = rectaddpt(sr, dst->r.min);
-//		blkr = dr;
-//		blkr.max.y = blkr.min.y + Δy;
-//		stride = Dx(blkr)*Dy(blkr)*4;
-//		tasks = emalloc(turbodrawingpool->nprocs * sizeof(*tasks));
-//
-//		for(i = 0; i < turbodrawingpool->nprocs; i++){
-//			tasks[i].dst = imgs[i];
-//			tasks[i].dr = rectaddpt(blkr, Pt(0, i*Δy));
-//			tasks[i].src = (uchar*)r->data + i*stride;
-//			tasks[i].len = stride;
-//			if(i == turbodrawingpool->nprocs-1){
-//				tasks[i].dr.max.y = dr.max.y;
-//				tasks[i].len = len - i*stride;
-//			}
-//			turbopoolexec(turbodrawingpool, ldimgtask, &tasks[i]);
-//		}
-//		for(i = 0; i < turbodrawingpool->nprocs; i++)
-//			recvp(tasks[i].done);
-//		free(tasks);
-
 		tmp = allocimage(display, sr, RGBA32, 0, DNofill);
 		if(tmp == nil)
 			sysfatal("allocimage: %r");
--- a/internal.h
+++ b/internal.h
@@ -39,23 +39,6 @@
 	Primitive p;
 };
 
-typedef struct Turbotask Turbotask;
-typedef struct Turbopool Turbopool;
-
-struct Turbotask
-{
-	void (*fn)(void*);
-	void *arg;
-};
-
-struct Turbopool
-{
-	ulong nprocs;
-	Channel *subq;	/* task submission queue */
-};
-
-extern Turbopool *turbopool;
-
 /* alloc */
 void *emalloc(ulong);
 void *erealloc(void*, ulong);
@@ -95,11 +78,6 @@
 
 /* nanosec */
 uvlong nanosec(void);
-
-/* turbopool */
-Turbopool *mkturbopool(ulong);
-void turbopoolexec(Turbopool*, void(*)(void*), void*);
-void rmturbopool(Turbopool*);
 
 #define getpixel(fb, p)		rastergetcolor(fb, p)
 #define putpixel(fb, p, c)	rasterputcolor(fb, p, c)
--- a/mkfile
+++ b/mkfile
@@ -17,7 +17,6 @@
 	color.$O\
 	util.$O\
 	nanosec.$O\
-	turbopool.$O\
 
 HFILES=\
 	graphics.h\
--- a/render.c
+++ b/render.c
@@ -9,7 +9,6 @@
 #include "internal.h"
 
 Rectangle UR = {0,0,1,1};
-//Turbopool *turbopool;
 
 static Vertexattr *
 sparams_getuniform(Shaderparams *sp, char *id)
@@ -731,8 +730,6 @@
 	if(nprocs == nil || (nproc = strtoul(nprocs, nil, 10)) < 2)
 		nproc = 1;
 	free(nprocs);
-
-//	turbopool = mkturbopool(nproc);
 
 	r = emalloc(sizeof *r);
 	memset(r, 0, sizeof *r);
--- a/turbopool.c
+++ /dev/null
@@ -1,60 +1,0 @@
-#include <u.h>
-#include <libc.h>
-#include <thread.h>
-#include <draw.h>
-#include <memdraw.h>
-#include <geometry.h>
-#include "libobj/obj.h"
-#include "graphics.h"
-#include "internal.h"
-
-static void
-_turboproc(void *arg)
-{
-	Turbopool *p;
-	Turbotask *t;
-
-	threadsetname("turboproc");
-
-	p = arg;
-
-	while((t = recvp(p->subq)) != nil){
-		t->fn(t->arg);
-		free(t);
-	}
-}
-
-Turbopool *
-mkturbopool(ulong nprocs)
-{
-	Turbopool *p;
-
-	p = emalloc(sizeof *p);
-	memset(p, 0, sizeof *p);
-	p->nprocs = nprocs;
-	p->subq = chancreate(sizeof(void*), nprocs);
-	while(nprocs--)
-		proccreate(_turboproc, p, mainstacksize);
-	return p;
-}
-
-void
-turbopoolexec(Turbopool *p, void (*fn)(void*), void *arg)
-{
-	Turbotask *t;
-
-	t = emalloc(sizeof *t);
-	t->fn = fn;
-	t->arg = arg;
-
-	sendp(p->subq, t);
-}
-
-void
-rmturbopool(Turbopool *p)
-{
-	while(p->nprocs--)
-		sendp(p->subq, nil);
-	chanfree(p->subq);
-	free(p);
-}