[Mesa-dev] [PATCH] llvmpipe: we need to subdivide if fb is bigger in either direction

Brian Paul brian.e.paul at gmail.com
Wed Sep 25 10:12:46 PDT 2013


On Tue, Sep 24, 2013 at 2:26 PM, Zack Rusin <zackr at vmware.com> wrote:
> We need to subdivide triangles if either of the dimensions is
> larger than the max edge length, not when both of them are larger.
>
> Signed-off-by: Zack Rusin <zackr at vmware.com>
> ---
>  src/gallium/drivers/llvmpipe/lp_setup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
> index 5fde01f..c8199b4 100644
> --- a/src/gallium/drivers/llvmpipe/lp_setup.c
> +++ b/src/gallium/drivers/llvmpipe/lp_setup.c
> @@ -1015,7 +1015,7 @@ try_update_scene_state( struct lp_setup_context *setup )
>         * 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->subdivide_large_triangles = (setup->fb.width > 2048 ||
>                                            setup->fb.height > 2048);
>     }


Zack, did you actually find a test case where the old condition
failed?  I had done some testing of various image sizes when I added
this code.  The overflow issue only seemed to happen when both
dimensions exceeded the threshold.  I think this is because of the
arithmetic where we basically compute the cross product of two edge
vectors to get triangle area.  In that case we're multiplying dx * dy
and that only overflows when both are large numbers.  And dx and dy
can only both be large when the surface is large in both dimensions.

But anyway, this change is fine with me.  It's a safer check and still
allows surfaces up to 2Kx2K to skip subdivision.

-Brian


More information about the mesa-dev mailing list