diff options
Diffstat (limited to 'src/mesa/shader/slang/library/slang_core.gc')
-rwxr-xr-x | src/mesa/shader/slang/library/slang_core.gc | 206 |
1 files changed, 116 insertions, 90 deletions
diff --git a/src/mesa/shader/slang/library/slang_core.gc b/src/mesa/shader/slang/library/slang_core.gc index 437040b330..d99eb10a8b 100755 --- a/src/mesa/shader/slang/library/slang_core.gc +++ b/src/mesa/shader/slang/library/slang_core.gc @@ -605,201 +605,249 @@ ivec4 __operator - (const ivec4 v) +//// dot product - - - -//// operator += - -void __operator += (inout float a, const float b) +float dot(const float a, const float b) { - __asm vec4_add a.x, a, b; + return a * b; } -void __operator -= (inout float a, const float b) +float dot(const vec2 a, const vec2 b) { - __asm vec4_subtract a.x, a, b; + return a.x * b.x + a.y * b.y; } -void __operator *= (inout float a, const float b) +float dot(const vec3 a, const vec3 b) { - __asm vec4_multiply a.x, a, b; + __asm vec3_dot __retVal, a, b; } -void __operator /= (inout float a, const float b) +float dot(const vec4 a, const vec4 b) { - float w; // = 1 / b - __asm float_rcp w.x, b; - __asm vec4_multiply a.x, a, w; + __asm vec4_dot __retVal, a, b; } -void __operator += (inout int a, const int b) { +//// int assignment operators + +void __operator += (inout int a, const int b) +{ a = int (float (a) + float (b)); } - -void __operator -= (inout int a, const int b) { +void __operator -= (inout int a, const int b) +{ a += -b; } - - -void __operator *= (inout int a, const int b) { +void __operator *= (inout int a, const int b) +{ a = int (float (a) * float (b)); } - -void __operator /= (inout int a, const int b) { +void __operator /= (inout int a, const int b) +{ a = int (float (a) / float (b)); } -void __operator += (inout vec2 v, const vec2 u) { + +//// ivec2 assignment operators + +void __operator += (inout ivec2 v, const ivec2 u) +{ v.x += u.x; v.y += u.y; } -void __operator -= (inout vec2 v, const vec2 u) { +void __operator -= (inout ivec2 v, const ivec2 u) +{ v.x -= u.x; v.y -= u.y; } -void __operator *= (inout vec2 v, const vec2 u) { +void __operator *= (inout ivec2 v, const ivec2 u) +{ v.x *= u.x; v.y *= u.y; } -void __operator /= (inout vec2 v, const vec2 u) { +void __operator /= (inout ivec2 v, const ivec2 u) +{ v.x /= u.x; v.y /= u.y; } -void __operator += (inout vec3 v, const vec3 u) { + +//// ivec3 assignment operators + +void __operator += (inout ivec3 v, const ivec3 u) +{ v.x += u.x; v.y += u.y; v.z += u.z; } -void __operator -= (inout vec3 v, const vec3 u) { +void __operator -= (inout ivec3 v, const ivec3 u) +{ v.x -= u.x; v.y -= u.y; v.z -= u.z; } -void __operator *= (inout vec3 v, const vec3 u) { +void __operator *= (inout ivec3 v, const ivec3 u) +{ v.x *= u.x; v.y *= u.y; v.z *= u.z; } -void __operator /= (inout vec3 v, const vec3 u) { +void __operator /= (inout ivec3 v, const ivec3 u) +{ v.x /= u.x; v.y /= u.y; v.z /= u.z; } -void __operator += (inout vec4 v, const vec4 u) { + +//// ivec4 assignment operators + +void __operator += (inout ivec4 v, const ivec4 u) { v.x += u.x; v.y += u.y; v.z += u.z; v.w += u.w; } -void __operator -= (inout vec4 v, const vec4 u) { +void __operator -= (inout ivec4 v, const ivec4 u) { v.x -= u.x; v.y -= u.y; v.z -= u.z; v.w -= u.w; } -void __operator *= (inout vec4 v, const vec4 u) { +void __operator *= (inout ivec4 v, const ivec4 u) { v.x *= u.x; v.y *= u.y; v.z *= u.z; v.w *= u.w; } -void __operator /= (inout vec4 v, const vec4 u) { +void __operator /= (inout ivec4 v, const ivec4 u) { v.x /= u.x; v.y /= u.y; v.z /= u.z; v.w /= u.w; } -void __operator += (inout ivec2 v, const ivec2 u) { + +//// float assignment operators + +void __operator += (inout float a, const float b) +{ + __asm vec4_add a.x, a, b; +} + +void __operator -= (inout float a, const float b) +{ + __asm vec4_subtract a.x, a, b; +} + +void __operator *= (inout float a, const float b) +{ + __asm vec4_multiply a.x, a, b; +} + +void __operator /= (inout float a, const float b) +{ + float w; // = 1 / b + __asm float_rcp w.x, b; + __asm vec4_multiply a.x, a, w; +} + + +//// vec2 assignment operators + +void __operator += (inout vec2 v, const vec2 u) +{ v.x += u.x; v.y += u.y; } -void __operator -= (inout ivec2 v, const ivec2 u) { +void __operator -= (inout vec2 v, const vec2 u) +{ v.x -= u.x; v.y -= u.y; } -void __operator *= (inout ivec2 v, const ivec2 u) { +void __operator *= (inout vec2 v, const vec2 u) +{ v.x *= u.x; v.y *= u.y; } -void __operator /= (inout ivec2 v, const ivec2 u) { +void __operator /= (inout vec2 v, const vec2 u) +{ v.x /= u.x; v.y /= u.y; } -void __operator += (inout ivec3 v, const ivec3 u) { - v.x += u.x; - v.y += u.y; - v.z += u.z; + +//// vec3 assignment operators + +void __operator += (inout vec3 v, const vec3 u) +{ + __asm vec4_add v.xyz, v, u; } -void __operator -= (inout ivec3 v, const ivec3 u) { - v.x -= u.x; - v.y -= u.y; - v.z -= u.z; +void __operator -= (inout vec3 v, const vec3 u) +{ + __asm vec4_subtract v.xyz, v, u; } -void __operator *= (inout ivec3 v, const ivec3 u) { - v.x *= u.x; - v.y *= u.y; - v.z *= u.z; +void __operator *= (inout vec3 v, const vec3 u) +{ + __asm vec4_multiply v.xyz, v, u; } -void __operator /= (inout ivec3 v, const ivec3 u) { +void __operator /= (inout vec3 v, const vec3 u) +{ +// XXX rcp v.x /= u.x; v.y /= u.y; v.z /= u.z; } -void __operator += (inout ivec4 v, const ivec4 u) { - v.x += u.x; - v.y += u.y; - v.z += u.z; - v.w += u.w; + +//// vec4 assignment operators + +void __operator += (inout vec4 v, const vec4 u) +{ + __asm vec4_add v, v, u; } -void __operator -= (inout ivec4 v, const ivec4 u) { - v.x -= u.x; - v.y -= u.y; - v.z -= u.z; - v.w -= u.w; +void __operator -= (inout vec4 v, const vec4 u) +{ + __asm vec4_subtract v, v, u; } -void __operator *= (inout ivec4 v, const ivec4 u) { - v.x *= u.x; - v.y *= u.y; - v.z *= u.z; - v.w *= u.w; +void __operator *= (inout vec4 v, const vec4 u) +{ + __asm vec4_multiply v, v, u; } -void __operator /= (inout ivec4 v, const ivec4 u) { +void __operator /= (inout vec4 v, const vec4 u) +{ +// XXX rcp v.x /= u.x; v.y /= u.y; v.z /= u.z; v.w /= u.w; } + + void __operator += (inout mat2 m, const mat2 n) { m[0] += n[0]; m[1] += n[1]; @@ -846,28 +894,6 @@ void __operator -= (inout mat3 m, const mat3 n) { } -//// dot (formerly in slang_common_builtin.gc) - -float dot(const float a, const float b) -{ - return a * b; -} - -float dot(const vec2 a, const vec2 b) -{ - return a.x * b.x + a.y * b.y; -} - -float dot(const vec3 a, const vec3 b) -{ - __asm vec3_dot __retVal, a, b; -} - -float dot(const vec4 a, const vec4 b) -{ - __asm vec4_dot __retVal, a, b; -} - |