From bdfbeb9633eb3f8cf1ad76723f6c3839e57a08a3 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 3 Apr 2013 02:49:56 +0200 Subject: gallivm: minor rho calculation optimization for 1 or 3 coords Using a different packing for the single coord case should save a shuffle. Plus some minor style fixes. Reviewed-by: Jose Fonseca --- src/gallium/auxiliary/gallivm/lp_bld_quad.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/gallium/auxiliary/gallivm/lp_bld_quad.c') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_quad.c b/src/gallium/auxiliary/gallivm/lp_bld_quad.c index 1955add..f2a762a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_quad.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_quad.c @@ -81,7 +81,8 @@ lp_build_ddy(struct lp_build_context *bld, /* * Helper for building packed ddx/ddy vector for one coord (scalar per quad * values). The vector will look like this (8-wide): - * dr1dx dr1dy _____ _____ dr2dx dr2dy _____ _____ + * dr1dx _____ -dr1dy _____ dr2dx _____ -dr2dy _____ + * This only requires one shuffle instead of two for more straightforward packing. */ LLVMValueRef lp_build_packed_ddx_ddy_onecoord(struct lp_build_context *bld, @@ -91,19 +92,15 @@ lp_build_packed_ddx_ddy_onecoord(struct lp_build_context *bld, LLVMBuilderRef builder = gallivm->builder; LLVMValueRef vec1, vec2; - /* same packing as _twocoord, but can use aos swizzle helper */ + /* use aos swizzle helper */ - /* - * XXX could make swizzle1 a noop swizzle by using right top/bottom - * pair for ddy - */ - static const unsigned char swizzle1[] = { - LP_BLD_QUAD_TOP_LEFT, LP_BLD_QUAD_TOP_LEFT, - LP_BLD_SWIZZLE_DONTCARE, LP_BLD_SWIZZLE_DONTCARE + static const unsigned char swizzle1[] = { /* no-op swizzle */ + LP_BLD_QUAD_TOP_LEFT, LP_BLD_SWIZZLE_DONTCARE, + LP_BLD_QUAD_BOTTOM_LEFT, LP_BLD_SWIZZLE_DONTCARE }; static const unsigned char swizzle2[] = { - LP_BLD_QUAD_TOP_RIGHT, LP_BLD_QUAD_BOTTOM_LEFT, - LP_BLD_SWIZZLE_DONTCARE, LP_BLD_SWIZZLE_DONTCARE + LP_BLD_QUAD_TOP_RIGHT, LP_BLD_SWIZZLE_DONTCARE, + LP_BLD_QUAD_TOP_LEFT, LP_BLD_SWIZZLE_DONTCARE }; vec1 = lp_build_swizzle_aos(bld, a, swizzle1); @@ -120,6 +117,7 @@ lp_build_packed_ddx_ddy_onecoord(struct lp_build_context *bld, * Helper for building packed ddx/ddy vector for one coord (scalar per quad * values). The vector will look like this (8-wide): * ds1dx ds1dy dt1dx dt1dy ds2dx ds2dy dt2dx dt2dy + * This only needs 2 (v)shufps. */ LLVMValueRef lp_build_packed_ddx_ddy_twocoord(struct lp_build_context *bld, -- cgit v1.1