diff options
author | Brian <brian@yutani.localnet.net> | 2007-01-19 12:19:38 -0700 |
---|---|---|
committer | Brian <brian@yutani.localnet.net> | 2007-01-19 12:19:38 -0700 |
commit | eff9690351c07940a976fade4302b480e9731917 (patch) | |
tree | ec47843be676ee6850b10e2543ca85c9e8a9a76b /src/mesa/shader/slang/library/slang_common_builtin.gc | |
parent | dceae2829e981236736513a95fc0e46564625d44 (diff) |
Rewrite normalize(vec3/vec4) to use one less register.
Diffstat (limited to 'src/mesa/shader/slang/library/slang_common_builtin.gc')
-rw-r--r-- | src/mesa/shader/slang/library/slang_common_builtin.gc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/mesa/shader/slang/library/slang_common_builtin.gc b/src/mesa/shader/slang/library/slang_common_builtin.gc index 822cc3e989..e32a8831dc 100644 --- a/src/mesa/shader/slang/library/slang_common_builtin.gc +++ b/src/mesa/shader/slang/library/slang_common_builtin.gc @@ -671,14 +671,23 @@ vec2 normalize(const vec2 v) vec3 normalize(const vec3 v) { - const float s = inversesqrt(dot(v, v)); - __asm vec4_multiply __retVal.xyz, v, s.xxx; +// const float s = inversesqrt(dot(v, v)); +// __retVal = v * s; +// XXX note, we _could_ use __retVal.w instead of tmp and and save a +// register, but that's actually a compilation error because v is a vec3 +// and the .w suffix is illegal. Oh well. + float tmp; + __asm vec3_dot tmp, v, v; + __asm float_rsq tmp, tmp; + __asm vec4_multiply __retVal.xyz, v, tmp.xxx; } vec4 normalize(const vec4 v) { - const float s = inversesqrt(dot(v, v)); - __asm vec4_multiply __retVal, v, s.xxxx; + float tmp; + __asm vec4_dot tmp, v, v; + __asm float_rsq tmp, tmp; + __asm vec4_multiply __retVal.xyz, v, tmp.xxx; } |