fragment program execution
[mesa.git] / src / mesa / tnl / t_vtx_api.h
1 /* $XFree86$ */
2 /**************************************************************************
3
4 Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
5
6 All Rights Reserved.
7
8 Permission is hereby granted, free of charge, to any person obtaining a
9 copy of this software and associated documentation files (the "Software"),
10 to deal in the Software without restriction, including without limitation
11 on the rights to use, copy, modify, merge, publish, distribute, sub
12 license, and/or sell copies of the Software, and to permit persons to whom
13 the Software is furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice (including the next
16 paragraph) shall be included in all copies or substantial portions of the
17 Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
22 TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
23 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25 USE OR OTHER DEALINGS IN THE SOFTWARE.
26
27 **************************************************************************/
28
29 /*
30 * Authors:
31 * Keith Whitwell <keith@tungstengraphics.com>
32 *
33 */
34
35 #ifndef __RADEON_VTXFMT_H__
36 #define __RADEON_VTXFMT_H__
37
38 #ifdef GLX_DIRECT_RENDERING
39
40 #include "_tnl__context.h"
41
42 extern void _tnl_UpdateVtxfmt( GLcontext *ctx );
43 extern void _tnl_InitVtxfmt( GLcontext *ctx );
44 extern void _tnl_InvalidateVtxfmt( GLcontext *ctx );
45 extern void _tnl_DestroyVtxfmt( GLcontext *ctx );
46
47 typedef void (*p4f)( GLfloat, GLfloat, GLfloat, GLfloat );
48 typedef void (*p3f)( GLfloat, GLfloat, GLfloat );
49 typedef void (*p2f)( GLfloat, GLfloat );
50 typedef void (*p1f)( GLfloat );
51 typedef void (*pe2f)( GLenum, GLfloat, GLfloat );
52 typedef void (*pe1f)( GLenum, GLfloat );
53 typedef void (*p4ub)( GLubyte, GLubyte, GLubyte, GLubyte );
54 typedef void (*p3ub)( GLubyte, GLubyte, GLubyte );
55 typedef void (*pfv)( const GLfloat * );
56 typedef void (*pefv)( GLenum, const GLfloat * );
57 typedef void (*pubv)( const GLubyte * );
58
59 /* Want to keep a cache of these around. Each is parameterized by
60 * only a single value which has only a small range. Only expect a
61 * few, so just rescan the list each time?
62 */
63 struct dynfn {
64 struct dynfn *next, *prev;
65 int key;
66 char *code;
67 };
68
69 struct dfn_lists {
70 struct dynfn Vertex2f;
71 struct dynfn Vertex2fv;
72 struct dynfn Vertex3f;
73 struct dynfn Vertex3fv;
74 struct dynfn Color4ub;
75 struct dynfn Color4ubv;
76 struct dynfn Color3ub;
77 struct dynfn Color3ubv;
78 struct dynfn Color4f;
79 struct dynfn Color4fv;
80 struct dynfn Color3f;
81 struct dynfn Color3fv;
82 struct dynfn SecondaryColor3ubEXT;
83 struct dynfn SecondaryColor3ubvEXT;
84 struct dynfn SecondaryColor3fEXT;
85 struct dynfn SecondaryColor3fvEXT;
86 struct dynfn Normal3f;
87 struct dynfn Normal3fv;
88 struct dynfn TexCoord2f;
89 struct dynfn TexCoord2fv;
90 struct dynfn TexCoord1f;
91 struct dynfn TexCoord1fv;
92 struct dynfn MultiTexCoord2fARB;
93 struct dynfn MultiTexCoord2fvARB;
94 struct dynfn MultiTexCoord1fARB;
95 struct dynfn MultiTexCoord1fvARB;
96 };
97
98 struct _vb;
99
100 struct dfn_generators {
101 struct dynfn *(*Vertex2f)( struct _vb *, int );
102 struct dynfn *(*Vertex2fv)( struct _vb *, int );
103 struct dynfn *(*Vertex3f)( struct _vb *, int );
104 struct dynfn *(*Vertex3fv)( struct _vb *, int );
105 struct dynfn *(*Color4ub)( struct _vb *, int );
106 struct dynfn *(*Color4ubv)( struct _vb *, int );
107 struct dynfn *(*Color3ub)( struct _vb *, int );
108 struct dynfn *(*Color3ubv)( struct _vb *, int );
109 struct dynfn *(*Color4f)( struct _vb *, int );
110 struct dynfn *(*Color4fv)( struct _vb *, int );
111 struct dynfn *(*Color3f)( struct _vb *, int );
112 struct dynfn *(*Color3fv)( struct _vb *, int );
113 struct dynfn *(*SecondaryColor3ubEXT)( struct _vb *, int );
114 struct dynfn *(*SecondaryColor3ubvEXT)( struct _vb *, int );
115 struct dynfn *(*SecondaryColor3fEXT)( struct _vb *, int );
116 struct dynfn *(*SecondaryColor3fvEXT)( struct _vb *, int );
117 struct dynfn *(*Normal3f)( struct _vb *, int );
118 struct dynfn *(*Normal3fv)( struct _vb *, int );
119 struct dynfn *(*TexCoord2f)( struct _vb *, int );
120 struct dynfn *(*TexCoord2fv)( struct _vb *, int );
121 struct dynfn *(*TexCoord1f)( struct _vb *, int );
122 struct dynfn *(*TexCoord1fv)( struct _vb *, int );
123 struct dynfn *(*MultiTexCoord2fARB)( struct _vb *, int );
124 struct dynfn *(*MultiTexCoord2fvARB)( struct _vb *, int );
125 struct dynfn *(*MultiTexCoord1fARB)( struct _vb *, int );
126 struct dynfn *(*MultiTexCoord1fvARB)( struct _vb *, int );
127 };
128
129 struct prim {
130 GLuint start;
131 GLuint end;
132 GLuint prim;
133 };
134
135 #define _TNL__MAX_PRIMS 64
136
137
138
139 struct tnl_vbinfo {
140 /* Keep these first: referenced from codegen templates:
141 */
142 GLint counter;
143 GLint *dmaptr;
144 void (*notify)( void );
145 union { float f; int i; GLubyte ub4[4]; } vertex[16*4];
146
147 GLfloat *attrptr[16];
148 GLuint size[16];
149
150 GLenum *prim; /* &ctx->Driver.CurrentExecPrimitive */
151 GLuint primflags;
152
153 GLboolean installed;
154 GLboolean recheck;
155
156 GLint vertex_size;
157 GLint initial_counter;
158 GLint nrverts;
159 GLuint vertex_format;
160
161 GLuint installed_vertex_format;
162
163 struct prim primlist[RADEON_MAX_PRIMS];
164 int nrprims;
165
166 struct dfn_lists dfn_cache;
167 struct dfn_generators codegen;
168 GLvertexformat vtxfmt;
169 };
170
171
172 extern void _tnl_InitVtxfmtChoosers( GLvertexformat *vfmt );
173
174
175 #define FIXUP( CODE, OFFSET, CHECKVAL, NEWVAL ) \
176 do { \
177 int *icode = (int *)(CODE+OFFSET); \
178 assert (*icode == CHECKVAL); \
179 *icode = (int)NEWVAL; \
180 } while (0)
181
182
183 /* Useful for figuring out the offsets:
184 */
185 #define FIXUP2( CODE, OFFSET, CHECKVAL, NEWVAL ) \
186 do { \
187 while (*(int *)(CODE+OFFSET) != CHECKVAL) OFFSET++; \
188 fprintf(stderr, "%s/%d CVAL %x OFFSET %d\n", __FUNCTION__, \
189 __LINE__, CHECKVAL, OFFSET); \
190 *(int *)(CODE+OFFSET) = (int)NEWVAL; \
191 OFFSET += 4; \
192 } while (0)
193
194 /*
195 */
196 void _tnl_InitCodegen( struct dfn_generators *gen );
197 void _tnl_InitX86Codegen( struct dfn_generators *gen );
198 void _tnl_InitSSECodegen( struct dfn_generators *gen );
199
200 void _tnl_copy_to_current( GLcontext *ctx );
201
202
203 /* Defined in tnl_vtxfmt_c.c.
204 */
205 struct dynfn *tnl_makeX86Vertex2f( TNLcontext *, int );
206 struct dynfn *tnl_makeX86Vertex2fv( TNLcontext *, int );
207 struct dynfn *tnl_makeX86Vertex3f( TNLcontext *, int );
208 struct dynfn *tnl_makeX86Vertex3fv( TNLcontext *, int );
209 struct dynfn *tnl_makeX86Color4ub( TNLcontext *, int );
210 struct dynfn *tnl_makeX86Color4ubv( TNLcontext *, int );
211 struct dynfn *tnl_makeX86Color3ub( TNLcontext *, int );
212 struct dynfn *tnl_makeX86Color3ubv( TNLcontext *, int );
213 struct dynfn *tnl_makeX86Color4f( TNLcontext *, int );
214 struct dynfn *tnl_makeX86Color4fv( TNLcontext *, int );
215 struct dynfn *tnl_makeX86Color3f( TNLcontext *, int );
216 struct dynfn *tnl_makeX86Color3fv( TNLcontext *, int );
217 struct dynfn *tnl_makeX86SecondaryColor3ubEXT( TNLcontext *, int );
218 struct dynfn *tnl_makeX86SecondaryColor3ubvEXT( TNLcontext *, int );
219 struct dynfn *tnl_makeX86SecondaryColor3fEXT( TNLcontext *, int );
220 struct dynfn *tnl_makeX86SecondaryColor3fvEXT( TNLcontext *, int );
221 struct dynfn *tnl_makeX86Normal3f( TNLcontext *, int );
222 struct dynfn *tnl_makeX86Normal3fv( TNLcontext *, int );
223 struct dynfn *tnl_makeX86TexCoord2f( TNLcontext *, int );
224 struct dynfn *tnl_makeX86TexCoord2fv( TNLcontext *, int );
225 struct dynfn *tnl_makeX86TexCoord1f( TNLcontext *, int );
226 struct dynfn *tnl_makeX86TexCoord1fv( TNLcontext *, int );
227 struct dynfn *tnl_makeX86MultiTexCoord2fARB( TNLcontext *, int );
228 struct dynfn *tnl_makeX86MultiTexCoord2fvARB( TNLcontext *, int );
229 struct dynfn *tnl_makeX86MultiTexCoord1fARB( TNLcontext *, int );
230 struct dynfn *tnl_makeX86MultiTexCoord1fvARB( TNLcontext *, int );
231
232
233 #endif
234 #endif