diff options
author | Brian Paul <[email protected]> | 2010-03-29 11:21:26 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2010-03-29 11:47:38 -0600 |
commit | ab0b9f80f45fcab55155b0a16b91a56ff4b3db1e (patch) | |
tree | eaa472ecc0e94a5af28a1021814f063cda1bb967 /src/mesa/shader/slang/library | |
parent | 588dd187c45490368354f340f5175d2c4d7cbd3c (diff) |
glsl: remove rcp from sqrt()
Per a patch from Marek Olšák, we can simply multiply the incoming
value by 1/sqrt(x) instead of using rcp.
We're keeping the x==0 check to avoid generating NaN for sqrt(0).
Diffstat (limited to 'src/mesa/shader/slang/library')
-rw-r--r-- | src/mesa/shader/slang/library/slang_common_builtin.gc | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/mesa/shader/slang/library/slang_common_builtin.gc b/src/mesa/shader/slang/library/slang_common_builtin.gc index a25ca55bc42..3d464630df2 100644 --- a/src/mesa/shader/slang/library/slang_common_builtin.gc +++ b/src/mesa/shader/slang/library/slang_common_builtin.gc @@ -605,7 +605,7 @@ float sqrt(const float x) const float nx = -x; float r; __asm float_rsq r, x; - __asm float_rcp r, r; + r = r * x; __asm vec4_cmp __retVal, nx, r, 0.0; } @@ -615,8 +615,7 @@ vec2 sqrt(const vec2 x) vec2 r; __asm float_rsq r.x, x.x; __asm float_rsq r.y, x.y; - __asm float_rcp r.x, r.x; - __asm float_rcp r.y, r.y; + r = r * x; __asm vec4_cmp __retVal, nx, r, zero; } @@ -627,9 +626,7 @@ vec3 sqrt(const vec3 x) __asm float_rsq r.x, x.x; __asm float_rsq r.y, x.y; __asm float_rsq r.z, x.z; - __asm float_rcp r.x, r.x; - __asm float_rcp r.y, r.y; - __asm float_rcp r.z, r.z; + r = r * x; __asm vec4_cmp __retVal, nx, r, zero; } @@ -641,10 +638,7 @@ vec4 sqrt(const vec4 x) __asm float_rsq r.y, x.y; __asm float_rsq r.z, x.z; __asm float_rsq r.w, x.w; - __asm float_rcp r.x, r.x; - __asm float_rcp r.y, r.y; - __asm float_rcp r.z, r.z; - __asm float_rcp r.w, r.w; + r = r * x; __asm vec4_cmp __retVal, nx, r, zero; } |