1 /* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_vtxfmt_sse.c,v 1.1 2002/10/30 12:51:53 alanh Exp $ */
3 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
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.
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:
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.
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.
29 **************************************************************************/
33 * Keith Whitwell <keith@tungstengraphics.com>
38 #include "simple_list.h"
39 #include "r200_vtxfmt.h"
41 #if defined(USE_SSE_ASM)
42 #include "x86/common_x86_asm.h"
44 #define EXTERN( FUNC ) \
45 extern const char *FUNC; \
46 extern const char *FUNC##_end
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
);
57 /* Build specialized versions of the immediate calls on the fly for
61 static struct dynfn
*r200_makeSSEAttribute2fv( struct dynfn
* cache
, const int * key
,
62 const char * name
, void * dest
)
64 struct dynfn
*dfn
= MALLOC_STRUCT( dynfn
);
66 if (R200_DEBUG
& DEBUG_CODEGEN
)
67 fprintf(stderr
, "%s 0x%08x\n", name
, key
[0] );
69 DFN ( _sse_Attribute2fv
, (*cache
) );
70 FIXUP(dfn
->code
, 10, 0x0, (int)dest
);
74 static struct dynfn
*r200_makeSSEAttribute2f( struct dynfn
* cache
, const int * key
,
75 const char * name
, void * dest
)
77 struct dynfn
*dfn
= MALLOC_STRUCT( dynfn
);
79 if (R200_DEBUG
& DEBUG_CODEGEN
)
80 fprintf(stderr
, "%s 0x%08x\n", name
, key
[0] );
82 DFN ( _sse_Attribute2f
, (*cache
) );
83 FIXUP(dfn
->code
, 8, 0x0, (int)dest
);
87 static struct dynfn
*r200_makeSSEAttribute3fv( struct dynfn
* cache
, const int * key
,
88 const char * name
, void * dest
)
90 struct dynfn
*dfn
= MALLOC_STRUCT( dynfn
);
92 if (R200_DEBUG
& DEBUG_CODEGEN
)
93 fprintf(stderr
, "%s 0x%08x\n", name
, key
[0] );
95 DFN ( _sse_Attribute3fv
, (*cache
) );
96 FIXUP(dfn
->code
, 13, 0x0, (int)dest
);
97 FIXUP(dfn
->code
, 18, 0x8, 8+(int)dest
);
101 static struct dynfn
*r200_makeSSEAttribute3f( struct dynfn
* cache
, const int * key
,
102 const char * name
, void * dest
)
104 struct dynfn
*dfn
= MALLOC_STRUCT( dynfn
);
106 if (R200_DEBUG
& DEBUG_CODEGEN
)
107 fprintf(stderr
, "%s 0x%08x\n", name
, key
[0] );
109 DFN ( _sse_Attribute3f
, (*cache
) );
110 FIXUP(dfn
->code
, 12, 0x0, (int)dest
);
111 FIXUP(dfn
->code
, 17, 0x8, 8+(int)dest
);
115 static struct dynfn
*r200_makeSSENormal3fv( GLcontext
*ctx
, const int *key
)
117 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
119 return r200_makeSSEAttribute3fv( & rmesa
->vb
.dfn_cache
.Normal3fv
, key
,
120 __FUNCTION__
, rmesa
->vb
.normalptr
);
123 static struct dynfn
*r200_makeSSENormal3f( GLcontext
*ctx
, const int * key
)
125 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
127 return r200_makeSSEAttribute3f( & rmesa
->vb
.dfn_cache
.Normal3f
, key
,
128 __FUNCTION__
, rmesa
->vb
.normalptr
);
131 static struct dynfn
*r200_makeSSEColor3fv( GLcontext
*ctx
, const int * key
)
133 if (VTX_COLOR(key
[0],0) != R200_VTX_FP_RGB
)
137 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
139 return r200_makeSSEAttribute3fv( & rmesa
->vb
.dfn_cache
.Color3fv
, key
,
140 __FUNCTION__
, rmesa
->vb
.floatcolorptr
);
144 static struct dynfn
*r200_makeSSEColor3f( GLcontext
*ctx
, const int * key
)
146 if (VTX_COLOR(key
[0],0) != R200_VTX_FP_RGB
)
150 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
152 return r200_makeSSEAttribute3f( & rmesa
->vb
.dfn_cache
.Color3f
, key
,
153 __FUNCTION__
, rmesa
->vb
.floatcolorptr
);
157 #if 0 /* Temporarily disabled as it is broken w/the new cubemap code. - idr */
158 static struct dynfn
*r200_makeSSETexCoord2fv( GLcontext
*ctx
, const int * key
)
160 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
162 return r200_makeSSEAttribute2fv( & rmesa
->vb
.dfn_cache
.TexCoord2fv
, key
,
163 __FUNCTION__
, rmesa
->vb
.texcoordptr
[0] );
166 static struct dynfn
*r200_makeSSETexCoord2f( GLcontext
*ctx
, const int * key
)
168 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
170 return r200_makeSSEAttribute2f( & rmesa
->vb
.dfn_cache
.TexCoord2f
, key
,
171 __FUNCTION__
, rmesa
->vb
.texcoordptr
[0] );
174 static struct dynfn
*r200_makeSSEMultiTexCoord2fv( GLcontext
*ctx
, const int * key
)
176 struct dynfn
*dfn
= MALLOC_STRUCT( dynfn
);
177 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
179 if (R200_DEBUG
& DEBUG_CODEGEN
)
180 fprintf(stderr
, "%s 0x%08x\n", __FUNCTION__
, key
[0] );
182 if (rmesa
->vb
.texcoordptr
[1] == rmesa
->vb
.texcoordptr
[0]+4) {
183 DFN ( _sse_MultiTexCoord2fv
, rmesa
->vb
.dfn_cache
.MultiTexCoord2fvARB
);
184 FIXUP(dfn
->code
, 18, 0xdeadbeef, (int)rmesa
->vb
.texcoordptr
[0]);
186 DFN ( _sse_MultiTexCoord2fv_2
, rmesa
->vb
.dfn_cache
.MultiTexCoord2fvARB
);
187 FIXUP(dfn
->code
, 14, 0x0, (int)rmesa
->vb
.texcoordptr
);
192 static struct dynfn
*r200_makeSSEMultiTexCoord2f( GLcontext
*ctx
, const int * key
)
194 struct dynfn
*dfn
= MALLOC_STRUCT( dynfn
);
195 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
197 if (R200_DEBUG
& DEBUG_CODEGEN
)
198 fprintf(stderr
, "%s 0x%08x\n", __FUNCTION__
, key
[0] );
200 if (rmesa
->vb
.texcoordptr
[1] == rmesa
->vb
.texcoordptr
[0]+4) {
201 DFN ( _sse_MultiTexCoord2f
, rmesa
->vb
.dfn_cache
.MultiTexCoord2fARB
);
202 FIXUP(dfn
->code
, 16, 0xdeadbeef, (int)rmesa
->vb
.texcoordptr
[0]);
204 DFN ( _sse_MultiTexCoord2f_2
, rmesa
->vb
.dfn_cache
.MultiTexCoord2fARB
);
205 FIXUP(dfn
->code
, 15, 0x0, (int)rmesa
->vb
.texcoordptr
);
211 void r200InitSSECodegen( struct dfn_generators
*gen
)
214 gen
->Normal3fv
= (void *) r200_makeSSENormal3fv
;
215 gen
->Normal3f
= (void *) r200_makeSSENormal3f
;
216 gen
->Color3fv
= (void *) r200_makeSSEColor3fv
;
217 gen
->Color3f
= (void *) r200_makeSSEColor3f
;
218 #if 0 /* Temporarily disabled as it is broken w/the new cubemap code. - idr */
219 gen
->TexCoord2fv
= (void *) r200_makeSSETexCoord2fv
;
220 gen
->TexCoord2f
= (void *) r200_makeSSETexCoord2f
;
221 gen
->MultiTexCoord2fvARB
= (void *) r200_makeSSEMultiTexCoord2fv
;
222 gen
->MultiTexCoord2fARB
= (void *) r200_makeSSEMultiTexCoord2f
;
229 void r200InitSSECodegen( struct dfn_generators
*gen
)