summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe/lp_setup.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2013-03-25 22:02:47 -0600
committerBrian Paul <[email protected]>2013-04-01 08:40:35 -0600
commit1165ff1af1853c9f1156221e1225ed5fb92a4507 (patch)
treeade105268a8770762a507d38af4f1feed18c8427 /src/gallium/drivers/llvmpipe/lp_setup.c
parent95df2b28831147b3e7ce2a3b6257bf60c46b4ab4 (diff)
llvmpipe: use triangle subdivision to avoid fixed-point overflow issues
If we're drawing to a surface that's 2048 x 2048 pixels or larger there's danger of fixed-point overflow in the triangle rasterization code. That leads to various rendering glitches. Rather than implement some intricate changes to the rasterization code, simply subdivide triangles into smaller subtriangles to avoid the issue. Only do this when the drawing surface is larger than 2048 by 2048. Reviewed-by: José Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_setup.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index 299fd65ff06..c119395a9d6 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -1010,6 +1010,16 @@ try_update_scene_state( struct lp_setup_context *setup )
u_rect_possible_intersection(&setup->scissor,
&setup->draw_region);
}
+ /* If the framebuffer is large we have to think about fixed-point
+ * integer overflow. For 2K by 2K images, coordinates need 15 bits
+ * (2^11 + 4 subpixel bits). The product of two such numbers would
+ * use 30 bits. Any larger and we could overflow a 32-bit int.
+ *
+ * To cope with this problem we check if triangles are large and
+ * subdivide them if needed.
+ */
+ setup->subdivide_large_triangles = (setup->fb.width > 2048 &&
+ setup->fb.height > 2048);
}
setup->dirty = 0;