2 * Copyright 2003 Tungsten Graphics, inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Keith Whitwell <keithw@tungstengraphics.com>
41 VF_ATTRIB_COLOR_INDEX
= 6,
42 VF_ATTRIB_EDGEFLAG
= 7,
51 VF_ATTRIB_POINTSIZE
= 16,
54 VF_ATTRIB_CLIP_POS
= 19,
55 VF_ATTRIB_VERTEX_HEADER
= 20,
65 EMIT_2F_VIEWPORT
, /* do viewport transform and emit */
66 EMIT_3F_VIEWPORT
, /* do viewport transform and emit */
67 EMIT_4F_VIEWPORT
, /* do viewport transform and emit */
68 EMIT_3F_XYW
, /* for projective texture */
69 EMIT_1UB_1F
, /* for fog coordinate */
70 EMIT_3UB_3F_RGB
, /* for specular color */
71 EMIT_3UB_3F_BGR
, /* for specular color */
72 EMIT_4UB_4F_RGBA
, /* for color */
73 EMIT_4UB_4F_BGRA
, /* for color */
74 EMIT_4UB_4F_ARGB
, /* for color */
75 EMIT_4UB_4F_ABGR
, /* for color */
76 EMIT_4CHAN_4F_RGBA
, /* for swrast color */
77 EMIT_PAD
, /* leave a hole of 'offset' bytes */
83 enum vf_attr_format format
;
89 void vf_set_vp_matrix( struct vertex_fetch
*vf
,
90 const GLfloat
*viewport
);
92 void vf_set_vp_scale_translate( struct vertex_fetch
*vf
,
94 const GLfloat
*translate
);
96 GLuint
vf_set_vertex_attributes( struct vertex_fetch
*vf
,
97 const struct vf_attr_map
*map
,
99 GLuint vertex_stride
);
101 void vf_set_sources( struct vertex_fetch
*vf
,
102 GLvector4f
* const attrib
[],
105 void vf_emit_vertices( struct vertex_fetch
*vf
,
109 void vf_get_attr( struct vertex_fetch
*vf
,
115 struct vertex_fetch
*vf_create( GLboolean allow_viewport_emits
);
117 void vf_destroy( struct vertex_fetch
*vf
);
121 /***********************************************************************
122 * Internal functions and structs:
127 typedef void (*vf_extract_func
)( const struct vf_attr
*a
,
131 typedef void (*vf_insert_func
)( const struct vf_attr
*a
,
135 typedef void (*vf_emit_func
)( struct vertex_fetch
*vf
,
141 /* Describes how to convert/move a vertex attribute from a vertex
142 * array to a vertex structure.
146 struct vertex_fetch
*vf
;
151 GLuint vertoffset
; /* position of the attrib in the vertex struct */
153 GLuint attrib
; /* which vertex attrib (0=position, etc) */
154 GLuint vertattrsize
; /* size of the attribute in bytes */
157 const vf_insert_func
*insert
;
158 vf_insert_func do_insert
;
159 vf_extract_func extract
;
164 struct vf_attr attr
[VF_ATTRIB_MAX
];
166 GLuint vertex_stride
;
168 struct vf_attr
*lookup
[VF_ATTRIB_MAX
];
172 /* Parameters and constants for codegen:
174 GLboolean allow_viewport_emits
;
176 GLfloat chan_scale
[4];
179 struct vf_fastpath
*fastpath
;
181 void (*codegen_emit
)( struct vertex_fetch
*vf
);
185 struct vf_attr_type
{
193 GLuint vertex_stride
;
195 GLboolean match_strides
;
197 struct vf_attr_type
*attr
;
200 struct vf_fastpath
*next
;
204 void vf_register_fastpath( struct vertex_fetch
*vtx
,
205 GLboolean match_strides
);
207 void vf_generic_emit( struct vertex_fetch
*vf
,
211 void vf_generate_hardwired_emit( struct vertex_fetch
*vf
);
213 void vf_generate_sse_emit( struct vertex_fetch
*vf
);
216 struct vf_format_info
{
218 vf_extract_func extract
;
219 vf_insert_func insert
[4];
220 const GLuint attrsize
;
223 const struct vf_format_info vf_format_info
[EMIT_MAX
];