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>
31 #include "main/mtypes.h"
32 #include "math/m_vector.h"
41 VF_ATTRIB_COLOR_INDEX
= 6,
42 VF_ATTRIB_EDGEFLAG
= 7,
59 VF_ATTRIB_POINTSIZE
= 24,
62 VF_ATTRIB_CLIP_POS
= 27,
63 VF_ATTRIB_VERTEX_HEADER
= 28,
73 EMIT_2F_VIEWPORT
, /* do viewport transform and emit */
74 EMIT_3F_VIEWPORT
, /* do viewport transform and emit */
75 EMIT_4F_VIEWPORT
, /* do viewport transform and emit */
76 EMIT_3F_XYW
, /* for projective texture */
77 EMIT_1UB_1F
, /* for fog coordinate */
78 EMIT_3UB_3F_RGB
, /* for specular color */
79 EMIT_3UB_3F_BGR
, /* for specular color */
80 EMIT_4UB_4F_RGBA
, /* for color */
81 EMIT_4UB_4F_BGRA
, /* for color */
82 EMIT_4UB_4F_ARGB
, /* for color */
83 EMIT_4UB_4F_ABGR
, /* for color */
84 EMIT_4CHAN_4F_RGBA
, /* for swrast color */
85 EMIT_PAD
, /* leave a hole of 'offset' bytes */
91 enum vf_attr_format format
;
97 void vf_set_vp_matrix( struct vertex_fetch
*vf
,
98 const GLfloat
*viewport
);
100 void vf_set_vp_scale_translate( struct vertex_fetch
*vf
,
101 const GLfloat
*scale
,
102 const GLfloat
*translate
);
104 GLuint
vf_set_vertex_attributes( struct vertex_fetch
*vf
,
105 const struct vf_attr_map
*map
,
107 GLuint vertex_stride
);
109 void vf_set_sources( struct vertex_fetch
*vf
,
110 GLvector4f
* const attrib
[],
113 void vf_emit_vertices( struct vertex_fetch
*vf
,
117 void vf_get_attr( struct vertex_fetch
*vf
,
123 struct vertex_fetch
*vf_create( GLboolean allow_viewport_emits
);
125 void vf_destroy( struct vertex_fetch
*vf
);
129 /***********************************************************************
130 * Internal functions and structs:
135 typedef void (*vf_extract_func
)( const struct vf_attr
*a
,
139 typedef void (*vf_insert_func
)( const struct vf_attr
*a
,
143 typedef void (*vf_emit_func
)( struct vertex_fetch
*vf
,
149 /* Describes how to convert/move a vertex attribute from a vertex
150 * array to a vertex structure.
154 struct vertex_fetch
*vf
;
159 GLuint vertoffset
; /* position of the attrib in the vertex struct */
161 GLuint attrib
; /* which vertex attrib (0=position, etc) */
162 GLuint vertattrsize
; /* size of the attribute in bytes */
165 const vf_insert_func
*insert
;
166 vf_insert_func do_insert
;
167 vf_extract_func extract
;
172 struct vf_attr attr
[VF_ATTRIB_MAX
];
174 GLuint vertex_stride
;
176 struct vf_attr
*lookup
[VF_ATTRIB_MAX
];
180 /* Parameters and constants for codegen:
182 GLboolean allow_viewport_emits
;
184 GLfloat chan_scale
[4];
187 struct vf_fastpath
*fastpath
;
189 void (*codegen_emit
)( struct vertex_fetch
*vf
);
193 struct vf_attr_type
{
201 GLuint vertex_stride
;
203 GLboolean match_strides
;
205 struct vf_attr_type
*attr
;
208 struct vf_fastpath
*next
;
212 void vf_register_fastpath( struct vertex_fetch
*vtx
,
213 GLboolean match_strides
);
215 void vf_generic_emit( struct vertex_fetch
*vf
,
219 void vf_generate_hardwired_emit( struct vertex_fetch
*vf
);
221 void vf_generate_sse_emit( struct vertex_fetch
*vf
);
224 struct vf_format_info
{
226 vf_extract_func extract
;
227 vf_insert_func insert
[4];
228 const GLuint attrsize
;
231 const struct vf_format_info vf_format_info
[EMIT_MAX
];