The line antialiasing support in the HW doesn't compute properly the pixel coverage by the line when line width is equal to 1.0.
This patch increases a little bit the line width making the piglit's line-aa-width pass and fix some related bugs in applications like 1 pixel lines in octave plot aliased to 0. This patch is based on Eric Anholt's work on bug 28832. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=28832 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=60797 Signed-off-by: Samuel Iglesias Gonsalvez <sigles...@igalia.com> --- src/mesa/drivers/dri/i965/gen6_sf_state.c | 7 ++++++- src/mesa/drivers/dri/i965/gen7_sf_state.c | 7 ++++++- src/mesa/drivers/dri/i965/gen8_sf_state.c | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/gen6_sf_state.c b/src/mesa/drivers/dri/i965/gen6_sf_state.c index ec14be4..b46f09d 100644 --- a/src/mesa/drivers/dri/i965/gen6_sf_state.c +++ b/src/mesa/drivers/dri/i965/gen6_sf_state.c @@ -323,7 +323,12 @@ upload_sf_state(struct brw_context *brw) /* _NEW_LINE */ { - uint32_t line_width_u3_7 = U_FIXED(CLAMP(ctx->Line.Width, 0.0, 7.99), 7); + float line_width = ctx->Line.Width; + if (ctx->Line.SmoothFlag) + line_width += 0.25; + + uint32_t line_width_u3_7 = U_FIXED(CLAMP(line_width, ctx->Const.MinLineWidth, ctx->Const.MaxLineWidth), 7); + /* TODO: line width of 0 is not allowed when MSAA enabled */ if (line_width_u3_7 == 0) line_width_u3_7 = 1; diff --git a/src/mesa/drivers/dri/i965/gen7_sf_state.c b/src/mesa/drivers/dri/i965/gen7_sf_state.c index 7fe1435..49f85e9 100644 --- a/src/mesa/drivers/dri/i965/gen7_sf_state.c +++ b/src/mesa/drivers/dri/i965/gen7_sf_state.c @@ -191,7 +191,12 @@ upload_sf_state(struct brw_context *brw) /* _NEW_LINE */ { - uint32_t line_width_u3_7 = U_FIXED(CLAMP(ctx->Line.Width, 0.0, 7.99), 7); + float line_width = ctx->Line.Width; + if (ctx->Line.SmoothFlag) + line_width += 0.25; + + uint32_t line_width_u3_7 = U_FIXED(CLAMP(line_width, ctx->Const.MinLineWidth, ctx->Const.MaxLineWidth), 7); + /* TODO: line width of 0 is not allowed when MSAA enabled */ if (line_width_u3_7 == 0) line_width_u3_7 = 1; diff --git a/src/mesa/drivers/dri/i965/gen8_sf_state.c b/src/mesa/drivers/dri/i965/gen8_sf_state.c index 0693fee..eb3d8a3 100644 --- a/src/mesa/drivers/dri/i965/gen8_sf_state.c +++ b/src/mesa/drivers/dri/i965/gen8_sf_state.c @@ -120,7 +120,12 @@ upload_sf(struct brw_context *brw) dw1 = GEN6_SF_STATISTICS_ENABLE | GEN6_SF_VIEWPORT_TRANSFORM_ENABLE; /* _NEW_LINE */ - uint32_t line_width_u3_7 = U_FIXED(CLAMP(ctx->Line.Width, 0.0, 7.99), 7); + float line_width = ctx->Line.Width; + if (ctx->Line.SmoothFlag) + line_width += 0.25; + + uint32_t line_width_u3_7 = U_FIXED(CLAMP(line_width, ctx->Const.MinLineWidth, ctx->Const.MaxLineWidth), 7); + if (line_width_u3_7 == 0) line_width_u3_7 = 1; dw2 |= line_width_u3_7 << GEN6_SF_LINE_WIDTH_SHIFT; -- 1.9.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev