Add ARGB modes to support big-endian systems.
[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 "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_4CHAN_4F_RGBA, /* for swrast color */
58 EMIT_PAD, /* leave a hole of 'offset' bytes */
59 EMIT_MAX
60 };
61
62 struct tnl_attr_map {
63 GLuint attrib; /* _TNL_ATTRIB_ enum */
64 enum tnl_attr_format format;
65 GLuint offset;
66 };
67
68
69
70 /* Interpolate between two vertices to produce a third:
71 */
72 extern void _tnl_interp( GLcontext *ctx,
73 GLfloat t,
74 GLuint edst, GLuint eout, GLuint ein,
75 GLboolean force_boundary );
76
77 /* Copy colors from one vertex to another:
78 */
79 extern void _tnl_copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc );
80
81
82 /* Extract a named attribute from a hardware vertex. Will have to
83 * reverse any viewport transformation, swizzling or other conversions
84 * which may have been applied:
85 */
86 extern void _tnl_get_attr( GLcontext *ctx, const void *vertex, GLenum attrib,
87 GLfloat *dest );
88
89 /* Complementary to the above.
90 */
91 extern void _tnl_set_attr( GLcontext *ctx, void *vout, GLenum attrib,
92 const GLfloat *src );
93
94
95 extern void *_tnl_get_vertex( GLcontext *ctx, GLuint nr );
96
97
98 /*
99 */
100 extern GLuint _tnl_install_attrs( GLcontext *ctx,
101 const struct tnl_attr_map *map,
102 GLuint nr, const GLfloat *vp,
103 GLuint unpacked_size );
104
105
106
107
108
109 extern void _tnl_free_vertices( GLcontext *ctx );
110
111 extern void _tnl_init_vertices( GLcontext *ctx,
112 GLuint vb_size,
113 GLuint max_vertex_size );
114
115 extern void *_tnl_emit_vertices_to_buffer( GLcontext *ctx,
116 GLuint start,
117 GLuint end,
118 void *dest );
119
120 extern void _tnl_build_vertices( GLcontext *ctx,
121 GLuint start,
122 GLuint end,
123 GLuint newinputs );
124
125 extern void _tnl_invalidate_vertices( GLcontext *ctx, GLuint newinputs );
126
127 extern void _tnl_invalidate_vertex_state( GLcontext *ctx, GLuint new_state );
128
129 extern tnl_emit_func _tnl_codegen_emit( GLcontext *ctx );
130
131 #define REG_IN (0<<16)
132 #define REG_OUT (1<<16)
133 #define REG_VP (2<<16)
134 #define REG_TMP (3<<16)
135 #define REG_MASK (3<<16)
136
137 #define REG_OFFSET_MASK 0xffff
138
139 #define in( offset ) (REG_IN | (offset))
140 #define out( offset ) (REG_OUT | (offset))
141 #define vp( offset ) (REG_VP | (offset))
142 #define tmp( offset ) (REG_TMP | (offset))
143
144
145 extern void _tnl_init_c_codegen( struct tnl_clipspace_codegen *p );
146
147 #define GET_VERTEX_STATE(ctx) &(TNL_CONTEXT(ctx)->clipspace)
148
149 #endif