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 "cairoint.h"
34 #include "cairo-drm-intel-brw-eu.h"
35 
36 
brw_math_invert(struct brw_compile * p,struct brw_reg dst,struct brw_reg src)37 void brw_math_invert( struct brw_compile *p,
38 		      struct brw_reg dst,
39 		      struct brw_reg src)
40 {
41     brw_math( p,
42 	      dst,
43 	      BRW_MATH_FUNCTION_INV,
44 	      BRW_MATH_SATURATE_NONE,
45 	      0,
46 	      src,
47 	      BRW_MATH_PRECISION_FULL,
48 	      BRW_MATH_DATA_VECTOR );
49 }
50 
51 
52 
brw_copy4(struct brw_compile * p,struct brw_reg dst,struct brw_reg src,uint32_t count)53 void brw_copy4(struct brw_compile *p,
54 	       struct brw_reg dst,
55 	       struct brw_reg src,
56 	       uint32_t count)
57 {
58     uint32_t i;
59 
60     dst = vec4(dst);
61     src = vec4(src);
62 
63     for (i = 0; i < count; i++)
64     {
65 	uint32_t delta = i*32;
66 	brw_MOV(p, byte_offset(dst, delta),    byte_offset(src, delta));
67 	brw_MOV(p, byte_offset(dst, delta+16), byte_offset(src, delta+16));
68     }
69 }
70 
71 
brw_copy8(struct brw_compile * p,struct brw_reg dst,struct brw_reg src,uint32_t count)72 void brw_copy8(struct brw_compile *p,
73 	       struct brw_reg dst,
74 	       struct brw_reg src,
75 	       uint32_t count)
76 {
77     uint32_t i;
78 
79     dst = vec8(dst);
80     src = vec8(src);
81 
82     for (i = 0; i < count; i++)
83     {
84 	uint32_t delta = i*32;
85 	brw_MOV(p, byte_offset(dst, delta),    byte_offset(src, delta));
86     }
87 }
88 
89 
brw_copy_indirect_to_indirect(struct brw_compile * p,struct brw_indirect dst_ptr,struct brw_indirect src_ptr,uint32_t count)90 void brw_copy_indirect_to_indirect(struct brw_compile *p,
91 				   struct brw_indirect dst_ptr,
92 				   struct brw_indirect src_ptr,
93 				   uint32_t count)
94 {
95     uint32_t i;
96 
97     for (i = 0; i < count; i++)
98     {
99 	uint32_t delta = i*32;
100 	brw_MOV(p, deref_4f(dst_ptr, delta),    deref_4f(src_ptr, delta));
101 	brw_MOV(p, deref_4f(dst_ptr, delta+16), deref_4f(src_ptr, delta+16));
102     }
103 }
104 
105 
brw_copy_from_indirect(struct brw_compile * p,struct brw_reg dst,struct brw_indirect ptr,uint32_t count)106 void brw_copy_from_indirect(struct brw_compile *p,
107 			    struct brw_reg dst,
108 			    struct brw_indirect ptr,
109 			    uint32_t count)
110 {
111     uint32_t i;
112 
113     dst = vec4(dst);
114 
115     for (i = 0; i < count; i++)
116     {
117 	uint32_t delta = i*32;
118 	brw_MOV(p, byte_offset(dst, delta),    deref_4f(ptr, delta));
119 	brw_MOV(p, byte_offset(dst, delta+16), deref_4f(ptr, delta+16));
120     }
121 }
122