summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2018-08-21 11:30:09 -0700
committerKenneth Graunke <[email protected]>2019-02-21 10:26:08 -0800
commitd2516358f98f2770b9bc1e8669520a5a3e19f86d (patch)
tree50408dc79d92b72478e21ffb41b3dd966188d3b2
parent701b47a197f8ec0b308e52002bc59614943fd2d1 (diff)
iris: fix line-aa-width
we should probably move the roundf to st_atom_raster
-rw-r--r--src/gallium/drivers/iris/iris_state.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c
index eb84cd290a0..055fddff82c 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -824,6 +824,36 @@ struct iris_rasterizer_state {
uint16_t sprite_coord_enable;
};
+static float
+get_line_width(const struct pipe_rasterizer_state *state)
+{
+ float line_width = state->line_width;
+
+ /* From the OpenGL 4.4 spec:
+ *
+ * "The actual width of non-antialiased lines is determined by rounding
+ * the supplied width to the nearest integer, then clamping it to the
+ * implementation-dependent maximum non-antialiased line width."
+ */
+ if (!state->multisample && !state->line_smooth)
+ line_width = roundf(state->line_width);
+
+ if (!state->multisample && state->line_smooth && line_width < 1.5f) {
+ /* For 1 pixel line thickness or less, the general anti-aliasing
+ * algorithm gives up, and a garbage line is generated. Setting a
+ * Line Width of 0.0 specifies the rasterization of the "thinnest"
+ * (one-pixel-wide), non-antialiased lines.
+ *
+ * Lines rendered with zero Line Width are rasterized using the
+ * "Grid Intersection Quantization" rules as specified by the
+ * "Zero-Width (Cosmetic) Line Rasterization" section of the docs.
+ */
+ line_width = 0.0f;
+ }
+
+ return line_width;
+}
+
/**
* The pipe->create_rasterizer_state() driver hook.
*/
@@ -866,6 +896,8 @@ iris_create_rasterizer_state(struct pipe_context *ctx,
cso->line_stipple_enable = state->line_stipple_enable;
cso->poly_stipple_enable = state->poly_stipple_enable;
+ float line_width = get_line_width(state);
+
iris_pack_command(GENX(3DSTATE_SF), cso->sf, sf) {
sf.StatisticsEnable = true;
sf.ViewportTransformEnable = true;
@@ -873,7 +905,7 @@ iris_create_rasterizer_state(struct pipe_context *ctx,
sf.LineEndCapAntialiasingRegionWidth =
state->line_smooth ? _10pixels : _05pixels;
sf.LastPixelEnable = state->line_last_pixel;
- sf.LineWidth = state->line_width;
+ sf.LineWidth = line_width;
sf.SmoothPointEnable = state->point_smooth;
sf.PointWidthSource = state->point_size_per_vertex ? Vertex : State;
sf.PointWidth = state->point_size;