mesa: Restore 78-column wrapping of license text in C-style comments.
[mesa.git] / src / mesa / vbo / vbo.h
1 /*
2 * mesa 3-D graphics library
3 * Version: 6.5
4 *
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 /**
27 * \file vbo_context.h
28 * \brief VBO builder module datatypes and definitions.
29 * \author Keith Whitwell
30 */
31
32
33 #ifndef _VBO_H
34 #define _VBO_H
35
36 #include "main/glheader.h"
37
38 struct gl_client_array;
39 struct gl_context;
40 struct gl_transform_feedback_object;
41
42 struct _mesa_prim {
43 GLuint mode:8; /**< GL_POINTS, GL_LINES, GL_QUAD_STRIP, etc */
44 GLuint indexed:1;
45 GLuint begin:1;
46 GLuint end:1;
47 GLuint weak:1;
48 GLuint no_current_update:1;
49 GLuint pad:19;
50
51 GLuint start;
52 GLuint count;
53 GLint basevertex;
54 GLuint num_instances;
55 GLuint base_instance;
56 };
57
58 /* Would like to call this a "vbo_index_buffer", but this would be
59 * confusing as the indices are not neccessarily yet in a non-null
60 * buffer object.
61 */
62 struct _mesa_index_buffer {
63 GLuint count;
64 GLenum type;
65 struct gl_buffer_object *obj;
66 const void *ptr;
67 };
68
69
70
71 GLboolean _vbo_CreateContext( struct gl_context *ctx );
72 void _vbo_DestroyContext( struct gl_context *ctx );
73 void _vbo_InvalidateState( struct gl_context *ctx, GLuint new_state );
74
75
76 typedef void (*vbo_draw_func)( struct gl_context *ctx,
77 const struct _mesa_prim *prims,
78 GLuint nr_prims,
79 const struct _mesa_index_buffer *ib,
80 GLboolean index_bounds_valid,
81 GLuint min_index,
82 GLuint max_index,
83 struct gl_transform_feedback_object *tfb_vertcount );
84
85
86
87
88 /* Utility function to cope with various constraints on tnl modules or
89 * hardware. This can be used to split an incoming set of arrays and
90 * primitives against the following constraints:
91 * - Maximum number of indices in index buffer.
92 * - Maximum number of vertices referenced by index buffer.
93 * - Maximum hardware vertex buffer size.
94 */
95 struct split_limits {
96 GLuint max_verts;
97 GLuint max_indices;
98 GLuint max_vb_size; /* bytes */
99 };
100
101
102 void vbo_split_prims( struct gl_context *ctx,
103 const struct gl_client_array *arrays[],
104 const struct _mesa_prim *prim,
105 GLuint nr_prims,
106 const struct _mesa_index_buffer *ib,
107 GLuint min_index,
108 GLuint max_index,
109 vbo_draw_func draw,
110 const struct split_limits *limits );
111
112
113 /* Helpers for dealing translating away non-zero min_index.
114 */
115 GLboolean vbo_all_varyings_in_vbos( const struct gl_client_array *arrays[] );
116 GLboolean vbo_any_varyings_in_vbos( const struct gl_client_array *arrays[] );
117
118 void vbo_rebase_prims( struct gl_context *ctx,
119 const struct gl_client_array *arrays[],
120 const struct _mesa_prim *prim,
121 GLuint nr_prims,
122 const struct _mesa_index_buffer *ib,
123 GLuint min_index,
124 GLuint max_index,
125 vbo_draw_func draw );
126
127 static inline int
128 vbo_sizeof_ib_type(GLenum type)
129 {
130 switch (type) {
131 case GL_UNSIGNED_INT:
132 return sizeof(GLuint);
133 case GL_UNSIGNED_SHORT:
134 return sizeof(GLushort);
135 case GL_UNSIGNED_BYTE:
136 return sizeof(GLubyte);
137 default:
138 assert(!"unsupported index data type");
139 /* In case assert is turned off */
140 return 0;
141 }
142 }
143
144 void
145 vbo_get_minmax_indices(struct gl_context *ctx, const struct _mesa_prim *prim,
146 const struct _mesa_index_buffer *ib,
147 GLuint *min_index, GLuint *max_index, GLuint nr_prims);
148
149 void vbo_use_buffer_objects(struct gl_context *ctx);
150
151 void vbo_always_unmap_buffers(struct gl_context *ctx);
152
153 void vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func);
154
155 void vbo_check_buffers_are_unmapped(struct gl_context *ctx);
156
157 void vbo_bind_arrays(struct gl_context *ctx);
158
159 size_t
160 vbo_count_tessellated_primitives(GLenum mode, GLuint count,
161 GLuint num_instances);
162
163 void
164 vbo_sw_primitive_restart(struct gl_context *ctx,
165 const struct _mesa_prim *prim,
166 GLuint nr_prims,
167 const struct _mesa_index_buffer *ib);
168
169 void GLAPIENTRY
170 _es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
171
172 void GLAPIENTRY
173 _es_Normal3f(GLfloat x, GLfloat y, GLfloat z);
174
175 void GLAPIENTRY
176 _es_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
177
178 void GLAPIENTRY
179 _es_Materialfv(GLenum face, GLenum pname, const GLfloat *params);
180
181 void GLAPIENTRY
182 _es_Materialf(GLenum face, GLenum pname, GLfloat param);
183
184 void GLAPIENTRY
185 _es_VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
186
187 void GLAPIENTRY
188 _es_VertexAttrib1f(GLuint indx, GLfloat x);
189
190 void GLAPIENTRY
191 _es_VertexAttrib1fv(GLuint indx, const GLfloat* values);
192
193 void GLAPIENTRY
194 _es_VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
195
196 void GLAPIENTRY
197 _es_VertexAttrib2fv(GLuint indx, const GLfloat* values);
198
199 void GLAPIENTRY
200 _es_VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
201
202 void GLAPIENTRY
203 _es_VertexAttrib3fv(GLuint indx, const GLfloat* values);
204
205 void GLAPIENTRY
206 _es_VertexAttrib4fv(GLuint indx, const GLfloat* values);
207
208 #endif