disable under _SOLO build
[mesa.git] / src / mesa / drivers / dri / r200 / r200_vtxfmt_sse.c
1 /* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_vtxfmt_sse.c,v 1.1 2002/10/30 12:51:53 alanh Exp $ */
2 /*
3 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
4
5 The Weather Channel (TM) funded Tungsten Graphics to develop the
6 initial release of the Radeon 8500 driver under the XFree86 license.
7 This notice must be preserved.
8
9 Permission is hereby granted, free of charge, to any person obtaining
10 a copy of this software and associated documentation files (the
11 "Software"), to deal in the Software without restriction, including
12 without limitation the rights to use, copy, modify, merge, publish,
13 distribute, sublicense, and/or sell copies of the Software, and to
14 permit persons to whom the Software is furnished to do so, subject to
15 the following conditions:
16
17 The above copyright notice and this permission notice (including the
18 next paragraph) shall be included in all copies or substantial
19 portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
25 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
29 **************************************************************************/
30
31 /*
32 * Authors:
33 * Keith Whitwell <keith@tungstengraphics.com>
34 */
35
36 #include "glheader.h"
37 #include "imports.h"
38 #include "simple_list.h"
39 #include "r200_vtxfmt.h"
40
41 #if defined(USE_SSE_ASM)
42 #include "x86/common_x86_asm.h"
43
44 #define EXTERN( FUNC ) \
45 extern const char *FUNC; \
46 extern const char *FUNC##_end
47
48 EXTERN( _sse_Attribute2fv );
49 EXTERN( _sse_Attribute2f );
50 EXTERN( _sse_Attribute3fv );
51 EXTERN( _sse_Attribute3f );
52 EXTERN( _sse_MultiTexCoord2fv );
53 EXTERN( _sse_MultiTexCoord2f );
54 EXTERN( _sse_MultiTexCoord2fv_2 );
55 EXTERN( _sse_MultiTexCoord2f_2 );
56
57 /* Build specialized versions of the immediate calls on the fly for
58 * the current state.
59 */
60
61 static struct dynfn *r200_makeSSEAttribute2fv( struct dynfn * cache, const int * key,
62 const char * name, void * dest)
63 {
64 struct dynfn *dfn = MALLOC_STRUCT( dynfn );
65
66 if (R200_DEBUG & DEBUG_CODEGEN)
67 fprintf(stderr, "%s 0x%08x\n", name, key[0] );
68
69 DFN ( _sse_Attribute2fv, (*cache) );
70 FIXUP(dfn->code, 10, 0x0, (int)dest);
71 return dfn;
72 }
73
74 static struct dynfn *r200_makeSSEAttribute2f( struct dynfn * cache, const int * key,
75 const char * name, void * dest )
76 {
77 struct dynfn *dfn = MALLOC_STRUCT( dynfn );
78
79 if (R200_DEBUG & DEBUG_CODEGEN)
80 fprintf(stderr, "%s 0x%08x\n", name, key[0] );
81
82 DFN ( _sse_Attribute2f, (*cache) );
83 FIXUP(dfn->code, 8, 0x0, (int)dest);
84 return dfn;
85 }
86
87 static struct dynfn *r200_makeSSEAttribute3fv( struct dynfn * cache, const int * key,
88 const char * name, void * dest)
89 {
90 struct dynfn *dfn = MALLOC_STRUCT( dynfn );
91
92 if (R200_DEBUG & DEBUG_CODEGEN)
93 fprintf(stderr, "%s 0x%08x\n", name, key[0] );
94
95 DFN ( _sse_Attribute3fv, (*cache) );
96 FIXUP(dfn->code, 13, 0x0, (int)dest);
97 FIXUP(dfn->code, 18, 0x8, 8+(int)dest);
98 return dfn;
99 }
100
101 static struct dynfn *r200_makeSSEAttribute3f( struct dynfn * cache, const int * key,
102 const char * name, void * dest )
103 {
104 struct dynfn *dfn = MALLOC_STRUCT( dynfn );
105
106 if (R200_DEBUG & DEBUG_CODEGEN)
107 fprintf(stderr, "%s 0x%08x\n", name, key[0] );
108
109 DFN ( _sse_Attribute3f, (*cache) );
110 FIXUP(dfn->code, 12, 0x0, (int)dest);
111 FIXUP(dfn->code, 17, 0x8, 8+(int)dest);
112 return dfn;
113 }
114
115 static struct dynfn *r200_makeSSENormal3fv( GLcontext *ctx, const int *key )
116 {
117 r200ContextPtr rmesa = R200_CONTEXT(ctx);
118
119 return r200_makeSSEAttribute3fv( & rmesa->vb.dfn_cache.Normal3fv, key,
120 __FUNCTION__, rmesa->vb.normalptr );
121 }
122
123 static struct dynfn *r200_makeSSENormal3f( GLcontext *ctx, const int * key )
124 {
125 r200ContextPtr rmesa = R200_CONTEXT(ctx);
126
127 return r200_makeSSEAttribute3f( & rmesa->vb.dfn_cache.Normal3f, key,
128 __FUNCTION__, rmesa->vb.normalptr );
129 }
130
131 static struct dynfn *r200_makeSSEColor3fv( GLcontext *ctx, const int * key )
132 {
133 if (VTX_COLOR(key[0],0) != R200_VTX_FP_RGB)
134 return 0;
135 else
136 {
137 r200ContextPtr rmesa = R200_CONTEXT(ctx);
138
139 return r200_makeSSEAttribute3fv( & rmesa->vb.dfn_cache.Color3fv, key,
140 __FUNCTION__, rmesa->vb.floatcolorptr );
141 }
142 }
143
144 static struct dynfn *r200_makeSSEColor3f( GLcontext *ctx, const int * key )
145 {
146 if (VTX_COLOR(key[0],0) != R200_VTX_FP_RGB)
147 return 0;
148 else
149 {
150 r200ContextPtr rmesa = R200_CONTEXT(ctx);
151
152 return r200_makeSSEAttribute3f( & rmesa->vb.dfn_cache.Color3f, key,
153 __FUNCTION__, rmesa->vb.floatcolorptr );
154 }
155 }
156
157 static struct dynfn *r200_makeSSETexCoord2fv( GLcontext *ctx, const int * key )
158 {
159 r200ContextPtr rmesa = R200_CONTEXT(ctx);
160
161 return r200_makeSSEAttribute2fv( & rmesa->vb.dfn_cache.TexCoord2fv, key,
162 __FUNCTION__, rmesa->vb.texcoordptr[0] );
163 }
164
165 static struct dynfn *r200_makeSSETexCoord2f( GLcontext *ctx, const int * key )
166 {
167 r200ContextPtr rmesa = R200_CONTEXT(ctx);
168
169 return r200_makeSSEAttribute2f( & rmesa->vb.dfn_cache.TexCoord2f, key,
170 __FUNCTION__, rmesa->vb.texcoordptr[0] );
171 }
172
173 static struct dynfn *r200_makeSSEMultiTexCoord2fv( GLcontext *ctx, const int * key )
174 {
175 struct dynfn *dfn = MALLOC_STRUCT( dynfn );
176 r200ContextPtr rmesa = R200_CONTEXT(ctx);
177
178 if (R200_DEBUG & DEBUG_CODEGEN)
179 fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key[0] );
180
181 if (rmesa->vb.texcoordptr[1] == rmesa->vb.texcoordptr[0]+4) {
182 DFN ( _sse_MultiTexCoord2fv, rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
183 FIXUP(dfn->code, 18, 0xdeadbeef, (int)rmesa->vb.texcoordptr[0]);
184 } else {
185 DFN ( _sse_MultiTexCoord2fv_2, rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
186 FIXUP(dfn->code, 14, 0x0, (int)rmesa->vb.texcoordptr);
187 }
188 return dfn;
189 }
190
191 static struct dynfn *r200_makeSSEMultiTexCoord2f( GLcontext *ctx, const int * key )
192 {
193 struct dynfn *dfn = MALLOC_STRUCT( dynfn );
194 r200ContextPtr rmesa = R200_CONTEXT(ctx);
195
196 if (R200_DEBUG & DEBUG_CODEGEN)
197 fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key[0] );
198
199 if (rmesa->vb.texcoordptr[1] == rmesa->vb.texcoordptr[0]+4) {
200 DFN ( _sse_MultiTexCoord2f, rmesa->vb.dfn_cache.MultiTexCoord2fARB );
201 FIXUP(dfn->code, 16, 0xdeadbeef, (int)rmesa->vb.texcoordptr[0]);
202 } else {
203 DFN ( _sse_MultiTexCoord2f_2, rmesa->vb.dfn_cache.MultiTexCoord2fARB );
204 FIXUP(dfn->code, 15, 0x0, (int)rmesa->vb.texcoordptr);
205 }
206 return dfn;
207 }
208
209 void r200InitSSECodegen( struct dfn_generators *gen )
210 {
211 if ( cpu_has_xmm ) {
212 gen->Normal3fv = (void *) r200_makeSSENormal3fv;
213 gen->Normal3f = (void *) r200_makeSSENormal3f;
214 gen->Color3fv = (void *) r200_makeSSEColor3fv;
215 gen->Color3f = (void *) r200_makeSSEColor3f;
216 gen->TexCoord2fv = (void *) r200_makeSSETexCoord2fv;
217 gen->TexCoord2f = (void *) r200_makeSSETexCoord2f;
218 gen->MultiTexCoord2fvARB = (void *) r200_makeSSEMultiTexCoord2fv;
219 gen->MultiTexCoord2fARB = (void *) r200_makeSSEMultiTexCoord2f;
220 }
221 }
222
223 #else
224
225 void r200InitSSECodegen( struct dfn_generators *gen )
226 {
227 (void) gen;
228 }
229
230 #endif