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