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