llvmpipe: respect rectangular_lines

With the new rectangular_lines state, we can now support rasterizing
wide lines correctly according to the vulkan spec, where this can be
specified independently of the rest of the state.

Because rectangular lines are orthogonal to multi-sampling, we now need
to also adjust with the pixel-offset in the rectangle code-path as well.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11782>
This commit is contained in:
Erik Faye-Lund 2021-07-07 11:50:45 +02:00 committed by Marge Bot
parent 7221f2d682
commit fda906566b
5 changed files with 18 additions and 13 deletions

View File

@ -588,11 +588,13 @@ lp_setup_set_triangle_state( struct lp_setup_context *setup,
void
lp_setup_set_line_state( struct lp_setup_context *setup,
float line_width)
float line_width,
boolean line_rectangular)
{
LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
setup->line_width = line_width;
setup->rectangular_lines = line_rectangular;
}
void

View File

@ -83,7 +83,8 @@ lp_setup_set_triangle_state( struct lp_setup_context *setup,
void
lp_setup_set_line_state( struct lp_setup_context *setup,
float line_width);
float line_width,
boolean line_rectangular);
void
lp_setup_set_point_state( struct lp_setup_context *setup,

View File

@ -103,6 +103,7 @@ struct lp_setup_context
boolean legacy_points;
boolean rasterizer_discard;
boolean multisample;
boolean rectangular_lines;
unsigned cullmode;
unsigned bottom_edge_rule;
float pixel_offset;

View File

@ -298,7 +298,7 @@ try_setup_line( struct lp_setup_context *setup,
int nr_planes = 4;
unsigned viewport_index = 0;
unsigned layer = 0;
float pixel_offset = setup->pixel_offset;
float pixel_offset = setup->multisample ? 0.0 : setup->pixel_offset;
/* linewidth should be interpreted as integer */
int fixed_width = util_iround(width) * FIXED_ONE;
@ -357,20 +357,20 @@ try_setup_line( struct lp_setup_context *setup,
info.v2 = v2;
if (setup->multisample) {
if (setup->rectangular_lines) {
float scale = (setup->line_width * 0.5f) / sqrtf(area);
int tx = subpixel_snap(-dy * scale);
int ty = subpixel_snap(+dx * scale);
x[0] = subpixel_snap(v1[0][0]) - tx;
x[1] = subpixel_snap(v2[0][0]) - tx;
x[2] = subpixel_snap(v2[0][0]) + tx;
x[3] = subpixel_snap(v1[0][0]) + tx;
x[0] = subpixel_snap(v1[0][0] - pixel_offset) - tx;
x[1] = subpixel_snap(v2[0][0] - pixel_offset) - tx;
x[2] = subpixel_snap(v2[0][0] - pixel_offset) + tx;
x[3] = subpixel_snap(v1[0][0] - pixel_offset) + tx;
y[0] = subpixel_snap(v1[0][1]) - ty;
y[1] = subpixel_snap(v2[0][1]) - ty;
y[2] = subpixel_snap(v2[0][1]) + ty;
y[3] = subpixel_snap(v1[0][1]) + ty;
y[0] = subpixel_snap(v1[0][1] - pixel_offset) - ty;
y[1] = subpixel_snap(v2[0][1] - pixel_offset) - ty;
y[2] = subpixel_snap(v2[0][1] - pixel_offset) + ty;
y[3] = subpixel_snap(v1[0][1] - pixel_offset) + ty;
} else if (fabsf(dx) >= fabsf(dy)) {
float dydx = dy / dx;

View File

@ -121,7 +121,8 @@ llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, void *handle)
lp_setup_set_flatshade_first( llvmpipe->setup,
state->lp_state.flatshade_first);
lp_setup_set_line_state( llvmpipe->setup,
state->lp_state.line_width);
state->lp_state.line_width,
state->lp_state.line_rectangular);
lp_setup_set_point_state( llvmpipe->setup,
state->lp_state.point_size,
state->lp_state.point_size_per_vertex,