From 42b262d01a2b0f676ead098c09e33e387b8a5e3a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 11 Aug 2008 17:35:21 -0600 Subject: [PATCH] mesa: glsl: better mod() functions --- .../slang/library/slang_common_builtin.gc | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/src/mesa/shader/slang/library/slang_common_builtin.gc b/src/mesa/shader/slang/library/slang_common_builtin.gc index 18b38af7586..e908e6c9401 100644 --- a/src/mesa/shader/slang/library/slang_common_builtin.gc +++ b/src/mesa/shader/slang/library/slang_common_builtin.gc @@ -872,35 +872,29 @@ vec4 mod(const vec4 a, const float b) vec2 mod(const vec2 a, const vec2 b) { - float oneOverBx, oneOverBy; - __asm float_rcp oneOverBx, b.x; - __asm float_rcp oneOverBy, b.y; - __retVal.x = a.x - b.x * floor(a.x * oneOverBx); - __retVal.y = a.y - b.y * floor(a.y * oneOverBy); + vec2 oneOverB; + __asm float_rcp oneOverB.x, b.x; + __asm float_rcp oneOverB.y, b.y; + __retVal = a - b * floor(a * oneOverB); } vec3 mod(const vec3 a, const vec3 b) { - float oneOverBx, oneOverBy, oneOverBz; - __asm float_rcp oneOverBx, b.x; - __asm float_rcp oneOverBy, b.y; - __asm float_rcp oneOverBz, b.z; - __retVal.x = a.x - b.x * floor(a.x * oneOverBx); - __retVal.y = a.y - b.y * floor(a.y * oneOverBy); - __retVal.z = a.z - b.z * floor(a.z * oneOverBz); + vec3 oneOverB; + __asm float_rcp oneOverB.x, b.x; + __asm float_rcp oneOverB.y, b.y; + __asm float_rcp oneOverB.z, b.z; + __retVal = a - b * floor(a * oneOverB); } vec4 mod(const vec4 a, const vec4 b) { - float oneOverBx, oneOverBy, oneOverBz, oneOverBw; - __asm float_rcp oneOverBx, b.x; - __asm float_rcp oneOverBy, b.y; - __asm float_rcp oneOverBz, b.z; - __asm float_rcp oneOverBw, b.w; - __retVal.x = a.x - b.x * floor(a.x * oneOverBx); - __retVal.y = a.y - b.y * floor(a.y * oneOverBy); - __retVal.z = a.z - b.z * floor(a.z * oneOverBz); - __retVal.w = a.w - b.w * floor(a.w * oneOverBw); + vec4 oneOverB; + __asm float_rcp oneOverB.x, b.x; + __asm float_rcp oneOverB.y, b.y; + __asm float_rcp oneOverB.z, b.z; + __asm float_rcp oneOverB.w, b.w; + __retVal = a - b * floor(a * oneOverB); } -- 2.30.2