From f26871163cc451587d980af2cf5c48405d39e9eb Mon Sep 17 00:00:00 2001 From: Samuel Iglesias Gonsalvez Date: Thu, 13 Mar 2014 16:17:39 +0100 Subject: [PATCH] i965: increase the antialiased line width by 0.25 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 --- 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