xref: /aosp_15_r20/external/mesa3d/src/mesa/vbo/vbo.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1*61046927SAndroid Build Coastguard Worker /*
2*61046927SAndroid Build Coastguard Worker  * mesa 3-D graphics library
3*61046927SAndroid Build Coastguard Worker  *
4*61046927SAndroid Build Coastguard Worker  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
5*61046927SAndroid Build Coastguard Worker  *
6*61046927SAndroid Build Coastguard Worker  * Permission is hereby granted, free of charge, to any person obtaining a
7*61046927SAndroid Build Coastguard Worker  * copy of this software and associated documentation files (the "Software"),
8*61046927SAndroid Build Coastguard Worker  * to deal in the Software without restriction, including without limitation
9*61046927SAndroid Build Coastguard Worker  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10*61046927SAndroid Build Coastguard Worker  * and/or sell copies of the Software, and to permit persons to whom the
11*61046927SAndroid Build Coastguard Worker  * Software is furnished to do so, subject to the following conditions:
12*61046927SAndroid Build Coastguard Worker  *
13*61046927SAndroid Build Coastguard Worker  * The above copyright notice and this permission notice shall be included
14*61046927SAndroid Build Coastguard Worker  * in all copies or substantial portions of the Software.
15*61046927SAndroid Build Coastguard Worker  *
16*61046927SAndroid Build Coastguard Worker  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17*61046927SAndroid Build Coastguard Worker  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*61046927SAndroid Build Coastguard Worker  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19*61046927SAndroid Build Coastguard Worker  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20*61046927SAndroid Build Coastguard Worker  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21*61046927SAndroid Build Coastguard Worker  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22*61046927SAndroid Build Coastguard Worker  * OTHER DEALINGS IN THE SOFTWARE.
23*61046927SAndroid Build Coastguard Worker  */
24*61046927SAndroid Build Coastguard Worker 
25*61046927SAndroid Build Coastguard Worker /**
26*61046927SAndroid Build Coastguard Worker  * \brief Public interface to the VBO module
27*61046927SAndroid Build Coastguard Worker  * \author Keith Whitwell
28*61046927SAndroid Build Coastguard Worker  */
29*61046927SAndroid Build Coastguard Worker 
30*61046927SAndroid Build Coastguard Worker 
31*61046927SAndroid Build Coastguard Worker #ifndef _VBO_H
32*61046927SAndroid Build Coastguard Worker #define _VBO_H
33*61046927SAndroid Build Coastguard Worker 
34*61046927SAndroid Build Coastguard Worker #include <stdbool.h>
35*61046927SAndroid Build Coastguard Worker #include "util/glheader.h"
36*61046927SAndroid Build Coastguard Worker #include "main/dd.h"
37*61046927SAndroid Build Coastguard Worker #include "main/draw.h"
38*61046927SAndroid Build Coastguard Worker #include "main/macros.h"
39*61046927SAndroid Build Coastguard Worker #include "vbo_attrib.h"
40*61046927SAndroid Build Coastguard Worker #include "gallium/include/pipe/p_state.h"
41*61046927SAndroid Build Coastguard Worker 
42*61046927SAndroid Build Coastguard Worker #ifdef __cplusplus
43*61046927SAndroid Build Coastguard Worker extern "C" {
44*61046927SAndroid Build Coastguard Worker #endif
45*61046927SAndroid Build Coastguard Worker 
46*61046927SAndroid Build Coastguard Worker struct gl_context;
47*61046927SAndroid Build Coastguard Worker struct pipe_draw_info;
48*61046927SAndroid Build Coastguard Worker struct pipe_draw_start_count_bias;
49*61046927SAndroid Build Coastguard Worker 
50*61046927SAndroid Build Coastguard Worker /**
51*61046927SAndroid Build Coastguard Worker  * Max number of primitives (number of glBegin/End pairs) per VBO.
52*61046927SAndroid Build Coastguard Worker  */
53*61046927SAndroid Build Coastguard Worker #define VBO_MAX_PRIM 64
54*61046927SAndroid Build Coastguard Worker 
55*61046927SAndroid Build Coastguard Worker 
56*61046927SAndroid Build Coastguard Worker /**
57*61046927SAndroid Build Coastguard Worker  * Current vertex processing mode: fixed function vs. shader.
58*61046927SAndroid Build Coastguard Worker  * In reality, fixed function is probably implemented by a shader but that's
59*61046927SAndroid Build Coastguard Worker  * not what we care about here.
60*61046927SAndroid Build Coastguard Worker  */
61*61046927SAndroid Build Coastguard Worker typedef enum
62*61046927SAndroid Build Coastguard Worker {
63*61046927SAndroid Build Coastguard Worker    VP_MODE_FF,     /**< legacy / fixed function */
64*61046927SAndroid Build Coastguard Worker    VP_MODE_SHADER, /**< ARB vertex program or GLSL vertex shader */
65*61046927SAndroid Build Coastguard Worker    VP_MODE_MAX     /**< for sizing arrays */
66*61046927SAndroid Build Coastguard Worker } gl_vertex_processing_mode;
67*61046927SAndroid Build Coastguard Worker 
68*61046927SAndroid Build Coastguard Worker 
69*61046927SAndroid Build Coastguard Worker struct vbo_exec_eval1_map {
70*61046927SAndroid Build Coastguard Worker    struct gl_1d_map *map;
71*61046927SAndroid Build Coastguard Worker    GLuint sz;
72*61046927SAndroid Build Coastguard Worker };
73*61046927SAndroid Build Coastguard Worker 
74*61046927SAndroid Build Coastguard Worker struct vbo_exec_eval2_map {
75*61046927SAndroid Build Coastguard Worker    struct gl_2d_map *map;
76*61046927SAndroid Build Coastguard Worker    GLuint sz;
77*61046927SAndroid Build Coastguard Worker };
78*61046927SAndroid Build Coastguard Worker 
79*61046927SAndroid Build Coastguard Worker struct vbo_exec_copied_vtx {
80*61046927SAndroid Build Coastguard Worker    fi_type buffer[VBO_ATTRIB_MAX * 4 * VBO_MAX_COPIED_VERTS];
81*61046927SAndroid Build Coastguard Worker    GLuint nr;
82*61046927SAndroid Build Coastguard Worker };
83*61046927SAndroid Build Coastguard Worker 
84*61046927SAndroid Build Coastguard Worker struct vbo_markers
85*61046927SAndroid Build Coastguard Worker {
86*61046927SAndroid Build Coastguard Worker    /**
87*61046927SAndroid Build Coastguard Worker     * If false and the primitive is a line loop, the first vertex is
88*61046927SAndroid Build Coastguard Worker     * the beginning of the line loop and it won't be drawn.
89*61046927SAndroid Build Coastguard Worker     * Instead, it will be moved to the end.
90*61046927SAndroid Build Coastguard Worker     *
91*61046927SAndroid Build Coastguard Worker     * Drivers shouldn't reset the line stipple pattern walker if begin is
92*61046927SAndroid Build Coastguard Worker     * false and mode is a line strip.
93*61046927SAndroid Build Coastguard Worker     */
94*61046927SAndroid Build Coastguard Worker    bool begin;
95*61046927SAndroid Build Coastguard Worker 
96*61046927SAndroid Build Coastguard Worker    /**
97*61046927SAndroid Build Coastguard Worker     * If true and the primitive is a line loop, it will be closed.
98*61046927SAndroid Build Coastguard Worker     */
99*61046927SAndroid Build Coastguard Worker    bool end;
100*61046927SAndroid Build Coastguard Worker };
101*61046927SAndroid Build Coastguard Worker 
102*61046927SAndroid Build Coastguard Worker struct vbo_exec_context
103*61046927SAndroid Build Coastguard Worker {
104*61046927SAndroid Build Coastguard Worker    struct {
105*61046927SAndroid Build Coastguard Worker       /* Multi draw where the mode can vary between draws. */
106*61046927SAndroid Build Coastguard Worker       struct pipe_draw_info info;
107*61046927SAndroid Build Coastguard Worker       struct pipe_draw_start_count_bias draw[VBO_MAX_PRIM];
108*61046927SAndroid Build Coastguard Worker       GLubyte mode[VBO_MAX_PRIM];            /**< primitive modes per draw */
109*61046927SAndroid Build Coastguard Worker       struct vbo_markers markers[VBO_MAX_PRIM];
110*61046927SAndroid Build Coastguard Worker       unsigned prim_count;
111*61046927SAndroid Build Coastguard Worker 
112*61046927SAndroid Build Coastguard Worker       struct gl_buffer_object *bufferobj;
113*61046927SAndroid Build Coastguard Worker 
114*61046927SAndroid Build Coastguard Worker       GLuint vertex_size;       /* in dwords */
115*61046927SAndroid Build Coastguard Worker       GLuint vertex_size_no_pos;
116*61046927SAndroid Build Coastguard Worker 
117*61046927SAndroid Build Coastguard Worker       fi_type *buffer_map;
118*61046927SAndroid Build Coastguard Worker       fi_type *buffer_ptr;              /* cursor, points into buffer */
119*61046927SAndroid Build Coastguard Worker       GLuint   buffer_used;             /* in bytes */
120*61046927SAndroid Build Coastguard Worker       unsigned buffer_offset;           /* only for persistent mappings */
121*61046927SAndroid Build Coastguard Worker       fi_type vertex[VBO_ATTRIB_MAX*4]; /* current vertex */
122*61046927SAndroid Build Coastguard Worker 
123*61046927SAndroid Build Coastguard Worker       GLuint vert_count;   /**< Number of vertices currently in buffer */
124*61046927SAndroid Build Coastguard Worker       GLuint max_vert;     /**< Max number of vertices allowed in buffer */
125*61046927SAndroid Build Coastguard Worker       struct vbo_exec_copied_vtx copied;
126*61046927SAndroid Build Coastguard Worker 
127*61046927SAndroid Build Coastguard Worker       GLbitfield64 enabled;             /**< mask of enabled vbo arrays. */
128*61046927SAndroid Build Coastguard Worker 
129*61046927SAndroid Build Coastguard Worker       /* Keep these packed in a structure for faster access. */
130*61046927SAndroid Build Coastguard Worker       struct {
131*61046927SAndroid Build Coastguard Worker          GLenum16 type;       /**< GL_FLOAT, GL_DOUBLE, GL_INT, etc */
132*61046927SAndroid Build Coastguard Worker          GLubyte active_size; /**< number of components, but can shrink */
133*61046927SAndroid Build Coastguard Worker          GLubyte size;        /**< number of components (1..4) */
134*61046927SAndroid Build Coastguard Worker       } attr[VBO_ATTRIB_MAX];
135*61046927SAndroid Build Coastguard Worker 
136*61046927SAndroid Build Coastguard Worker       /** pointers into the current 'vertex' array, declared above */
137*61046927SAndroid Build Coastguard Worker       fi_type *attrptr[VBO_ATTRIB_MAX];
138*61046927SAndroid Build Coastguard Worker    } vtx;
139*61046927SAndroid Build Coastguard Worker 
140*61046927SAndroid Build Coastguard Worker    struct {
141*61046927SAndroid Build Coastguard Worker       GLboolean recalculate_maps;
142*61046927SAndroid Build Coastguard Worker       struct vbo_exec_eval1_map map1[VERT_ATTRIB_MAX];
143*61046927SAndroid Build Coastguard Worker       struct vbo_exec_eval2_map map2[VERT_ATTRIB_MAX];
144*61046927SAndroid Build Coastguard Worker    } eval;
145*61046927SAndroid Build Coastguard Worker 
146*61046927SAndroid Build Coastguard Worker #ifndef NDEBUG
147*61046927SAndroid Build Coastguard Worker    GLint flush_call_depth;
148*61046927SAndroid Build Coastguard Worker #endif
149*61046927SAndroid Build Coastguard Worker };
150*61046927SAndroid Build Coastguard Worker 
151*61046927SAndroid Build Coastguard Worker 
152*61046927SAndroid Build Coastguard Worker struct vbo_save_context {
153*61046927SAndroid Build Coastguard Worker    GLbitfield64 enabled; /**< mask of enabled vbo arrays. */
154*61046927SAndroid Build Coastguard Worker    GLubyte attrsz[VBO_ATTRIB_MAX];  /**< 1, 2, 3 or 4 */
155*61046927SAndroid Build Coastguard Worker    GLenum16 attrtype[VBO_ATTRIB_MAX];  /**< GL_FLOAT, GL_INT, etc */
156*61046927SAndroid Build Coastguard Worker    GLubyte active_sz[VBO_ATTRIB_MAX];  /**< 1, 2, 3 or 4 */
157*61046927SAndroid Build Coastguard Worker    GLuint vertex_size;  /**< size in GLfloats */
158*61046927SAndroid Build Coastguard Worker    struct gl_vertex_array_object *VAO[VP_MODE_MAX];
159*61046927SAndroid Build Coastguard Worker 
160*61046927SAndroid Build Coastguard Worker    struct vbo_save_vertex_store *vertex_store;
161*61046927SAndroid Build Coastguard Worker    struct vbo_save_primitive_store *prim_store;
162*61046927SAndroid Build Coastguard Worker    struct gl_buffer_object *current_bo;
163*61046927SAndroid Build Coastguard Worker    unsigned current_bo_bytes_used;
164*61046927SAndroid Build Coastguard Worker 
165*61046927SAndroid Build Coastguard Worker    fi_type vertex[VBO_ATTRIB_MAX*4];	   /* current values */
166*61046927SAndroid Build Coastguard Worker    fi_type *attrptr[VBO_ATTRIB_MAX];
167*61046927SAndroid Build Coastguard Worker 
168*61046927SAndroid Build Coastguard Worker    struct {
169*61046927SAndroid Build Coastguard Worker       fi_type *buffer;
170*61046927SAndroid Build Coastguard Worker       GLuint nr;
171*61046927SAndroid Build Coastguard Worker    } copied;
172*61046927SAndroid Build Coastguard Worker 
173*61046927SAndroid Build Coastguard Worker    fi_type *current[VBO_ATTRIB_MAX]; /* points into ctx->ListState */
174*61046927SAndroid Build Coastguard Worker    GLubyte *currentsz[VBO_ATTRIB_MAX];
175*61046927SAndroid Build Coastguard Worker 
176*61046927SAndroid Build Coastguard Worker    GLboolean dangling_attr_ref;
177*61046927SAndroid Build Coastguard Worker    GLboolean out_of_memory;  /**< True if last VBO allocation failed */
178*61046927SAndroid Build Coastguard Worker    bool no_current_update;
179*61046927SAndroid Build Coastguard Worker };
180*61046927SAndroid Build Coastguard Worker 
181*61046927SAndroid Build Coastguard Worker GLboolean
182*61046927SAndroid Build Coastguard Worker _mesa_using_noop_vtxfmt(const struct _glapi_table *dispatch);
183*61046927SAndroid Build Coastguard Worker 
184*61046927SAndroid Build Coastguard Worker GLboolean
185*61046927SAndroid Build Coastguard Worker _vbo_CreateContext(struct gl_context *ctx);
186*61046927SAndroid Build Coastguard Worker 
187*61046927SAndroid Build Coastguard Worker void
188*61046927SAndroid Build Coastguard Worker _vbo_DestroyContext(struct gl_context *ctx);
189*61046927SAndroid Build Coastguard Worker 
190*61046927SAndroid Build Coastguard Worker void
191*61046927SAndroid Build Coastguard Worker vbo_init_dispatch_begin_end(struct gl_context *ctx);
192*61046927SAndroid Build Coastguard Worker 
193*61046927SAndroid Build Coastguard Worker void
194*61046927SAndroid Build Coastguard Worker vbo_init_dispatch_hw_select_begin_end(struct gl_context *ctx);
195*61046927SAndroid Build Coastguard Worker 
196*61046927SAndroid Build Coastguard Worker void
197*61046927SAndroid Build Coastguard Worker vbo_install_exec_vtxfmt_noop(struct gl_context *ctx);
198*61046927SAndroid Build Coastguard Worker 
199*61046927SAndroid Build Coastguard Worker void
200*61046927SAndroid Build Coastguard Worker vbo_install_save_vtxfmt_noop(struct gl_context *ctx);
201*61046927SAndroid Build Coastguard Worker 
202*61046927SAndroid Build Coastguard Worker void
203*61046927SAndroid Build Coastguard Worker vbo_exec_update_eval_maps(struct gl_context *ctx);
204*61046927SAndroid Build Coastguard Worker 
205*61046927SAndroid Build Coastguard Worker void
206*61046927SAndroid Build Coastguard Worker vbo_reset_all_attr(struct gl_context *ctx);
207*61046927SAndroid Build Coastguard Worker 
208*61046927SAndroid Build Coastguard Worker void
209*61046927SAndroid Build Coastguard Worker vbo_exec_FlushVertices(struct gl_context *ctx, GLuint flags);
210*61046927SAndroid Build Coastguard Worker 
211*61046927SAndroid Build Coastguard Worker void
212*61046927SAndroid Build Coastguard Worker vbo_save_SaveFlushVertices(struct gl_context *ctx);
213*61046927SAndroid Build Coastguard Worker 
214*61046927SAndroid Build Coastguard Worker void
215*61046927SAndroid Build Coastguard Worker vbo_save_NotifyBegin(struct gl_context *ctx, GLenum mode,
216*61046927SAndroid Build Coastguard Worker                      bool no_current_update);
217*61046927SAndroid Build Coastguard Worker 
218*61046927SAndroid Build Coastguard Worker void
219*61046927SAndroid Build Coastguard Worker vbo_save_NewList(struct gl_context *ctx, GLuint list, GLenum mode);
220*61046927SAndroid Build Coastguard Worker 
221*61046927SAndroid Build Coastguard Worker void
222*61046927SAndroid Build Coastguard Worker vbo_save_EndList(struct gl_context *ctx);
223*61046927SAndroid Build Coastguard Worker 
224*61046927SAndroid Build Coastguard Worker void
225*61046927SAndroid Build Coastguard Worker vbo_delete_minmax_cache(struct gl_buffer_object *bufferObj);
226*61046927SAndroid Build Coastguard Worker 
227*61046927SAndroid Build Coastguard Worker void
228*61046927SAndroid Build Coastguard Worker vbo_get_minmax_index_mapped(unsigned count, unsigned index_size,
229*61046927SAndroid Build Coastguard Worker                             unsigned restartIndex, bool restart,
230*61046927SAndroid Build Coastguard Worker                             const void *indices,
231*61046927SAndroid Build Coastguard Worker                             unsigned *min_index, unsigned *max_index);
232*61046927SAndroid Build Coastguard Worker 
233*61046927SAndroid Build Coastguard Worker void
234*61046927SAndroid Build Coastguard Worker vbo_get_minmax_index(struct gl_context *ctx, struct gl_buffer_object *obj,
235*61046927SAndroid Build Coastguard Worker                      const void *ptr, GLintptr offset, unsigned count,
236*61046927SAndroid Build Coastguard Worker                      unsigned index_size, bool primitive_restart,
237*61046927SAndroid Build Coastguard Worker                      unsigned restart_index, GLuint *min_index,
238*61046927SAndroid Build Coastguard Worker                      GLuint *max_index);
239*61046927SAndroid Build Coastguard Worker 
240*61046927SAndroid Build Coastguard Worker bool
241*61046927SAndroid Build Coastguard Worker vbo_get_minmax_indices_gallium(struct gl_context *ctx,
242*61046927SAndroid Build Coastguard Worker                                struct pipe_draw_info *info,
243*61046927SAndroid Build Coastguard Worker                                const struct pipe_draw_start_count_bias *draws,
244*61046927SAndroid Build Coastguard Worker                                unsigned num_draws);
245*61046927SAndroid Build Coastguard Worker 
246*61046927SAndroid Build Coastguard Worker const struct gl_array_attributes*
247*61046927SAndroid Build Coastguard Worker _vbo_current_attrib(const struct gl_context *ctx, gl_vert_attrib attr);
248*61046927SAndroid Build Coastguard Worker 
249*61046927SAndroid Build Coastguard Worker void GLAPIENTRY
250*61046927SAndroid Build Coastguard Worker _es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
251*61046927SAndroid Build Coastguard Worker 
252*61046927SAndroid Build Coastguard Worker void GLAPIENTRY
253*61046927SAndroid Build Coastguard Worker _es_Normal3f(GLfloat x, GLfloat y, GLfloat z);
254*61046927SAndroid Build Coastguard Worker 
255*61046927SAndroid Build Coastguard Worker void GLAPIENTRY
256*61046927SAndroid Build Coastguard Worker _es_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
257*61046927SAndroid Build Coastguard Worker 
258*61046927SAndroid Build Coastguard Worker void GLAPIENTRY
259*61046927SAndroid Build Coastguard Worker _es_Materialfv(GLenum face, GLenum pname, const GLfloat *params);
260*61046927SAndroid Build Coastguard Worker 
261*61046927SAndroid Build Coastguard Worker void GLAPIENTRY
262*61046927SAndroid Build Coastguard Worker _es_Materialf(GLenum face, GLenum pname, GLfloat param);
263*61046927SAndroid Build Coastguard Worker 
264*61046927SAndroid Build Coastguard Worker #ifdef __cplusplus
265*61046927SAndroid Build Coastguard Worker } // extern "C"
266*61046927SAndroid Build Coastguard Worker #endif
267*61046927SAndroid Build Coastguard Worker 
268*61046927SAndroid Build Coastguard Worker #endif
269