1848b8605Smrg/*
2848b8605Smrg * Copyright 2003 VMware, Inc.
3848b8605Smrg * All Rights Reserved.
4848b8605Smrg *
5848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a
6848b8605Smrg * copy of this software and associated documentation files (the "Software"),
7848b8605Smrg * to deal in the Software without restriction, including without limitation
8848b8605Smrg * on the rights to use, copy, modify, merge, publish, distribute, sub
9848b8605Smrg * license, and/or sell copies of the Software, and to permit persons to whom
10848b8605Smrg * the Software is furnished to do so, subject to the following conditions:
11848b8605Smrg *
12848b8605Smrg * The above copyright notice and this permission notice (including the next
13848b8605Smrg * paragraph) shall be included in all copies or substantial portions of the
14848b8605Smrg * Software.
15848b8605Smrg *
16848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17848b8605Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18848b8605Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
19848b8605Smrg * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20848b8605Smrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21848b8605Smrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22848b8605Smrg * USE OR OTHER DEALINGS IN THE SOFTWARE.
23848b8605Smrg *
24848b8605Smrg * Authors:
25848b8605Smrg *    Keith Whitwell <keithw@vmware.com>
26848b8605Smrg */
27848b8605Smrg
28848b8605Smrg#ifndef _TNL_VERTEX_H
29848b8605Smrg#define _TNL_VERTEX_H
30848b8605Smrg
31848b8605Smrg#include "main/glheader.h"
32848b8605Smrg#include "t_context.h"
33848b8605Smrg
34848b8605Smrgstruct gl_context;
35848b8605Smrgstruct tnl_clipspace;
36848b8605Smrg
37848b8605Smrg/* New mechanism to specify hardware vertices so that tnl can build
38848b8605Smrg * and manipulate them directly.
39848b8605Smrg */
40848b8605Smrg
41848b8605Smrg
42848b8605Smrg/* It will probably be necessary to allow drivers to specify new
43b8e80941Smrg * emit-styles to cover all the weird and wacky things out there.
44848b8605Smrg */
45848b8605Smrgenum tnl_attr_format {
46848b8605Smrg   EMIT_1F,
47848b8605Smrg   EMIT_2F,
48848b8605Smrg   EMIT_3F,
49848b8605Smrg   EMIT_4F,
50848b8605Smrg   EMIT_2F_VIEWPORT,		/* do viewport transform and emit */
51848b8605Smrg   EMIT_3F_VIEWPORT,		/* do viewport transform and emit */
52848b8605Smrg   EMIT_4F_VIEWPORT,		/* do viewport transform and emit */
53848b8605Smrg   EMIT_3F_XYW,			/* for projective texture */
54848b8605Smrg   EMIT_1UB_1F,			/* for fog coordinate */
55848b8605Smrg   EMIT_3UB_3F_RGB,		/* for specular color */
56848b8605Smrg   EMIT_3UB_3F_BGR,		/* for specular color */
57848b8605Smrg   EMIT_4UB_4F_RGBA,		/* for color */
58848b8605Smrg   EMIT_4UB_4F_BGRA,		/* for color */
59848b8605Smrg   EMIT_4UB_4F_ARGB,		/* for color */
60848b8605Smrg   EMIT_4UB_4F_ABGR,		/* for color */
61848b8605Smrg   EMIT_4CHAN_4F_RGBA,		/* for swrast color */
62848b8605Smrg   EMIT_PAD,			/* leave a hole of 'offset' bytes */
63848b8605Smrg   EMIT_MAX
64848b8605Smrg};
65848b8605Smrg
66848b8605Smrgstruct tnl_attr_map {
67848b8605Smrg   GLuint attrib;			/* _TNL_ATTRIB_ enum */
68848b8605Smrg   enum tnl_attr_format format;
69848b8605Smrg   GLuint offset;
70848b8605Smrg};
71848b8605Smrg
72848b8605Smrgstruct tnl_format_info {
73848b8605Smrg   const char *name;
74848b8605Smrg   tnl_extract_func extract;
75848b8605Smrg   tnl_insert_func insert[4];
76848b8605Smrg   const GLuint attrsize;
77848b8605Smrg};
78848b8605Smrg
79848b8605Smrgextern const struct tnl_format_info _tnl_format_info[EMIT_MAX];
80848b8605Smrg
81848b8605Smrg
82848b8605Smrg/* Interpolate between two vertices to produce a third:
83848b8605Smrg */
84848b8605Smrgextern void _tnl_interp( struct gl_context *ctx,
85848b8605Smrg			 GLfloat t,
86848b8605Smrg			 GLuint edst, GLuint eout, GLuint ein,
87848b8605Smrg			 GLboolean force_boundary );
88848b8605Smrg
89848b8605Smrg/* Copy colors from one vertex to another:
90848b8605Smrg */
91848b8605Smrgextern void _tnl_copy_pv(  struct gl_context *ctx, GLuint edst, GLuint esrc );
92848b8605Smrg
93848b8605Smrg
94848b8605Smrg/* Extract a named attribute from a hardware vertex.  Will have to
95848b8605Smrg * reverse any viewport transformation, swizzling or other conversions
96848b8605Smrg * which may have been applied:
97848b8605Smrg */
98848b8605Smrgextern void _tnl_get_attr( struct gl_context *ctx, const void *vertex, GLenum attrib,
99848b8605Smrg			   GLfloat *dest );
100848b8605Smrg
101848b8605Smrg/* Complementary to the above.
102848b8605Smrg */
103848b8605Smrgextern void _tnl_set_attr( struct gl_context *ctx, void *vout, GLenum attrib,
104848b8605Smrg			   const GLfloat *src );
105848b8605Smrg
106848b8605Smrg
107848b8605Smrgextern void *_tnl_get_vertex( struct gl_context *ctx, GLuint nr );
108848b8605Smrg
109848b8605Smrgextern GLuint _tnl_install_attrs( struct gl_context *ctx,
110848b8605Smrg				  const struct tnl_attr_map *map,
111848b8605Smrg				  GLuint nr, const GLfloat *vp,
112848b8605Smrg				  GLuint unpacked_size );
113848b8605Smrg
114848b8605Smrgextern void _tnl_free_vertices( struct gl_context *ctx );
115848b8605Smrg
116848b8605Smrgextern void _tnl_init_vertices( struct gl_context *ctx,
117848b8605Smrg				GLuint vb_size,
118848b8605Smrg				GLuint max_vertex_size );
119848b8605Smrg
120848b8605Smrgextern void *_tnl_emit_vertices_to_buffer( struct gl_context *ctx,
121848b8605Smrg					   GLuint start,
122848b8605Smrg					   GLuint end,
123848b8605Smrg					   void *dest );
124848b8605Smrg
125848b8605Smrg/* This function isn't optimal. Check out
126848b8605Smrg * gallium/auxilary/translate for a more comprehensive implementation of
127848b8605Smrg * the same functionality.
128848b8605Smrg */
129848b8605Smrg
130848b8605Smrgextern void *_tnl_emit_indexed_vertices_to_buffer( struct gl_context *ctx,
131848b8605Smrg						   const GLuint *elts,
132848b8605Smrg						   GLuint start,
133848b8605Smrg						   GLuint end,
134848b8605Smrg						   void *dest );
135848b8605Smrg
136848b8605Smrg
137848b8605Smrgextern void _tnl_build_vertices( struct gl_context *ctx,
138848b8605Smrg				 GLuint start,
139848b8605Smrg				 GLuint end,
140848b8605Smrg				 GLuint newinputs );
141848b8605Smrg
142848b8605Smrgextern void _tnl_invalidate_vertices( struct gl_context *ctx, GLuint newinputs );
143848b8605Smrg
144848b8605Smrgextern void _tnl_invalidate_vertex_state( struct gl_context *ctx, GLuint new_state );
145848b8605Smrg
146848b8605Smrgextern void _tnl_notify_pipeline_output_change( struct gl_context *ctx );
147848b8605Smrg
148848b8605Smrg
149848b8605Smrg#define GET_VERTEX_STATE(ctx)  &(TNL_CONTEXT(ctx)->clipspace)
150848b8605Smrg
151848b8605Smrg/* Internal function:
152848b8605Smrg */
153848b8605Smrgvoid _tnl_register_fastpath( struct tnl_clipspace *vtx,
154848b8605Smrg			     GLboolean match_strides );
155848b8605Smrg
156848b8605Smrg
157848b8605Smrg/* t_vertex_generic.c -- Internal functions for t_vertex.c
158848b8605Smrg */
159848b8605Smrgvoid _tnl_generic_copy_pv_extras( struct gl_context *ctx,
160848b8605Smrg				  GLuint dst, GLuint src );
161848b8605Smrg
162848b8605Smrgvoid _tnl_generic_interp_extras( struct gl_context *ctx,
163848b8605Smrg				 GLfloat t,
164848b8605Smrg				 GLuint dst, GLuint out, GLuint in,
165848b8605Smrg				 GLboolean force_boundary );
166848b8605Smrg
167848b8605Smrgvoid _tnl_generic_copy_pv( struct gl_context *ctx, GLuint edst, GLuint esrc );
168848b8605Smrg
169848b8605Smrgvoid _tnl_generic_interp( struct gl_context *ctx,
170848b8605Smrg			  GLfloat t,
171848b8605Smrg			  GLuint edst, GLuint eout, GLuint ein,
172848b8605Smrg			  GLboolean force_boundary );
173848b8605Smrg
174848b8605Smrgvoid _tnl_generic_emit( struct gl_context *ctx,
175848b8605Smrg			GLuint count,
176848b8605Smrg			GLubyte *v );
177848b8605Smrg
178848b8605Smrgvoid _tnl_generate_hardwired_emit( struct gl_context *ctx );
179848b8605Smrg
180848b8605Smrg/* t_vertex_sse.c -- Internal functions for t_vertex.c
181848b8605Smrg */
182848b8605Smrgvoid _tnl_generate_sse_emit( struct gl_context *ctx );
183848b8605Smrg
184848b8605Smrg#endif
185