4 // Rodrigo Kumpera (rkumpera@novell.com)
6 // (C) 2008 Novell, Inc. (http://www.novell.com)
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 using System.Runtime.InteropServices;
32 [StructLayout(LayoutKind.Explicit, Pack = 0, Size = 16)]
33 public struct Vector2l
40 public long X { get { return x; } set { x = value; } }
41 public long Y { get { return y; } set { y = value; } }
43 public static Vector2l One
45 get { return new Vector2l (1); }
48 public static Vector2l Zero
50 get { return new Vector2l (0); }
53 public static Vector2l MinusOne
55 get { return new Vector2l (-1); }
58 [System.Runtime.CompilerServices.IndexerName ("Component")]
59 public unsafe long this [int index]
62 if ((index | 0x1) != 0x1) //index < 0 || index > 1
63 throw new ArgumentOutOfRangeException ("index");
64 fixed (long *v = &x) {
69 if ( (index | 0x1) != 0x1) //index < 0 || index > 1
70 throw new ArgumentOutOfRangeException ("index");
71 fixed (long *v = &x) {
72 * (v + index) = value;
77 public Vector2l (long x, long y)
83 public Vector2l (long l)
89 [Acceleration (AccelMode.SSE2)]
90 public static Vector2l operator + (Vector2l v1, Vector2l v2)
92 return new Vector2l (v1.x + v2.x, v1.y + v2.y);
95 [Acceleration (AccelMode.SSE2)]
96 public static Vector2l operator - (Vector2l v1, Vector2l v2)
98 return new Vector2l (v1.x - v2.x, v1.y - v2.y);
101 [Acceleration (AccelMode.SSE2)]
102 public static unsafe Vector2l operator << (Vector2l v1, int amount)
104 return new Vector2l (v1.x << amount, v1.y << amount);
107 [Acceleration (AccelMode.SSE2)]
108 public static Vector2l operator & (Vector2l v1, Vector2l v2)
110 return new Vector2l (v1.x & v2.x, v1.y & v2.y);
113 [Acceleration (AccelMode.SSE2)]
114 public static Vector2l operator | (Vector2l v1, Vector2l v2)
116 return new Vector2l (v1.x | v2.x, v1.y | v2.y);
119 [Acceleration (AccelMode.SSE2)]
120 public static Vector2l operator ^ (Vector2l v1, Vector2l v2)
122 return new Vector2l (v1.x ^ v2.x, v1.y ^ v2.y);
125 [Acceleration (AccelMode.SSE1)]
126 public static unsafe explicit operator Vector2d (Vector2l v)
128 Vector2d* p = (Vector2d*)&v;
132 [Acceleration (AccelMode.SSE1)]
133 public static unsafe explicit operator Vector4f (Vector2l v)
135 Vector4f* p = (Vector4f*)&v;
139 [Acceleration (AccelMode.SSE1)]
140 [CLSCompliant(false)]
141 public static unsafe explicit operator Vector2ul (Vector2l v)
143 Vector2ul* p = (Vector2ul*)&v;
147 [Acceleration (AccelMode.SSE1)]
148 public static unsafe explicit operator Vector4i (Vector2l v)
150 Vector4i* p = (Vector4i*)&v;
154 [Acceleration (AccelMode.SSE1)]
155 [CLSCompliant(false)]
156 public static unsafe explicit operator Vector4ui (Vector2l v)
158 Vector4ui* p = (Vector4ui*)&v;
162 [Acceleration (AccelMode.SSE1)]
163 public static unsafe explicit operator Vector8s (Vector2l v)
165 Vector8s* p = (Vector8s*)&v;
169 [Acceleration (AccelMode.SSE1)]
170 [CLSCompliant(false)]
171 public static unsafe explicit operator Vector8us (Vector2l v)
173 Vector8us* p = (Vector8us*)&v;
177 [Acceleration (AccelMode.SSE1)]
178 [CLSCompliant(false)]
179 public static unsafe explicit operator Vector16sb (Vector2l v)
181 Vector16sb* p = (Vector16sb*)&v;
185 [Acceleration (AccelMode.SSE1)]
186 public static unsafe explicit operator Vector16b (Vector2l v)
188 Vector16b* p = (Vector16b*)&v;
192 [Acceleration (AccelMode.SSE1)]
193 public static Vector2l LoadAligned (ref Vector2l v)
198 [Acceleration (AccelMode.SSE1)]
199 public static void StoreAligned (ref Vector2l res, Vector2l val)
204 [CLSCompliant(false)]
205 [Acceleration (AccelMode.SSE1)]
206 public static unsafe Vector2l LoadAligned (Vector2l *v)
211 [CLSCompliant(false)]
212 [Acceleration (AccelMode.SSE1)]
213 public static unsafe void StoreAligned (Vector2l *res, Vector2l val)
218 [Acceleration (AccelMode.SSE1)]
219 [CLSCompliant(false)]
220 public static void PrefetchTemporalAllCacheLevels (ref Vector2l res)
224 [Acceleration (AccelMode.SSE1)]
225 [CLSCompliant(false)]
226 public static void PrefetchTemporal1stLevelCache (ref Vector2l res)
230 [Acceleration (AccelMode.SSE1)]
231 [CLSCompliant(false)]
232 public static void PrefetchTemporal2ndLevelCache (ref Vector2l res)
236 [Acceleration (AccelMode.SSE1)]
237 [CLSCompliant(false)]
238 public static void PrefetchNonTemporal (ref Vector2l res)
242 [Acceleration (AccelMode.SSE1)]
243 [CLSCompliant(false)]
244 public static unsafe void PrefetchTemporalAllCacheLevels (Vector2l *res)
248 [Acceleration (AccelMode.SSE1)]
249 [CLSCompliant(false)]
250 public static unsafe void PrefetchTemporal1stLevelCache (Vector2l *res)
254 [Acceleration (AccelMode.SSE1)]
255 [CLSCompliant(false)]
256 public static unsafe void PrefetchTemporal2ndLevelCache (Vector2l *res)
260 [Acceleration (AccelMode.SSE1)]
261 [CLSCompliant(false)]
262 public static unsafe void PrefetchNonTemporal (Vector2l *res)
266 public override string ToString()
268 return "<" + x + ", " + y + ">";