1/* 2 * Mesa 3-D graphics library 3 * Version: 6.3 4 * 5 * Copyright (C) 1999-2004 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 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 * 24 * Authors: 25 * Keith Whitwell <keith@tungstengraphics.com> 26 * Gareth Hughes 27 */ 28 29#include "glheader.h" 30#include "api_arrayelt.h" 31#include "context.h" 32#include "imports.h" 33#include "mfeatures.h" 34#include "mtypes.h" 35#include "vtxfmt.h" 36#include "eval.h" 37#include "dlist.h" 38#include "main/dispatch.h" 39 40 41#if FEATURE_beginend 42 43/** 44 * Use the per-vertex functions found in <vfmt> to initialize the given 45 * API dispatch table. 46 */ 47static void 48install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab, 49 const GLvertexformat *vfmt) 50{ 51 if (ctx->API != API_OPENGL_CORE && ctx->API != API_OPENGLES2) { 52 _mesa_install_arrayelt_vtxfmt(tab, vfmt); 53 SET_Color3f(tab, vfmt->Color3f); 54 SET_Color3fv(tab, vfmt->Color3fv); 55 SET_Color4f(tab, vfmt->Color4f); 56 SET_Color4fv(tab, vfmt->Color4fv); 57 SET_EdgeFlag(tab, vfmt->EdgeFlag); 58 } 59 60 if (ctx->API == API_OPENGL) { 61 _mesa_install_eval_vtxfmt(tab, vfmt); 62 } 63 64 if (ctx->API != API_OPENGL_CORE && ctx->API != API_OPENGLES2) { 65 SET_FogCoordfEXT(tab, vfmt->FogCoordfEXT); 66 SET_FogCoordfvEXT(tab, vfmt->FogCoordfvEXT); 67 SET_Indexf(tab, vfmt->Indexf); 68 SET_Indexfv(tab, vfmt->Indexfv); 69 SET_Materialfv(tab, vfmt->Materialfv); 70 SET_MultiTexCoord1fARB(tab, vfmt->MultiTexCoord1fARB); 71 SET_MultiTexCoord1fvARB(tab, vfmt->MultiTexCoord1fvARB); 72 SET_MultiTexCoord2fARB(tab, vfmt->MultiTexCoord2fARB); 73 SET_MultiTexCoord2fvARB(tab, vfmt->MultiTexCoord2fvARB); 74 SET_MultiTexCoord3fARB(tab, vfmt->MultiTexCoord3fARB); 75 SET_MultiTexCoord3fvARB(tab, vfmt->MultiTexCoord3fvARB); 76 SET_MultiTexCoord4fARB(tab, vfmt->MultiTexCoord4fARB); 77 SET_MultiTexCoord4fvARB(tab, vfmt->MultiTexCoord4fvARB); 78 SET_Normal3f(tab, vfmt->Normal3f); 79 SET_Normal3fv(tab, vfmt->Normal3fv); 80 SET_SecondaryColor3fEXT(tab, vfmt->SecondaryColor3fEXT); 81 SET_SecondaryColor3fvEXT(tab, vfmt->SecondaryColor3fvEXT); 82 SET_TexCoord1f(tab, vfmt->TexCoord1f); 83 SET_TexCoord1fv(tab, vfmt->TexCoord1fv); 84 SET_TexCoord2f(tab, vfmt->TexCoord2f); 85 SET_TexCoord2fv(tab, vfmt->TexCoord2fv); 86 SET_TexCoord3f(tab, vfmt->TexCoord3f); 87 SET_TexCoord3fv(tab, vfmt->TexCoord3fv); 88 SET_TexCoord4f(tab, vfmt->TexCoord4f); 89 SET_TexCoord4fv(tab, vfmt->TexCoord4fv); 90 SET_Vertex2f(tab, vfmt->Vertex2f); 91 SET_Vertex2fv(tab, vfmt->Vertex2fv); 92 SET_Vertex3f(tab, vfmt->Vertex3f); 93 SET_Vertex3fv(tab, vfmt->Vertex3fv); 94 SET_Vertex4f(tab, vfmt->Vertex4f); 95 SET_Vertex4fv(tab, vfmt->Vertex4fv); 96 } 97 98 if (ctx->API == API_OPENGL) { 99 _mesa_install_dlist_vtxfmt(tab, vfmt); /* glCallList / glCallLists */ 100 101 SET_Begin(tab, vfmt->Begin); 102 SET_End(tab, vfmt->End); 103 SET_PrimitiveRestartNV(tab, vfmt->PrimitiveRestartNV); 104 105 SET_Rectf(tab, vfmt->Rectf); 106 } 107 108 SET_DrawArrays(tab, vfmt->DrawArrays); 109 SET_DrawElements(tab, vfmt->DrawElements); 110 if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) { 111 SET_DrawRangeElements(tab, vfmt->DrawRangeElements); 112 } 113 114 SET_MultiDrawElementsEXT(tab, vfmt->MultiDrawElementsEXT); 115 116 if (ctx->API != API_OPENGLES2) { 117 SET_DrawElementsBaseVertex(tab, vfmt->DrawElementsBaseVertex); 118 SET_DrawRangeElementsBaseVertex(tab, vfmt->DrawRangeElementsBaseVertex); 119 SET_MultiDrawElementsBaseVertex(tab, vfmt->MultiDrawElementsBaseVertex); 120 SET_DrawArraysInstancedBaseInstance(tab, vfmt->DrawArraysInstancedBaseInstance); 121 SET_DrawElementsInstancedBaseInstance(tab, vfmt->DrawElementsInstancedBaseInstance); 122 SET_DrawElementsInstancedBaseVertex(tab, vfmt->DrawElementsInstancedBaseVertex); 123 SET_DrawElementsInstancedBaseVertexBaseInstance(tab, vfmt->DrawElementsInstancedBaseVertexBaseInstance); 124 } 125 126 if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) { 127 SET_DrawArraysInstancedARB(tab, vfmt->DrawArraysInstanced); 128 SET_DrawElementsInstancedARB(tab, vfmt->DrawElementsInstanced); 129 } 130 131 if (ctx->API != API_OPENGLES2) { 132 SET_DrawTransformFeedback(tab, vfmt->DrawTransformFeedback); 133 SET_DrawTransformFeedbackStream(tab, vfmt->DrawTransformFeedbackStream); 134 SET_DrawTransformFeedbackInstanced(tab, 135 vfmt->DrawTransformFeedbackInstanced); 136 SET_DrawTransformFeedbackStreamInstanced(tab, 137 vfmt->DrawTransformFeedbackStreamInstanced); 138 } 139 140 /* GL_NV_vertex_program */ 141#if FEATURE_ARB_vertex_program 142 if (ctx->API == API_OPENGL) { 143 SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV); 144 SET_VertexAttrib1fvNV(tab, vfmt->VertexAttrib1fvNV); 145 SET_VertexAttrib2fNV(tab, vfmt->VertexAttrib2fNV); 146 SET_VertexAttrib2fvNV(tab, vfmt->VertexAttrib2fvNV); 147 SET_VertexAttrib3fNV(tab, vfmt->VertexAttrib3fNV); 148 SET_VertexAttrib3fvNV(tab, vfmt->VertexAttrib3fvNV); 149 SET_VertexAttrib4fNV(tab, vfmt->VertexAttrib4fNV); 150 SET_VertexAttrib4fvNV(tab, vfmt->VertexAttrib4fvNV); 151 } 152 153 SET_VertexAttrib1fARB(tab, vfmt->VertexAttrib1fARB); 154 SET_VertexAttrib1fvARB(tab, vfmt->VertexAttrib1fvARB); 155 SET_VertexAttrib2fARB(tab, vfmt->VertexAttrib2fARB); 156 SET_VertexAttrib2fvARB(tab, vfmt->VertexAttrib2fvARB); 157 SET_VertexAttrib3fARB(tab, vfmt->VertexAttrib3fARB); 158 SET_VertexAttrib3fvARB(tab, vfmt->VertexAttrib3fvARB); 159 SET_VertexAttrib4fARB(tab, vfmt->VertexAttrib4fARB); 160 SET_VertexAttrib4fvARB(tab, vfmt->VertexAttrib4fvARB); 161#endif 162 163 /* GL_EXT_gpu_shader4 / OpenGL 3.0 */ 164 if (ctx->API != API_OPENGLES2) { 165 SET_VertexAttribI1iEXT(tab, vfmt->VertexAttribI1i); 166 SET_VertexAttribI2iEXT(tab, vfmt->VertexAttribI2i); 167 SET_VertexAttribI3iEXT(tab, vfmt->VertexAttribI3i); 168 SET_VertexAttribI2ivEXT(tab, vfmt->VertexAttribI2iv); 169 SET_VertexAttribI3ivEXT(tab, vfmt->VertexAttribI3iv); 170 171 SET_VertexAttribI1uiEXT(tab, vfmt->VertexAttribI1ui); 172 SET_VertexAttribI2uiEXT(tab, vfmt->VertexAttribI2ui); 173 SET_VertexAttribI3uiEXT(tab, vfmt->VertexAttribI3ui); 174 SET_VertexAttribI2uivEXT(tab, vfmt->VertexAttribI2uiv); 175 SET_VertexAttribI3uivEXT(tab, vfmt->VertexAttribI3uiv); 176 } 177 178 if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) { 179 SET_VertexAttribI4iEXT(tab, vfmt->VertexAttribI4i); 180 SET_VertexAttribI4ivEXT(tab, vfmt->VertexAttribI4iv); 181 SET_VertexAttribI4uiEXT(tab, vfmt->VertexAttribI4ui); 182 SET_VertexAttribI4uivEXT(tab, vfmt->VertexAttribI4uiv); 183 } 184 185 if (ctx->API != API_OPENGL_CORE && ctx->API != API_OPENGLES2) { 186 /* GL_ARB_vertex_type_10_10_10_2_rev / GL 3.3 */ 187 SET_VertexP2ui(tab, vfmt->VertexP2ui); 188 SET_VertexP2uiv(tab, vfmt->VertexP2uiv); 189 SET_VertexP3ui(tab, vfmt->VertexP3ui); 190 SET_VertexP3uiv(tab, vfmt->VertexP3uiv); 191 SET_VertexP4ui(tab, vfmt->VertexP4ui); 192 SET_VertexP4uiv(tab, vfmt->VertexP4uiv); 193 194 SET_TexCoordP1ui(tab, vfmt->TexCoordP1ui); 195 SET_TexCoordP1uiv(tab, vfmt->TexCoordP1uiv); 196 SET_TexCoordP2ui(tab, vfmt->TexCoordP2ui); 197 SET_TexCoordP2uiv(tab, vfmt->TexCoordP2uiv); 198 SET_TexCoordP3ui(tab, vfmt->TexCoordP3ui); 199 SET_TexCoordP3uiv(tab, vfmt->TexCoordP3uiv); 200 SET_TexCoordP4ui(tab, vfmt->TexCoordP4ui); 201 SET_TexCoordP4uiv(tab, vfmt->TexCoordP4uiv); 202 203 SET_MultiTexCoordP1ui(tab, vfmt->MultiTexCoordP1ui); 204 SET_MultiTexCoordP2ui(tab, vfmt->MultiTexCoordP2ui); 205 SET_MultiTexCoordP3ui(tab, vfmt->MultiTexCoordP3ui); 206 SET_MultiTexCoordP4ui(tab, vfmt->MultiTexCoordP4ui); 207 SET_MultiTexCoordP1uiv(tab, vfmt->MultiTexCoordP1uiv); 208 SET_MultiTexCoordP2uiv(tab, vfmt->MultiTexCoordP2uiv); 209 SET_MultiTexCoordP3uiv(tab, vfmt->MultiTexCoordP3uiv); 210 SET_MultiTexCoordP4uiv(tab, vfmt->MultiTexCoordP4uiv); 211 212 SET_NormalP3ui(tab, vfmt->NormalP3ui); 213 SET_NormalP3uiv(tab, vfmt->NormalP3uiv); 214 215 SET_ColorP3ui(tab, vfmt->ColorP3ui); 216 SET_ColorP4ui(tab, vfmt->ColorP4ui); 217 SET_ColorP3uiv(tab, vfmt->ColorP3uiv); 218 SET_ColorP4uiv(tab, vfmt->ColorP4uiv); 219 220 SET_SecondaryColorP3ui(tab, vfmt->SecondaryColorP3ui); 221 SET_SecondaryColorP3uiv(tab, vfmt->SecondaryColorP3uiv); 222 } 223 224 if (ctx->API != API_OPENGLES2) { 225 SET_VertexAttribP1ui(tab, vfmt->VertexAttribP1ui); 226 SET_VertexAttribP2ui(tab, vfmt->VertexAttribP2ui); 227 SET_VertexAttribP3ui(tab, vfmt->VertexAttribP3ui); 228 SET_VertexAttribP4ui(tab, vfmt->VertexAttribP4ui); 229 230 SET_VertexAttribP1uiv(tab, vfmt->VertexAttribP1uiv); 231 SET_VertexAttribP2uiv(tab, vfmt->VertexAttribP2uiv); 232 SET_VertexAttribP3uiv(tab, vfmt->VertexAttribP3uiv); 233 SET_VertexAttribP4uiv(tab, vfmt->VertexAttribP4uiv); 234 } 235} 236 237 238/** 239 * Install per-vertex functions into the API dispatch table for execution. 240 */ 241void 242_mesa_install_exec_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt) 243{ 244 install_vtxfmt( ctx, ctx->Exec, vfmt ); 245} 246 247 248/** 249 * Install per-vertex functions into the API dispatch table for display 250 * list compilation. 251 */ 252void 253_mesa_install_save_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt) 254{ 255 if (_mesa_is_desktop_gl(ctx)) 256 install_vtxfmt( ctx, ctx->Save, vfmt ); 257} 258 259 260#endif /* FEATURE_beginend */ 261