2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
26 * Keith Whitwell <keith@tungstengraphics.com> Gareth Hughes
30 #include "api_arrayelt.h"
37 #include "main/dispatch.h"
38 #include "vbo/vbo_context.h"
42 * Use the per-vertex functions found in <vfmt> to initialize the given
44 * If beginend is true, only plug in the functions which are legal
45 * between glBegin/glEnd.
48 install_vtxfmt(struct gl_context
*ctx
, struct _glapi_table
*tab
,
49 const GLvertexformat
*vfmt
, bool beginend
)
51 assert(ctx
->Version
> 0);
53 if (ctx
->API
!= API_OPENGL_CORE
&& ctx
->API
!= API_OPENGLES2
) {
54 SET_Color4f(tab
, vfmt
->Color4f
);
57 if (ctx
->API
== API_OPENGL_COMPAT
) {
58 _mesa_install_arrayelt_vtxfmt(tab
, vfmt
);
59 SET_Color3f(tab
, vfmt
->Color3f
);
60 SET_Color3fv(tab
, vfmt
->Color3fv
);
61 SET_Color4fv(tab
, vfmt
->Color4fv
);
62 SET_EdgeFlag(tab
, vfmt
->EdgeFlag
);
65 if (ctx
->API
== API_OPENGL_COMPAT
) {
66 _mesa_install_eval_vtxfmt(tab
, vfmt
, beginend
);
69 if (ctx
->API
!= API_OPENGL_CORE
&& ctx
->API
!= API_OPENGLES2
) {
70 SET_Materialfv(tab
, vfmt
->Materialfv
);
71 SET_MultiTexCoord4fARB(tab
, vfmt
->MultiTexCoord4fARB
);
72 SET_Normal3f(tab
, vfmt
->Normal3f
);
75 if (ctx
->API
== API_OPENGL_COMPAT
) {
76 SET_FogCoordfEXT(tab
, vfmt
->FogCoordfEXT
);
77 SET_FogCoordfvEXT(tab
, vfmt
->FogCoordfvEXT
);
78 SET_Indexf(tab
, vfmt
->Indexf
);
79 SET_Indexfv(tab
, vfmt
->Indexfv
);
80 SET_MultiTexCoord1fARB(tab
, vfmt
->MultiTexCoord1fARB
);
81 SET_MultiTexCoord1fvARB(tab
, vfmt
->MultiTexCoord1fvARB
);
82 SET_MultiTexCoord2fARB(tab
, vfmt
->MultiTexCoord2fARB
);
83 SET_MultiTexCoord2fvARB(tab
, vfmt
->MultiTexCoord2fvARB
);
84 SET_MultiTexCoord3fARB(tab
, vfmt
->MultiTexCoord3fARB
);
85 SET_MultiTexCoord3fvARB(tab
, vfmt
->MultiTexCoord3fvARB
);
86 SET_MultiTexCoord4fvARB(tab
, vfmt
->MultiTexCoord4fvARB
);
87 SET_Normal3fv(tab
, vfmt
->Normal3fv
);
90 if (ctx
->API
== API_OPENGL_COMPAT
) {
91 SET_SecondaryColor3fEXT(tab
, vfmt
->SecondaryColor3fEXT
);
92 SET_SecondaryColor3fvEXT(tab
, vfmt
->SecondaryColor3fvEXT
);
93 SET_TexCoord1f(tab
, vfmt
->TexCoord1f
);
94 SET_TexCoord1fv(tab
, vfmt
->TexCoord1fv
);
95 SET_TexCoord2f(tab
, vfmt
->TexCoord2f
);
96 SET_TexCoord2fv(tab
, vfmt
->TexCoord2fv
);
97 SET_TexCoord3f(tab
, vfmt
->TexCoord3f
);
98 SET_TexCoord3fv(tab
, vfmt
->TexCoord3fv
);
99 SET_TexCoord4f(tab
, vfmt
->TexCoord4f
);
100 SET_TexCoord4fv(tab
, vfmt
->TexCoord4fv
);
101 SET_Vertex2f(tab
, vfmt
->Vertex2f
);
102 SET_Vertex2fv(tab
, vfmt
->Vertex2fv
);
103 SET_Vertex3f(tab
, vfmt
->Vertex3f
);
104 SET_Vertex3fv(tab
, vfmt
->Vertex3fv
);
105 SET_Vertex4f(tab
, vfmt
->Vertex4f
);
106 SET_Vertex4fv(tab
, vfmt
->Vertex4fv
);
109 if (ctx
->API
== API_OPENGL_COMPAT
) {
110 _mesa_install_dlist_vtxfmt(tab
, vfmt
); /* glCallList / glCallLists */
112 SET_Begin(tab
, vfmt
->Begin
);
113 SET_End(tab
, vfmt
->End
);
114 SET_PrimitiveRestartNV(tab
, vfmt
->PrimitiveRestartNV
);
116 SET_Rectf(tab
, vfmt
->Rectf
);
120 /* These functions are only valid outside glBegin/glEnd */
121 SET_DrawArrays(tab
, vfmt
->DrawArrays
);
122 SET_DrawElements(tab
, vfmt
->DrawElements
);
124 if (_mesa_is_desktop_gl(ctx
) || _mesa_is_gles3(ctx
)) {
125 SET_DrawRangeElements(tab
, vfmt
->DrawRangeElements
);
128 SET_MultiDrawElementsEXT(tab
, vfmt
->MultiDrawElementsEXT
);
130 if (_mesa_is_desktop_gl(ctx
)) {
131 SET_DrawElementsBaseVertex(tab
, vfmt
->DrawElementsBaseVertex
);
132 SET_DrawRangeElementsBaseVertex(tab
,
133 vfmt
->DrawRangeElementsBaseVertex
);
134 SET_MultiDrawElementsBaseVertex(tab
,
135 vfmt
->MultiDrawElementsBaseVertex
);
136 SET_DrawArraysInstancedBaseInstance(tab
,
137 vfmt
->DrawArraysInstancedBaseInstance
);
138 SET_DrawElementsInstancedBaseInstance(tab
,
139 vfmt
->DrawElementsInstancedBaseInstance
);
140 SET_DrawElementsInstancedBaseVertex(tab
,
141 vfmt
->DrawElementsInstancedBaseVertex
);
142 SET_DrawElementsInstancedBaseVertexBaseInstance(tab
,
143 vfmt
->DrawElementsInstancedBaseVertexBaseInstance
);
146 if (_mesa_is_desktop_gl(ctx
) || _mesa_is_gles3(ctx
)) {
147 SET_DrawArraysInstancedARB(tab
, vfmt
->DrawArraysInstanced
);
148 SET_DrawElementsInstancedARB(tab
, vfmt
->DrawElementsInstanced
);
151 if (_mesa_is_desktop_gl(ctx
)) {
152 SET_DrawTransformFeedback(tab
, vfmt
->DrawTransformFeedback
);
153 SET_DrawTransformFeedbackStream(tab
,
154 vfmt
->DrawTransformFeedbackStream
);
155 SET_DrawTransformFeedbackInstanced(tab
,
156 vfmt
->DrawTransformFeedbackInstanced
);
157 SET_DrawTransformFeedbackStreamInstanced(tab
,
158 vfmt
->DrawTransformFeedbackStreamInstanced
);
162 /* Originally for GL_NV_vertex_program, this is also used by dlist.c */
163 if (ctx
->API
== API_OPENGL_COMPAT
) {
164 SET_VertexAttrib1fNV(tab
, vfmt
->VertexAttrib1fNV
);
165 SET_VertexAttrib1fvNV(tab
, vfmt
->VertexAttrib1fvNV
);
166 SET_VertexAttrib2fNV(tab
, vfmt
->VertexAttrib2fNV
);
167 SET_VertexAttrib2fvNV(tab
, vfmt
->VertexAttrib2fvNV
);
168 SET_VertexAttrib3fNV(tab
, vfmt
->VertexAttrib3fNV
);
169 SET_VertexAttrib3fvNV(tab
, vfmt
->VertexAttrib3fvNV
);
170 SET_VertexAttrib4fNV(tab
, vfmt
->VertexAttrib4fNV
);
171 SET_VertexAttrib4fvNV(tab
, vfmt
->VertexAttrib4fvNV
);
174 if (ctx
->API
!= API_OPENGLES
) {
175 SET_VertexAttrib1fARB(tab
, vfmt
->VertexAttrib1fARB
);
176 SET_VertexAttrib1fvARB(tab
, vfmt
->VertexAttrib1fvARB
);
177 SET_VertexAttrib2fARB(tab
, vfmt
->VertexAttrib2fARB
);
178 SET_VertexAttrib2fvARB(tab
, vfmt
->VertexAttrib2fvARB
);
179 SET_VertexAttrib3fARB(tab
, vfmt
->VertexAttrib3fARB
);
180 SET_VertexAttrib3fvARB(tab
, vfmt
->VertexAttrib3fvARB
);
181 SET_VertexAttrib4fARB(tab
, vfmt
->VertexAttrib4fARB
);
182 SET_VertexAttrib4fvARB(tab
, vfmt
->VertexAttrib4fvARB
);
185 /* GL_EXT_gpu_shader4 / OpenGL 3.0 */
186 if (_mesa_is_desktop_gl(ctx
)) {
187 SET_VertexAttribI1iEXT(tab
, vfmt
->VertexAttribI1i
);
188 SET_VertexAttribI2iEXT(tab
, vfmt
->VertexAttribI2i
);
189 SET_VertexAttribI3iEXT(tab
, vfmt
->VertexAttribI3i
);
190 SET_VertexAttribI2ivEXT(tab
, vfmt
->VertexAttribI2iv
);
191 SET_VertexAttribI3ivEXT(tab
, vfmt
->VertexAttribI3iv
);
193 SET_VertexAttribI1uiEXT(tab
, vfmt
->VertexAttribI1ui
);
194 SET_VertexAttribI2uiEXT(tab
, vfmt
->VertexAttribI2ui
);
195 SET_VertexAttribI3uiEXT(tab
, vfmt
->VertexAttribI3ui
);
196 SET_VertexAttribI2uivEXT(tab
, vfmt
->VertexAttribI2uiv
);
197 SET_VertexAttribI3uivEXT(tab
, vfmt
->VertexAttribI3uiv
);
200 if (_mesa_is_desktop_gl(ctx
) || _mesa_is_gles3(ctx
)) {
201 SET_VertexAttribI4iEXT(tab
, vfmt
->VertexAttribI4i
);
202 SET_VertexAttribI4ivEXT(tab
, vfmt
->VertexAttribI4iv
);
203 SET_VertexAttribI4uiEXT(tab
, vfmt
->VertexAttribI4ui
);
204 SET_VertexAttribI4uivEXT(tab
, vfmt
->VertexAttribI4uiv
);
207 if (ctx
->API
== API_OPENGL_COMPAT
) {
208 /* GL_ARB_vertex_type_10_10_10_2_rev / GL 3.3 */
209 SET_VertexP2ui(tab
, vfmt
->VertexP2ui
);
210 SET_VertexP2uiv(tab
, vfmt
->VertexP2uiv
);
211 SET_VertexP3ui(tab
, vfmt
->VertexP3ui
);
212 SET_VertexP3uiv(tab
, vfmt
->VertexP3uiv
);
213 SET_VertexP4ui(tab
, vfmt
->VertexP4ui
);
214 SET_VertexP4uiv(tab
, vfmt
->VertexP4uiv
);
216 SET_TexCoordP1ui(tab
, vfmt
->TexCoordP1ui
);
217 SET_TexCoordP1uiv(tab
, vfmt
->TexCoordP1uiv
);
218 SET_TexCoordP2ui(tab
, vfmt
->TexCoordP2ui
);
219 SET_TexCoordP2uiv(tab
, vfmt
->TexCoordP2uiv
);
220 SET_TexCoordP3ui(tab
, vfmt
->TexCoordP3ui
);
221 SET_TexCoordP3uiv(tab
, vfmt
->TexCoordP3uiv
);
222 SET_TexCoordP4ui(tab
, vfmt
->TexCoordP4ui
);
223 SET_TexCoordP4uiv(tab
, vfmt
->TexCoordP4uiv
);
225 SET_MultiTexCoordP1ui(tab
, vfmt
->MultiTexCoordP1ui
);
226 SET_MultiTexCoordP2ui(tab
, vfmt
->MultiTexCoordP2ui
);
227 SET_MultiTexCoordP3ui(tab
, vfmt
->MultiTexCoordP3ui
);
228 SET_MultiTexCoordP4ui(tab
, vfmt
->MultiTexCoordP4ui
);
229 SET_MultiTexCoordP1uiv(tab
, vfmt
->MultiTexCoordP1uiv
);
230 SET_MultiTexCoordP2uiv(tab
, vfmt
->MultiTexCoordP2uiv
);
231 SET_MultiTexCoordP3uiv(tab
, vfmt
->MultiTexCoordP3uiv
);
232 SET_MultiTexCoordP4uiv(tab
, vfmt
->MultiTexCoordP4uiv
);
234 SET_NormalP3ui(tab
, vfmt
->NormalP3ui
);
235 SET_NormalP3uiv(tab
, vfmt
->NormalP3uiv
);
237 SET_ColorP3ui(tab
, vfmt
->ColorP3ui
);
238 SET_ColorP4ui(tab
, vfmt
->ColorP4ui
);
239 SET_ColorP3uiv(tab
, vfmt
->ColorP3uiv
);
240 SET_ColorP4uiv(tab
, vfmt
->ColorP4uiv
);
242 SET_SecondaryColorP3ui(tab
, vfmt
->SecondaryColorP3ui
);
243 SET_SecondaryColorP3uiv(tab
, vfmt
->SecondaryColorP3uiv
);
246 if (_mesa_is_desktop_gl(ctx
)) {
247 SET_VertexAttribP1ui(tab
, vfmt
->VertexAttribP1ui
);
248 SET_VertexAttribP2ui(tab
, vfmt
->VertexAttribP2ui
);
249 SET_VertexAttribP3ui(tab
, vfmt
->VertexAttribP3ui
);
250 SET_VertexAttribP4ui(tab
, vfmt
->VertexAttribP4ui
);
252 SET_VertexAttribP1uiv(tab
, vfmt
->VertexAttribP1uiv
);
253 SET_VertexAttribP2uiv(tab
, vfmt
->VertexAttribP2uiv
);
254 SET_VertexAttribP3uiv(tab
, vfmt
->VertexAttribP3uiv
);
255 SET_VertexAttribP4uiv(tab
, vfmt
->VertexAttribP4uiv
);
261 * Install per-vertex functions into the API dispatch table for execution.
264 _mesa_install_exec_vtxfmt(struct gl_context
*ctx
, const GLvertexformat
*vfmt
)
266 install_vtxfmt(ctx
, ctx
->Exec
, vfmt
, false);
268 install_vtxfmt(ctx
, ctx
->BeginEnd
, vfmt
, true);
273 * Install per-vertex functions into the API dispatch table for display
277 _mesa_install_save_vtxfmt(struct gl_context
*ctx
, const GLvertexformat
*vfmt
)
279 if (_mesa_is_desktop_gl(ctx
))
280 install_vtxfmt(ctx
, ctx
->Save
, vfmt
, false);
285 * Install VBO vtxfmt functions.
287 * This function depends on ctx->Version.
290 _mesa_initialize_vbo_vtxfmt(struct gl_context
*ctx
)
292 struct vbo_exec_context
*exec
= &vbo_context(ctx
)->exec
;
293 _mesa_install_exec_vtxfmt(ctx
, &exec
->vtxfmt
);
294 if (ctx
->API
== API_OPENGL_COMPAT
) {
295 _mesa_install_save_vtxfmt(ctx
, &ctx
->ListState
.ListVtxfmt
);