From d61835b12f0fff4aa80d451b4a4444353127bdbd Mon Sep 17 00:00:00 2001 From: nobled Date: Fri, 6 Aug 2010 17:32:29 +0000 Subject: [PATCH] llvmpipe: Always use floating-point operators for floating-point types See: http://bugs.freedesktop.org/29404 http://bugs.freedesktop.org/29407 --- src/gallium/drivers/llvmpipe/lp_bld_interp.c | 34 +++++++++++++++++++------- 1 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_interp.c b/src/gallium/drivers/llvmpipe/lp_bld_interp.c index 78744da..4ccda4e 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_interp.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_interp.c @@ -141,7 +141,10 @@ coeffs_init(struct lp_build_interp_soa_context *bld, else { dadx = LLVMBuildLoad(builder, LLVMBuildGEP(builder, dadx_ptr, &index, 1, ""), ""); dady = LLVMBuildLoad(builder, LLVMBuildGEP(builder, dady_ptr, &index, 1, ""), ""); - dadxy = LLVMBuildAdd(builder, dadx, dady, ""); + if (coeff_bld->type.floating) + dadxy = LLVMBuildFAdd(builder, dadx, dady, ""); + else + dadxy = LLVMBuildAdd(builder, dadx, dady, ""); attrib_name(dadx, attrib, chan, ".dadx"); attrib_name(dady, attrib, chan, ".dady"); attrib_name(dadxy, attrib, chan, ".dadxy"); @@ -177,7 +180,10 @@ coeffs_init(struct lp_build_interp_soa_context *bld, * dadq2 = 2 * dq */ - dadq2 = LLVMBuildAdd(builder, dadq, dadq, ""); + if (coeff_bld->type.floating) + dadq2 = LLVMBuildFAdd(builder, dadq, dadq, ""); + else + dadq2 = LLVMBuildAdd(builder, dadq, dadq, ""); /* * a = a0 + x * dadx + y * dady @@ -193,12 +199,19 @@ coeffs_init(struct lp_build_interp_soa_context *bld, a = a0; if (interp != LP_INTERP_CONSTANT && interp != LP_INTERP_FACING) { - a = LLVMBuildAdd(builder, a, - LLVMBuildMul(builder, bld->x, dadx, ""), - ""); - a = LLVMBuildAdd(builder, a, - LLVMBuildMul(builder, bld->y, dady, ""), - ""); + LLVMValueRef tmp; + if (coeff_bld->type.floating) { + tmp = LLVMBuildFMul(builder, bld->x, dadx, ""); + a = LLVMBuildFAdd(builder, a, tmp, ""); + tmp = LLVMBuildFMul(builder, bld->y, dady, ""); + a = LLVMBuildFAdd(builder, a, tmp, ""); + } + else { + tmp = LLVMBuildMul(builder, bld->x, dadx, ""); + a = LLVMBuildAdd(builder, a, tmp, ""); + tmp = LLVMBuildMul(builder, bld->y, dady, ""); + a = LLVMBuildAdd(builder, a, tmp, ""); + } } } @@ -212,7 +225,10 @@ coeffs_init(struct lp_build_interp_soa_context *bld, * Compute the attrib values on the upper-left corner of each quad. */ - a = LLVMBuildAdd(builder, a, dadq2, ""); + if (coeff_bld->type.floating) + a = LLVMBuildFAdd(builder, a, dadq2, ""); + else + a = LLVMBuildAdd(builder, a, dadq2, ""); /* * a *= 1 / w -- 1.5.4.3