summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_line.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_line.c')
-rw-r--r--lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_line.c116
1 files changed, 41 insertions, 75 deletions
diff --git a/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_line.c b/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_line.c
index d0bac5efb..a190254d9 100644
--- a/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_line.c
+++ b/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_line.c
@@ -288,9 +288,7 @@ try_setup_line( struct lp_setup_context *setup,
struct lp_rast_plane *plane;
struct lp_line_info info;
float width = MAX2(1.0, setup->line_width);
- const struct u_rect *scissor;
- struct u_rect bbox, bboxpos;
- boolean s_planes[4];
+ struct u_rect bbox;
unsigned tri_bytes;
int x[4];
int y[4];
@@ -313,7 +311,6 @@ try_setup_line( struct lp_setup_context *setup,
float y2diff;
float dx, dy;
float area;
- const float (*pv)[4];
boolean draw_start;
boolean draw_end;
@@ -323,18 +320,19 @@ try_setup_line( struct lp_setup_context *setup,
if (0)
print_line(setup, v1, v2);
- if (setup->flatshade_first) {
- pv = v1;
+ if (setup->scissor_test) {
+ nr_planes = 8;
+ if (setup->viewport_index_slot > 0) {
+ unsigned *udata = (unsigned*)v1[setup->viewport_index_slot];
+ viewport_index = lp_clamp_viewport_idx(*udata);
+ }
}
else {
- pv = v2;
- }
- if (setup->viewport_index_slot > 0) {
- unsigned *udata = (unsigned*)pv[setup->viewport_index_slot];
- viewport_index = lp_clamp_viewport_idx(*udata);
+ nr_planes = 4;
}
+
if (setup->layer_slot > 0) {
- layer = *(unsigned*)pv[setup->layer_slot];
+ layer = *(unsigned*)v1[setup->layer_slot];
layer = MIN2(layer, scene->fb_max_layer);
}
@@ -581,24 +579,10 @@ try_setup_line( struct lp_setup_context *setup,
return TRUE;
}
- bboxpos = bbox;
-
/* Can safely discard negative regions:
*/
- bboxpos.x0 = MAX2(bboxpos.x0, 0);
- bboxpos.y0 = MAX2(bboxpos.y0, 0);
-
- nr_planes = 4;
- /*
- * Determine how many scissor planes we need, that is drop scissor
- * edges if the bounding box of the tri is fully inside that edge.
- */
- if (setup->scissor_test) {
- /* why not just use draw_regions */
- scissor = &setup->scissors[viewport_index];
- scissor_planes_needed(s_planes, &bboxpos, scissor);
- nr_planes += s_planes[0] + s_planes[1] + s_planes[2] + s_planes[3];
- }
+ bbox.x0 = MAX2(bbox.x0, 0);
+ bbox.y0 = MAX2(bbox.y0, 0);
line = lp_setup_alloc_triangle(scene,
key->num_inputs,
@@ -653,25 +637,19 @@ try_setup_line( struct lp_setup_context *setup,
line->inputs.layer = layer;
line->inputs.viewport_index = viewport_index;
- /*
- * XXX: this code is mostly identical to the one in lp_setup_tri, except it
- * uses 4 planes instead of 3. Could share the code (including the sse
- * assembly, in fact we'd get the 4th plane for free).
- * The only difference apart from storing the 4th plane would be some
- * different shuffle for calculating dcdx/dcdy.
- */
for (i = 0; i < 4; i++) {
- /* half-edge constants, will be iterated over the whole render
+ /* half-edge constants, will be interated over the whole render
* target.
*/
plane[i].c = IMUL64(plane[i].dcdx, x[i]) - IMUL64(plane[i].dcdy, y[i]);
- /* correct for top-left vs. bottom-left fill convention.
- */
+
+ /* correct for top-left vs. bottom-left fill convention.
+ */
if (plane[i].dcdx < 0) {
/* both fill conventions want this - adjust for left edges */
- plane[i].c++;
+ plane[i].c++;
}
else if (plane[i].dcdx == 0) {
if (setup->pixel_offset == 0) {
@@ -717,45 +695,33 @@ try_setup_line( struct lp_setup_context *setup,
* 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 = -1 << 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 = -1 << 8;
- plane_s->c = (scissor->y1+1) << 8;
- plane_s->eo = 0;
- plane_s++;
- }
- assert(plane_s == &plane[nr_planes]);
+ if (nr_planes == 8) {
+ const struct u_rect *scissor =
+ &setup->scissors[viewport_index];
+
+ plane[4].dcdx = -1;
+ plane[4].dcdy = 0;
+ plane[4].c = 1-scissor->x0;
+ plane[4].eo = 1;
+
+ plane[5].dcdx = 1;
+ plane[5].dcdy = 0;
+ plane[5].c = scissor->x1+1;
+ plane[5].eo = 0;
+
+ plane[6].dcdx = 0;
+ plane[6].dcdy = 1;
+ plane[6].c = 1-scissor->y0;
+ plane[6].eo = 1;
+
+ plane[7].dcdx = 0;
+ plane[7].dcdy = -1;
+ plane[7].c = scissor->y1+1;
+ plane[7].eo = 0;
}
- return lp_setup_bin_triangle(setup, line, &bbox, &bboxpos, nr_planes, viewport_index);
+ return lp_setup_bin_triangle(setup, line, &bbox, nr_planes, viewport_index);
}