shithub: tinyrend

Download patch

ref: d60d6cd1d01d25dd4931e8c3d3f2f9476cfe2a4b
parent: c6b9f1912fd3821f9806f74fa9b81ff9ba4d7b4e
author: rodri <rgl@antares-labs.eu>
date: Tue Dec 19 06:44:16 EST 2023

put the zbuflk in the Framebuf.

--- a/main.c
+++ b/main.c
@@ -65,6 +65,7 @@
 	Memimage *cb;
 	Memimage *zb;
 	double *zbuf;
+	Lock zbuflk;
 	Memimage *nb;	/* XXX DBG */
 	Rectangle r;
 };
@@ -90,7 +91,6 @@
 Stats fps;
 Framebufctl *fbctl;
 Memimage *screenfb;
-Lock zbuflk;
 Memimage *red, *green, *blue;
 OBJ *model;
 Memimage *modeltex;
@@ -588,9 +588,9 @@
 			z = st.p0.z*bc.x + st.p1.z*bc.y + st.p2.z*bc.z;
 			w = st.p0.w*bc.x + st.p1.w*bc.y + st.p2.w*bc.z;
 			depth = fclamp(z/w, 0, 1);
-			lock(&zbuflk);
+			lock(&params->fb->zbuflk);
 			if(depth <= params->fb->zbuf[p.x + p.y*Dx(params->fb->r)]){
-				unlock(&zbuflk);
+				unlock(&params->fb->zbuflk);
 				continue;
 			}
 			params->fb->zbuf[p.x + p.y*Dx(params->fb->r)] = depth;
@@ -600,7 +600,7 @@
 			cbuf[3] = 0xFF*depth;
 			memfillcolor(frag, *(ulong*)cbuf);
 			pixel(params->fb->zb, p, frag);
-			unlock(&zbuflk);
+			unlock(&params->fb->zbuflk);
 
 			cbuf[0] = 0xFF;
 			if((tt.p0.w + tt.p1.w + tt.p2.w) != 0){