diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 9109114487c..bbf52e93f86 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -1752,4 +1752,58 @@ lp_setup_flush_and_restart(struct lp_setup_context *setup) return TRUE; } - +void +lp_setup_add_scissor_planes(const struct u_rect *scissor, + struct lp_rast_plane *plane_s, + boolean s_planes[4]) +{ + /* + * When rasterizing scissored tris, use the intersection of the + * triangle bounding box and the scissor rect to generate the + * scissor planes. + * + * This permits us to cut off the triangle "tails" that are present + * in the intermediate recursive levels caused when two of the + * triangles edges don't diverge quickly enough to trivially reject + * exterior blocks from the triangle. + * + * It's not really clear if it's worth worrying about these tails, + * but since we generate the planes for each scissored tri, it's + * free to trim them in this case. + * + * Note that otherwise, the scissor planes only vary in 'C' value, + * and even then only on state-changes. Could alternatively store + * these planes elsewhere. + * (Or only store the c value together with a bit indicating which + * scissor edge this is, so rasterization would treat them differently + * (easier to evaluate) to ordinary planes.) + */ + if (s_planes[0]) { + plane_s->dcdx = ~0U << 8; + plane_s->dcdy = 0; + plane_s->c = (1-scissor->x0) << 8; + plane_s->eo = 1 << 8; + plane_s++; + } + if (s_planes[1]) { + plane_s->dcdx = 1 << 8; + plane_s->dcdy = 0; + plane_s->c = (scissor->x1+1) << 8; + plane_s->eo = 0 << 8; + plane_s++; + } + if (s_planes[2]) { + plane_s->dcdx = 0; + plane_s->dcdy = 1 << 8; + plane_s->c = (1-scissor->y0) << 8; + plane_s->eo = 1 << 8; + plane_s++; + } + if (s_planes[3]) { + plane_s->dcdx = 0; + plane_s->dcdy = ~0U << 8; + plane_s->c = (scissor->y1+1) << 8; + plane_s->eo = 0; + plane_s++; + } +} diff --git a/src/gallium/drivers/llvmpipe/lp_setup_context.h b/src/gallium/drivers/llvmpipe/lp_setup_context.h index a7273a2ad93..2a974e78ed6 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_context.h +++ b/src/gallium/drivers/llvmpipe/lp_setup_context.h @@ -207,6 +207,10 @@ scissor_planes_needed(boolean scis_planes[4], const struct u_rect *bbox, scis_planes[3] = (bbox->y1 > scissor->y1); } +void +lp_setup_add_scissor_planes(const struct u_rect *scissor, + struct lp_rast_plane *plane_s, + boolean s_planes[4]); void lp_setup_choose_triangle( struct lp_setup_context *setup ); void lp_setup_choose_line( struct lp_setup_context *setup ); diff --git a/src/gallium/drivers/llvmpipe/lp_setup_line.c b/src/gallium/drivers/llvmpipe/lp_setup_line.c index 756f24d2c33..60b30463853 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_line.c +++ b/src/gallium/drivers/llvmpipe/lp_setup_line.c @@ -711,60 +711,8 @@ try_setup_line( struct lp_setup_context *setup, if (plane[i].dcdy > 0) plane[i].eo += plane[i].dcdy; } - - /* - * When rasterizing scissored tris, use the intersection of the - * triangle bounding box and the scissor rect to generate the - * scissor planes. - * - * This permits us to cut off the triangle "tails" that are present - * in the intermediate recursive levels caused when two of the - * triangles edges don't diverge quickly enough to trivially reject - * exterior blocks from the triangle. - * - * It's not really clear if it's worth worrying about these tails, - * but since we generate the planes for each scissored tri, it's - * free to trim them in this case. - * - * Note that otherwise, the scissor planes only vary in 'C' value, - * and even then only on state-changes. Could alternatively store - * these planes elsewhere. - * (Or only store the c value together with a bit indicating which - * scissor edge this is, so rasterization would treat them differently - * (easier to evaluate) to ordinary planes.) - */ if (nr_planes > 4) { - struct lp_rast_plane *plane_s = &plane[4]; - - if (s_planes[0]) { - plane_s->dcdx = ~0U << 8; - plane_s->dcdy = 0; - plane_s->c = (1-scissor->x0) << 8; - plane_s->eo = 1 << 8; - plane_s++; - } - if (s_planes[1]) { - plane_s->dcdx = 1 << 8; - plane_s->dcdy = 0; - plane_s->c = (scissor->x1+1) << 8; - plane_s->eo = 0 << 8; - plane_s++; - } - if (s_planes[2]) { - plane_s->dcdx = 0; - plane_s->dcdy = 1 << 8; - plane_s->c = (1-scissor->y0) << 8; - plane_s->eo = 1 << 8; - plane_s++; - } - if (s_planes[3]) { - plane_s->dcdx = 0; - plane_s->dcdy = ~0U << 8; - plane_s->c = (scissor->y1+1) << 8; - plane_s->eo = 0; - plane_s++; - } - assert(plane_s == &plane[nr_planes]); + lp_setup_add_scissor_planes(scissor, &plane[4], s_planes); } return lp_setup_bin_triangle(setup, line, &bbox, &bboxpos, nr_planes, viewport_index); diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c index a31e77e5213..a3d34ef65ea 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c +++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c @@ -734,60 +734,8 @@ do_triangle_ccw(struct lp_setup_context *setup, plane[2].eo); } - - /* - * When rasterizing scissored tris, use the intersection of the - * triangle bounding box and the scissor rect to generate the - * scissor planes. - * - * This permits us to cut off the triangle "tails" that are present - * in the intermediate recursive levels caused when two of the - * triangles edges don't diverge quickly enough to trivially reject - * exterior blocks from the triangle. - * - * It's not really clear if it's worth worrying about these tails, - * but since we generate the planes for each scissored tri, it's - * free to trim them in this case. - * - * Note that otherwise, the scissor planes only vary in 'C' value, - * and even then only on state-changes. Could alternatively store - * these planes elsewhere. - * (Or only store the c value together with a bit indicating which - * scissor edge this is, so rasterization would treat them differently - * (easier to evaluate) to ordinary planes.) - */ if (nr_planes > 3) { - struct lp_rast_plane *plane_s = &plane[3]; - - if (s_planes[0]) { - plane_s->dcdx = ~0U << 8; - plane_s->dcdy = 0; - plane_s->c = (1-scissor->x0) << 8; - plane_s->eo = 1 << 8; - plane_s++; - } - if (s_planes[1]) { - plane_s->dcdx = 1 << 8; - plane_s->dcdy = 0; - plane_s->c = (scissor->x1+1) << 8; - plane_s->eo = 0 << 8; - plane_s++; - } - if (s_planes[2]) { - plane_s->dcdx = 0; - plane_s->dcdy = 1 << 8; - plane_s->c = (1-scissor->y0) << 8; - plane_s->eo = 1 << 8; - plane_s++; - } - if (s_planes[3]) { - plane_s->dcdx = 0; - plane_s->dcdy = ~0U << 8; - plane_s->c = (scissor->y1+1) << 8; - plane_s->eo = 0; - plane_s++; - } - assert(plane_s == &plane[nr_planes]); + lp_setup_add_scissor_planes(scissor, &plane[3], s_planes); } return lp_setup_bin_triangle(setup, tri, &bbox, &bboxpos, nr_planes, viewport_index);