Merge commit 'origin/gallium-master-merge'
[mesa.git] / src / gallium / drivers / i965simple / brw_eu_util.c
1 /*
2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4 develop this 3D driver.
5
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
13
14 The above copyright notice and this permission notice (including the
15 next paragraph) shall be included in all copies or substantial
16 portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
26 **********************************************************************/
27 /*
28 * Authors:
29 * Keith Whitwell <keith@tungstengraphics.com>
30 */
31
32
33 #include "brw_context.h"
34 #include "brw_defines.h"
35 #include "brw_eu.h"
36
37
38 void brw_math_invert( struct brw_compile *p,
39 struct brw_reg dst,
40 struct brw_reg src)
41 {
42 brw_math( p,
43 dst,
44 BRW_MATH_FUNCTION_INV,
45 BRW_MATH_SATURATE_NONE,
46 0,
47 src,
48 BRW_MATH_PRECISION_FULL,
49 BRW_MATH_DATA_VECTOR );
50 }
51
52
53
54 void brw_copy4(struct brw_compile *p,
55 struct brw_reg dst,
56 struct brw_reg src,
57 unsigned count)
58 {
59 unsigned i;
60
61 dst = vec4(dst);
62 src = vec4(src);
63
64 for (i = 0; i < count; i++)
65 {
66 unsigned delta = i*32;
67 brw_MOV(p, byte_offset(dst, delta), byte_offset(src, delta));
68 brw_MOV(p, byte_offset(dst, delta+16), byte_offset(src, delta+16));
69 }
70 }
71
72
73 void brw_copy8(struct brw_compile *p,
74 struct brw_reg dst,
75 struct brw_reg src,
76 unsigned count)
77 {
78 unsigned i;
79
80 dst = vec8(dst);
81 src = vec8(src);
82
83 for (i = 0; i < count; i++)
84 {
85 unsigned delta = i*32;
86 brw_MOV(p, byte_offset(dst, delta), byte_offset(src, delta));
87 }
88 }
89
90
91 void brw_copy_indirect_to_indirect(struct brw_compile *p,
92 struct brw_indirect dst_ptr,
93 struct brw_indirect src_ptr,
94 unsigned count)
95 {
96 unsigned i;
97
98 for (i = 0; i < count; i++)
99 {
100 unsigned delta = i*32;
101 brw_MOV(p, deref_4f(dst_ptr, delta), deref_4f(src_ptr, delta));
102 brw_MOV(p, deref_4f(dst_ptr, delta+16), deref_4f(src_ptr, delta+16));
103 }
104 }
105
106
107 void brw_copy_from_indirect(struct brw_compile *p,
108 struct brw_reg dst,
109 struct brw_indirect ptr,
110 unsigned count)
111 {
112 unsigned i;
113
114 dst = vec4(dst);
115
116 for (i = 0; i < count; i++)
117 {
118 unsigned delta = i*32;
119 brw_MOV(p, byte_offset(dst, delta), deref_4f(ptr, delta));
120 brw_MOV(p, byte_offset(dst, delta+16), deref_4f(ptr, delta+16));
121 }
122 }
123
124
125
126