summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-09-08 15:36:17 +0000
committerrodri <rgl@antares-labs.eu>2024-09-08 15:36:17 +0000
commitddbb6a2f4c9204b4539b7d43a0251d3f92538b10 (patch)
tree5f7f909384d2ba80b81a8cefac810056826cf159
parentc737bfbaaa28b316589ec809153f684f5f1014b6 (diff)
downloadlibgraphics-ddbb6a2f4c9204b4539b7d43a0251d3f92538b10.tar.gz
libgraphics-ddbb6a2f4c9204b4539b7d43a0251d3f92538b10.tar.bz2
libgraphics-ddbb6a2f4c9204b4539b7d43a0251d3f92538b10.zip
render: clip the triangle bbox against the wr directly at the tiler.
-rw-r--r--render.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/render.c b/render.c
index 7903a2c..ad0f244 100644
--- a/render.c
+++ b/render.c
@@ -195,7 +195,6 @@ rasterize(Rastertask *task)
Vertex v;
Shaderparams fsp;
Triangle2 t;
- Rectangle bbox;
Point p, dp, Δp, p0, p1;
Point3 bc;
Color c;
@@ -306,15 +305,9 @@ discard:
t.p0 = Pt2(prim->v[0].p.x, prim->v[0].p.y, 1);
t.p1 = Pt2(prim->v[1].p.x, prim->v[1].p.y, 1);
t.p2 = Pt2(prim->v[2].p.x, prim->v[2].p.y, 1);
- /* find the triangle's bbox and clip it against our wr */
- bbox.min.x = min(min(t.p0.x, t.p1.x), t.p2.x);
- bbox.min.y = min(min(t.p0.y, t.p1.y), t.p2.y);
- bbox.max.x = max(max(t.p0.x, t.p1.x), t.p2.x)+1;
- bbox.max.y = max(max(t.p0.y, t.p1.y), t.p2.y)+1;
- rectclip(&bbox, task->wr);
-
- for(p.y = bbox.min.y; p.y < bbox.max.y; p.y++)
- for(p.x = bbox.min.x; p.x < bbox.max.x; p.x++){
+
+ for(p.y = task->wr.min.y; p.y < task->wr.max.y; p.y++)
+ for(p.x = task->wr.min.x; p.x < task->wr.max.x; p.x++){
bc = _barycoords(t, Pt2(p.x+0.5,p.y+0.5,1));
if(bc.x < 0 || bc.y < 0 || bc.z < 0)
continue;
@@ -483,7 +476,6 @@ tiler(void *arg)
*newparams = *params;
task = emalloc(sizeof *task);
task->params = newparams;
- task->wr = wr[i];
task->p = *p;
task->p.v[0] = dupvertex(&p->v[0]);
sendp(taskchans[i], task);
@@ -578,7 +570,8 @@ tiler(void *arg)
*newparams = *params;
task = emalloc(sizeof *task);
task->params = newparams;
- task->wr = wr[i];
+ task->wr = bbox;
+ rectclip(&task->wr, wr[i]);
task->p = *p;
task->p.v[0] = dupvertex(&p->v[0]);
task->p.v[1] = dupvertex(&p->v[1]);