From edde6c77bd1cb91f6f7c42010919e6f406f507ce Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 25 Sep 2013 19:38:33 -0400 Subject: [PATCH] llvmpipe: abstract the code to set number of subpixel bits MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit As we're moving towards expanding the number of subpixel bits and the width of the variables used in the computations we need to make this code a bit more centralized. Signed-off-by: Zack Rusin Reviewed-by: José Fonseca Reviewed-by: Brian Paul --- src/gallium/drivers/llvmpipe/lp_rast.h | 9 +++++++++ src/gallium/drivers/llvmpipe/lp_setup.c | 14 +++++--------- src/gallium/drivers/llvmpipe/lp_setup_tri.c | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h index c57f2ea11de..43c598d5117 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.h +++ b/src/gallium/drivers/llvmpipe/lp_rast.h @@ -46,9 +46,18 @@ struct lp_scene; struct lp_fence; struct cmd_bin; +#define FIXED_TYPE_WIDTH 32 /** For sub-pixel positioning */ #define FIXED_ORDER 4 #define FIXED_ONE (1<draw_regions[i]); } } - /* 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. + /* + * Subdivide triangles if the framebuffer is larger than the + * MAX_FIXED_LENGTH. */ - setup->subdivide_large_triangles = (setup->fb.width > 2048 || - setup->fb.height > 2048); + setup->subdivide_large_triangles = (setup->fb.width > MAX_FIXED_LENGTH || + setup->fb.height > MAX_FIXED_LENGTH); } setup->dirty = 0; diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c index 051ffa09860..2164f3a1e3c 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c +++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c @@ -988,7 +988,7 @@ check_subdivide_triangle(struct lp_setup_context *setup, const float (*v2)[4], triangle_func_t tri) { - const float maxLen = 2048.0f; /* longest permissible edge, in pixels */ + const float maxLen = (float) MAX_FIXED_LENGTH; /* longest permissible edge, in pixels */ float dx10, dy10, len10; float dx21, dy21, len21; float dx02, dy02, len02; -- 2.30.2