Add a comment about _tnl_emit_indexed_vertices_to_buffer.
[mesa.git] / src / mesa / tnl / t_vertex.h
1 /*
2 * Copyright 2003 Tungsten Graphics, inc.
3 * All Rights Reserved.
4 *
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:
11 *
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
14 * Software.
15 *
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.
23 *
24 * Authors:
25 * Keith Whitwell <keithw@tungstengraphics.com>
26 */
27
28 #ifndef _TNL_VERTEX_H
29 #define _TNL_VERTEX_H
30
31 #include "main/mtypes.h"
32 #include "t_context.h"
33
34 /* New mechanism to specify hardware vertices so that tnl can build
35 * and manipulate them directly.
36 */
37
38
39 /* It will probably be necessary to allow drivers to specify new
40 * emit-styles to cover all the wierd and wacky things out there.
41 */
42 enum tnl_attr_format {
43 EMIT_1F,
44 EMIT_2F,
45 EMIT_3F,
46 EMIT_4F,
47 EMIT_2F_VIEWPORT, /* do viewport transform and emit */
48 EMIT_3F_VIEWPORT, /* do viewport transform and emit */
49 EMIT_4F_VIEWPORT, /* do viewport transform and emit */
50 EMIT_3F_XYW, /* for projective texture */
51 EMIT_1UB_1F, /* for fog coordinate */
52 EMIT_3UB_3F_RGB, /* for specular color */
53 EMIT_3UB_3F_BGR, /* for specular color */
54 EMIT_4UB_4F_RGBA, /* for color */
55 EMIT_4UB_4F_BGRA, /* for color */
56 EMIT_4UB_4F_ARGB, /* for color */
57 EMIT_4UB_4F_ABGR, /* for color */
58 EMIT_4CHAN_4F_RGBA, /* for swrast color */
59 EMIT_PAD, /* leave a hole of 'offset' bytes */
60 EMIT_MAX
61 };
62
63 struct tnl_attr_map {
64 GLuint attrib; /* _TNL_ATTRIB_ enum */
65 enum tnl_attr_format format;
66 GLuint offset;
67 };
68
69 struct tnl_format_info {
70 const char *name;
71 tnl_extract_func extract;
72 tnl_insert_func insert[4];
73 const GLuint attrsize;
74 };
75
76 extern const struct tnl_format_info _tnl_format_info[EMIT_MAX];
77
78
79 /* Interpolate between two vertices to produce a third:
80 */
81 extern void _tnl_interp( GLcontext *ctx,
82 GLfloat t,
83 GLuint edst, GLuint eout, GLuint ein,
84 GLboolean force_boundary );
85
86 /* Copy colors from one vertex to another:
87 */
88 extern void _tnl_copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc );
89
90
91 /* Extract a named attribute from a hardware vertex. Will have to
92 * reverse any viewport transformation, swizzling or other conversions
93 * which may have been applied:
94 */
95 extern void _tnl_get_attr( GLcontext *ctx, const void *vertex, GLenum attrib,
96 GLfloat *dest );
97
98 /* Complementary to the above.
99 */
100 extern void _tnl_set_attr( GLcontext *ctx, void *vout, GLenum attrib,
101 const GLfloat *src );
102
103
104 extern void *_tnl_get_vertex( GLcontext *ctx, GLuint nr );
105
106 extern GLuint _tnl_install_attrs( GLcontext *ctx,
107 const struct tnl_attr_map *map,
108 GLuint nr, const GLfloat *vp,
109 GLuint unpacked_size );
110
111 extern void _tnl_free_vertices( GLcontext *ctx );
112
113 extern void _tnl_init_vertices( GLcontext *ctx,
114 GLuint vb_size,
115 GLuint max_vertex_size );
116
117 extern void *_tnl_emit_vertices_to_buffer( GLcontext *ctx,
118 GLuint start,
119 GLuint end,
120 void *dest );
121
122 /* This function isn't optimal. Check out
123 * gallium/auxilary/translate for a more comprehensive implementation of
124 * the same functionality.
125 */
126
127 extern void *_tnl_emit_indexed_vertices_to_buffer( GLcontext *ctx,
128 const GLuint *elts,
129 GLuint start,
130 GLuint end,
131 void *dest );
132
133
134 extern void _tnl_build_vertices( GLcontext *ctx,
135 GLuint start,
136 GLuint end,
137 GLuint newinputs );
138
139 extern void _tnl_invalidate_vertices( GLcontext *ctx, GLuint newinputs );
140
141 extern void _tnl_invalidate_vertex_state( GLcontext *ctx, GLuint new_state );
142
143 extern void _tnl_notify_pipeline_output_change( GLcontext *ctx );
144
145
146 #define GET_VERTEX_STATE(ctx) &(TNL_CONTEXT(ctx)->clipspace)
147
148 /* Internal function:
149 */
150 void _tnl_register_fastpath( struct tnl_clipspace *vtx,
151 GLboolean match_strides );
152
153
154 /* t_vertex_generic.c -- Internal functions for t_vertex.c
155 */
156 void _tnl_generic_copy_pv_extras( GLcontext *ctx,
157 GLuint dst, GLuint src );
158
159 void _tnl_generic_interp_extras( GLcontext *ctx,
160 GLfloat t,
161 GLuint dst, GLuint out, GLuint in,
162 GLboolean force_boundary );
163
164 void _tnl_generic_copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc );
165
166 void _tnl_generic_interp( GLcontext *ctx,
167 GLfloat t,
168 GLuint edst, GLuint eout, GLuint ein,
169 GLboolean force_boundary );
170
171 void _tnl_generic_emit( GLcontext *ctx,
172 GLuint count,
173 GLubyte *v );
174
175 void _tnl_generate_hardwired_emit( GLcontext *ctx );
176
177 /* t_vertex_sse.c -- Internal functions for t_vertex.c
178 */
179 void _tnl_generate_sse_emit( GLcontext *ctx );
180
181 #endif