summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/library/slang_core.gc
diff options
context:
space:
mode:
authorBrian <brian@yutani.localnet.net>2007-03-06 14:07:48 -0700
committerBrian <brian@yutani.localnet.net>2007-03-06 14:07:48 -0700
commite10a1457e827f9cfb18a4438f3254151ddf1d60b (patch)
tree3f7334c9d33bcec668549858cb3ee182e9e2ff7b /src/mesa/shader/slang/library/slang_core.gc
parent28ab1125c22bcb558e3b5e127d975120de76e103 (diff)
fix some int arithmetic problems
Diffstat (limited to 'src/mesa/shader/slang/library/slang_core.gc')
-rw-r--r--src/mesa/shader/slang/library/slang_core.gc130
1 files changed, 77 insertions, 53 deletions
diff --git a/src/mesa/shader/slang/library/slang_core.gc b/src/mesa/shader/slang/library/slang_core.gc
index 811568c7ba..7ff2151ce4 100644
--- a/src/mesa/shader/slang/library/slang_core.gc
+++ b/src/mesa/shader/slang/library/slang_core.gc
@@ -537,116 +537,140 @@ mat4 __constructor(const vec4 r0, const vec4 r1, const vec4 r2, const vec4 r3)
int __operator + (const int a, const int b)
{
- float x, y;
- int c;
- __asm int_to_float x, a;
- __asm int_to_float y, b;
- __asm vec4_add x.x, x.x, y.x;
- __asm float_to_int c, x;
- return c;
+// XXX If we ever have int registers, we'll do something like this:
+// XXX For now, mostly treat ints as floats.
+// float x, y;
+// __asm int_to_float x, a;
+// __asm int_to_float y, b;
+// __asm vec4_add x.x, x.x, y.x;
+// __asm float_to_int __retVal, x;
+ float x;
+ __asm vec4_add x, a, b;
+ __asm float_to_int __retVal, x;
}
int __operator - (const int a, const int b)
{
- float x, y;
- int c;
- __asm int_to_float x, a;
- __asm int_to_float y, b;
- __asm float_negate y, y;
- __asm vec4_add x.x, x.x, y.x;
- __asm float_to_int c, x;
- return c;
+ float x;
+ __asm vec4_subtract x, a, b;
+ __asm float_to_int __retVal, x;
}
int __operator * (const int a, const int b)
{
- float x, y;
- int c;
- __asm int_to_float x, a;
- __asm int_to_float y, b;
- __asm float_multiply x, x, y;
- __asm float_to_int c, x;
- return c;
+ float x;
+ __asm vec4_multiply x, a, b;
+ __asm float_to_int __retVal, x;
}
int __operator / (const int a, const int b)
{
- float x, y;
- int c;
- __asm int_to_float x, a;
- __asm int_to_float y, b;
- __asm float_divide x, x, y;
- __asm float_to_int c, x;
- return c;
+ float bInv, x;
+ __asm float_rcp bInv, b;
+ __asm vec4_multiply x, a, bInv;
+ __asm float_to_int __retVal, x;
}
//// Basic ivec2 operators
-ivec2 __operator + (const ivec2 v, const ivec2 u)
+ivec2 __operator + (const ivec2 a, const ivec2 b)
{
- return ivec2 (v.x + u.x, v.y + u.y);
+ vec2 x;
+ __asm vec4_add x, a, b;
+ __asm float_to_int __retVal, x;
}
-ivec2 __operator - (const ivec2 v, const ivec2 u)
+ivec2 __operator - (const ivec2 a, const ivec2 b)
{
- return ivec2 (v.x - u.x, v.y - u.y);
+ vec2 x;
+ __asm vec4_subtract x, a, b;
+ __asm float_to_int __retVal, x;
}
-ivec2 __operator * (const ivec2 v, const ivec2 u)
+ivec2 __operator * (const ivec2 a, const ivec2 b)
{
- return ivec2 (v.x * u.x, v.y * u.y);
+ vec2 x;
+ __asm vec4_multiply x, a, b;
+ __asm float_to_int __retVal, x;
}
-ivec2 __operator / (const ivec2 v, const ivec2 u)
+ivec2 __operator / (const ivec2 a, const ivec2 b)
{
- return ivec2 (v.x / u.x, v.y / u.y);
+ vec2 bInv, x;
+ __asm float_rcp bInv.x, b.x;
+ __asm float_rcp bInv.y, b.y;
+ __asm vec4_multiply x, a, bInv;
+ __asm float_to_int __retVal, x;
}
//// Basic ivec3 operators
-ivec3 __operator + (const ivec3 v, const ivec3 u)
+ivec3 __operator + (const ivec3 a, const ivec3 b)
{
- return ivec3 (v.x + u.x, v.y + u.y, v.z + u.z);
+ vec3 x;
+ __asm vec4_add x, a, b;
+ __asm float_to_int __retVal, x;
}
-ivec3 __operator - (const ivec3 v, const ivec3 u)
+ivec3 __operator - (const ivec3 a, const ivec3 b)
{
- return ivec3 (v.x - u.x, v.y - u.y, v.z - u.z);
+ vec3 x;
+ __asm vec4_subtract x, a, b;
+ __asm float_to_int __retVal, x;
}
-ivec3 __operator * (const ivec3 v, const ivec3 u)
+ivec3 __operator * (const ivec3 a, const ivec3 b)
{
- return ivec3 (v.x * u.x, v.y * u.y, v.z * u.z);
+ vec3 x;
+ __asm vec4_multiply x, a, b;
+ __asm float_to_int __retVal, x;
}
-ivec3 __operator / (const ivec3 v, const ivec3 u)
+ivec3 __operator / (const ivec3 a, const ivec3 b)
{
- return ivec3 (v.x / u.x, v.y / u.y, v.z / u.z);
+ vec3 bInv, x;
+ __asm float_rcp bInv.x, b.x;
+ __asm float_rcp bInv.y, b.y;
+ __asm float_rcp bInv.z, b.z;
+ __asm vec4_multiply x, a, bInv;
+ __asm float_to_int __retVal, x;
}
//// Basic ivec4 operators
-ivec4 __operator + (const ivec4 v, const ivec4 u)
+ivec4 __operator + (const ivec4 a, const ivec4 b)
{
- return ivec4 (v.x + u.x, v.y + u.y, v.z + u.z, v.w + u.w);
+ vec3 x;
+ __asm vec4_add x, a, b;
+ __asm float_to_int __retVal, x;
}
-ivec4 __operator - (const ivec4 v, const ivec4 u)
+ivec4 __operator - (const ivec4 a, const ivec4 b)
{
- return ivec4 (v.x - u.x, v.y - u.y, v.z - u.z, v.w - u.w);
+ vec4 x;
+ __asm vec4_subtract x, a, b;
+ __asm float_to_int __retVal, x;
}
-ivec4 __operator * (const ivec4 v, const ivec4 u)
+ivec4 __operator * (const ivec4 a, const ivec4 b)
{
- return ivec4 (v.x * u.x, v.y * u.y, v.z * u.z, v.w * u.w);
+ vec4 x;
+ __asm vec4_multiply x, a, b;
+ __asm float_to_int __retVal, x;
}
-ivec4 __operator / (const ivec4 v, const ivec4 u)
+ivec4 __operator / (const ivec4 a, const ivec4 b)
{
- return ivec4 (v.x / u.x, v.y / u.y, v.z / u.z, v.w / u.w);
+ vec4 bInv, x;
+ __asm float_rcp bInv.x, b.x;
+ __asm float_rcp bInv.y, b.y;
+ __asm float_rcp bInv.z, b.z;
+ __asm float_rcp bInv.w, b.w;
+ __asm vec4_multiply x, a, bInv;
+ __asm float_to_int __retVal, x;
}