mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-02 07:20:16 +01:00
llvmpipe: use scissor_planes_needed helper function
So it doesn't get out of sync in multiple places.
This commit is contained in:
parent
141ef75569
commit
848a023c05
3 changed files with 33 additions and 18 deletions
|
|
@ -168,6 +168,21 @@ struct lp_setup_context
|
|||
const float (*v2)[4]);
|
||||
};
|
||||
|
||||
static inline void
|
||||
scissor_planes_needed(boolean scis_planes[4], struct u_rect *bbox,
|
||||
struct u_rect *scissor)
|
||||
{
|
||||
/* left */
|
||||
scis_planes[0] = (bbox->x0 < scissor->x0);
|
||||
/* right */
|
||||
scis_planes[1] = (bbox->x1 > scissor->x1);
|
||||
/* top */
|
||||
scis_planes[2] = (bbox->y0 < scissor->y0);
|
||||
/* bottom */
|
||||
scis_planes[3] = (bbox->y1 > scissor->y1);
|
||||
}
|
||||
|
||||
|
||||
void lp_setup_choose_triangle( struct lp_setup_context *setup );
|
||||
void lp_setup_choose_line( struct lp_setup_context *setup );
|
||||
void lp_setup_choose_point( struct lp_setup_context *setup );
|
||||
|
|
|
|||
|
|
@ -591,11 +591,9 @@ try_setup_line( struct lp_setup_context *setup,
|
|||
*/
|
||||
if (setup->scissor_test) {
|
||||
/* why not just use draw_regions */
|
||||
struct u_rect *scissor = &setup->scissors[viewport_index];
|
||||
nr_planes += (bbox.x0 < scissor->x0);
|
||||
nr_planes += (bbox.x1 > scissor->x1);
|
||||
nr_planes += (bbox.y0 < scissor->y0);
|
||||
nr_planes += (bbox.y1 > scissor->y1);
|
||||
boolean s_planes[4];
|
||||
scissor_planes_needed(s_planes, &bbox, &setup->scissors[viewport_index]);
|
||||
nr_planes += s_planes[0] + s_planes[1] + s_planes[2] + s_planes[3];
|
||||
}
|
||||
|
||||
line = lp_setup_alloc_triangle(scene,
|
||||
|
|
@ -723,29 +721,31 @@ try_setup_line( struct lp_setup_context *setup,
|
|||
/* why not just use draw_regions */
|
||||
struct u_rect *scissor = &setup->scissors[viewport_index];
|
||||
struct lp_rast_plane *plane_s = &plane[4];
|
||||
boolean s_planes[4];
|
||||
scissor_planes_needed(s_planes, &bbox, scissor);
|
||||
|
||||
if (bbox.x0 < scissor->x0) {
|
||||
if (s_planes[0]) {
|
||||
plane_s->dcdx = -1 << 8;
|
||||
plane_s->dcdy = 0;
|
||||
plane_s->c = (1-scissor->x0) << 8;
|
||||
plane_s->eo = 1 << 8;
|
||||
plane_s++;
|
||||
}
|
||||
if (bbox.x1 > scissor->x1) {
|
||||
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 (bbox.y0 < scissor->y0) {
|
||||
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 (bbox.y1 > scissor->y1) {
|
||||
if (s_planes[3]) {
|
||||
plane_s->dcdx = 0;
|
||||
plane_s->dcdy = -1 << 8;
|
||||
plane_s->c = (scissor->y1+1) << 8;
|
||||
|
|
|
|||
|
|
@ -347,11 +347,9 @@ do_triangle_ccw(struct lp_setup_context *setup,
|
|||
*/
|
||||
if (setup->scissor_test) {
|
||||
/* why not just use draw_regions */
|
||||
struct u_rect *scissor = &setup->scissors[viewport_index];
|
||||
nr_planes += (bbox.x0 < scissor->x0);
|
||||
nr_planes += (bbox.x1 > scissor->x1);
|
||||
nr_planes += (bbox.y0 < scissor->y0);
|
||||
nr_planes += (bbox.y1 > scissor->y1);
|
||||
boolean s_planes[4];
|
||||
scissor_planes_needed(s_planes, &bbox, &setup->scissors[viewport_index]);
|
||||
nr_planes += s_planes[0] + s_planes[1] + s_planes[2] + s_planes[3];
|
||||
}
|
||||
|
||||
tri = lp_setup_alloc_triangle(scene,
|
||||
|
|
@ -685,29 +683,31 @@ do_triangle_ccw(struct lp_setup_context *setup,
|
|||
/* why not just use draw_regions */
|
||||
struct u_rect *scissor = &setup->scissors[viewport_index];
|
||||
struct lp_rast_plane *plane_s = &plane[3];
|
||||
boolean s_planes[4];
|
||||
scissor_planes_needed(s_planes, &bbox, scissor);
|
||||
|
||||
if (bbox.x0 < scissor->x0) {
|
||||
if (s_planes[0]) {
|
||||
plane_s->dcdx = -1 << 8;
|
||||
plane_s->dcdy = 0;
|
||||
plane_s->c = (1-scissor->x0) << 8;
|
||||
plane_s->eo = 1 << 8;
|
||||
plane_s++;
|
||||
}
|
||||
if (bbox.x1 > scissor->x1) {
|
||||
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 (bbox.y0 < scissor->y0) {
|
||||
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 (bbox.y1 > scissor->y1) {
|
||||
if (s_planes[3]) {
|
||||
plane_s->dcdx = 0;
|
||||
plane_s->dcdy = -1 << 8;
|
||||
plane_s->c = (scissor->y1+1) << 8;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue