Re: [Mesa-dev] [PATCH] glsl: Fix type error when lowering integer divisions

2011-08-15 Thread Paul Berry
On 13 August 2011 09:58, Kenneth Graunke kenn...@whitecape.org wrote: On 08/12/2011 10:38 AM, Paul Berry wrote: This patch fixes a bug when lowering an integer division:   x/y to a multiplication by a reciprocal:   int(float(x)*reciprocal(float(y))) If x was a a plain int and y was an

Re: [Mesa-dev] [PATCH] glsl: Fix type error when lowering integer divisions

2011-08-15 Thread Jose Fonseca
- Original Message - On 13 August 2011 09:58, Kenneth Graunke kenn...@whitecape.org wrote: On 08/12/2011 10:38 AM, Paul Berry wrote: This patch fixes a bug when lowering an integer division:   x/y to a multiplication by a reciprocal:  

Re: [Mesa-dev] [PATCH] glsl: Fix type error when lowering integer divisions

2011-08-15 Thread Paul Berry
On 15 August 2011 08:50, Jose Fonseca jfons...@vmware.com wrote: In places you don't have native int division support, you could use one Newton-Raphson iteration step for almost accurate results, assuggested accuracy of SSE2's RCPPS instructions. See for reference the following llvmpipe

Re: [Mesa-dev] [PATCH] glsl: Fix type error when lowering integer divisions

2011-08-15 Thread Paul Berry
On 15 August 2011 10:11, Dan McCabe zen3d.li...@gmail.com wrote: You might also want to consider implementing    quotient = int((float(x) + 0.5 * float(y)) * reciprocal(float(y))); This rounds the result to the nearest integer rather then flooring the result and is arguably faster (assuming

Re: [Mesa-dev] [PATCH] glsl: Fix type error when lowering integer divisions

2011-08-15 Thread Ian Romanick
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 08/12/2011 10:38 AM, Paul Berry wrote: This patch fixes a bug when lowering an integer division: x/y to a multiplication by a reciprocal: int(float(x)*reciprocal(float(y))) If x was a a plain int and y was an ivecN, the lowering

Re: [Mesa-dev] [PATCH] glsl: Fix type error when lowering integer divisions

2011-08-15 Thread Dan McCabe
On 08/15/2011 10:45 AM, Paul Berry wrote: On 15 August 2011 10:11, Dan McCabezen3d.li...@gmail.com wrote: You might also want to consider implementing quotient = int((float(x) + 0.5 * float(y)) * reciprocal(float(y))); This rounds the result to the nearest integer rather then flooring the

Re: [Mesa-dev] [PATCH] glsl: Fix type error when lowering integer divisions

2011-08-13 Thread Kenneth Graunke
On 08/12/2011 10:38 AM, Paul Berry wrote: This patch fixes a bug when lowering an integer division: x/y to a multiplication by a reciprocal: int(float(x)*reciprocal(float(y))) If x was a a plain int and y was an ivecN, the lowering pass incorrectly assigned the type of the product to

Re: [Mesa-dev] [PATCH] glsl: Fix type error when lowering integer divisions

2011-08-13 Thread Eric Anholt
On Fri, 12 Aug 2011 10:38:35 -0700, Paul Berry stereotype...@gmail.com wrote: This patch fixes a bug when lowering an integer division: x/y to a multiplication by a reciprocal: int(float(x)*reciprocal(float(y))) If x was a a plain int and y was an ivecN, the lowering pass

[Mesa-dev] [PATCH] glsl: Fix type error when lowering integer divisions

2011-08-12 Thread Paul Berry
This patch fixes a bug when lowering an integer division: x/y to a multiplication by a reciprocal: int(float(x)*reciprocal(float(y))) If x was a a plain int and y was an ivecN, the lowering pass incorrectly assigned the type of the product to be float, when in fact it should be vecN. This