1848b8605Smrg/* 2848b8605Smrg * Mesa 3-D graphics library 3848b8605Smrg * 4848b8605Smrg * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. 5848b8605Smrg * 6848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a 7848b8605Smrg * copy of this software and associated documentation files (the "Software"), 8848b8605Smrg * to deal in the Software without restriction, including without limitation 9848b8605Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10848b8605Smrg * and/or sell copies of the Software, and to permit persons to whom the 11848b8605Smrg * Software is furnished to do so, subject to the following conditions: 12848b8605Smrg * 13848b8605Smrg * The above copyright notice and this permission notice shall be included 14848b8605Smrg * in all copies or substantial portions of the Software. 15848b8605Smrg * 16848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18848b8605Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19848b8605Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20848b8605Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21848b8605Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22848b8605Smrg * OTHER DEALINGS IN THE SOFTWARE. 23848b8605Smrg * 24848b8605Smrg * Authors: 25848b8605Smrg * Keith Whitwell <keithw@vmware.com> Gareth Hughes 26848b8605Smrg */ 27848b8605Smrg 28848b8605Smrg#include "glheader.h" 29848b8605Smrg#include "api_arrayelt.h" 30848b8605Smrg#include "context.h" 31848b8605Smrg#include "imports.h" 32848b8605Smrg#include "mtypes.h" 33848b8605Smrg#include "vtxfmt.h" 34848b8605Smrg#include "eval.h" 35848b8605Smrg#include "dlist.h" 36848b8605Smrg#include "main/dispatch.h" 37b8e80941Smrg#include "vbo/vbo.h" 38848b8605Smrg 39848b8605Smrg 40848b8605Smrg/** 41848b8605Smrg * Copy the functions found in the GLvertexformat object into the 42848b8605Smrg * dispatch table. 43848b8605Smrg */ 44848b8605Smrgstatic void 45848b8605Smrginstall_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab, 46848b8605Smrg const GLvertexformat *vfmt) 47848b8605Smrg{ 48848b8605Smrg assert(ctx->Version > 0); 49848b8605Smrg 50848b8605Smrg if (ctx->API != API_OPENGL_CORE && ctx->API != API_OPENGLES2) { 51848b8605Smrg SET_Color4f(tab, vfmt->Color4f); 52848b8605Smrg } 53848b8605Smrg 54848b8605Smrg if (ctx->API == API_OPENGL_COMPAT) { 55848b8605Smrg _mesa_install_arrayelt_vtxfmt(tab, vfmt); 56848b8605Smrg SET_Color3f(tab, vfmt->Color3f); 57848b8605Smrg SET_Color3fv(tab, vfmt->Color3fv); 58848b8605Smrg SET_Color4fv(tab, vfmt->Color4fv); 59848b8605Smrg SET_EdgeFlag(tab, vfmt->EdgeFlag); 60848b8605Smrg } 61848b8605Smrg 62848b8605Smrg if (ctx->API == API_OPENGL_COMPAT) { 63848b8605Smrg _mesa_install_eval_vtxfmt(tab, vfmt); 64848b8605Smrg } 65848b8605Smrg 66848b8605Smrg if (ctx->API != API_OPENGL_CORE && ctx->API != API_OPENGLES2) { 67848b8605Smrg SET_Materialfv(tab, vfmt->Materialfv); 68848b8605Smrg SET_MultiTexCoord4fARB(tab, vfmt->MultiTexCoord4fARB); 69848b8605Smrg SET_Normal3f(tab, vfmt->Normal3f); 70848b8605Smrg } 71848b8605Smrg 72848b8605Smrg if (ctx->API == API_OPENGL_COMPAT) { 73848b8605Smrg SET_FogCoordfEXT(tab, vfmt->FogCoordfEXT); 74848b8605Smrg SET_FogCoordfvEXT(tab, vfmt->FogCoordfvEXT); 75848b8605Smrg SET_Indexf(tab, vfmt->Indexf); 76848b8605Smrg SET_Indexfv(tab, vfmt->Indexfv); 77848b8605Smrg SET_MultiTexCoord1fARB(tab, vfmt->MultiTexCoord1fARB); 78848b8605Smrg SET_MultiTexCoord1fvARB(tab, vfmt->MultiTexCoord1fvARB); 79848b8605Smrg SET_MultiTexCoord2fARB(tab, vfmt->MultiTexCoord2fARB); 80848b8605Smrg SET_MultiTexCoord2fvARB(tab, vfmt->MultiTexCoord2fvARB); 81848b8605Smrg SET_MultiTexCoord3fARB(tab, vfmt->MultiTexCoord3fARB); 82848b8605Smrg SET_MultiTexCoord3fvARB(tab, vfmt->MultiTexCoord3fvARB); 83848b8605Smrg SET_MultiTexCoord4fvARB(tab, vfmt->MultiTexCoord4fvARB); 84848b8605Smrg SET_Normal3fv(tab, vfmt->Normal3fv); 85848b8605Smrg } 86848b8605Smrg 87848b8605Smrg if (ctx->API == API_OPENGL_COMPAT) { 88848b8605Smrg SET_SecondaryColor3fEXT(tab, vfmt->SecondaryColor3fEXT); 89848b8605Smrg SET_SecondaryColor3fvEXT(tab, vfmt->SecondaryColor3fvEXT); 90848b8605Smrg SET_TexCoord1f(tab, vfmt->TexCoord1f); 91848b8605Smrg SET_TexCoord1fv(tab, vfmt->TexCoord1fv); 92848b8605Smrg SET_TexCoord2f(tab, vfmt->TexCoord2f); 93848b8605Smrg SET_TexCoord2fv(tab, vfmt->TexCoord2fv); 94848b8605Smrg SET_TexCoord3f(tab, vfmt->TexCoord3f); 95848b8605Smrg SET_TexCoord3fv(tab, vfmt->TexCoord3fv); 96848b8605Smrg SET_TexCoord4f(tab, vfmt->TexCoord4f); 97848b8605Smrg SET_TexCoord4fv(tab, vfmt->TexCoord4fv); 98848b8605Smrg SET_Vertex2f(tab, vfmt->Vertex2f); 99848b8605Smrg SET_Vertex2fv(tab, vfmt->Vertex2fv); 100848b8605Smrg SET_Vertex3f(tab, vfmt->Vertex3f); 101848b8605Smrg SET_Vertex3fv(tab, vfmt->Vertex3fv); 102848b8605Smrg SET_Vertex4f(tab, vfmt->Vertex4f); 103848b8605Smrg SET_Vertex4fv(tab, vfmt->Vertex4fv); 104848b8605Smrg } 105848b8605Smrg 106848b8605Smrg if (ctx->API == API_OPENGL_COMPAT) { 107848b8605Smrg _mesa_install_dlist_vtxfmt(tab, vfmt); /* glCallList / glCallLists */ 108848b8605Smrg 109848b8605Smrg SET_Begin(tab, vfmt->Begin); 110848b8605Smrg SET_End(tab, vfmt->End); 111848b8605Smrg SET_PrimitiveRestartNV(tab, vfmt->PrimitiveRestartNV); 112848b8605Smrg } 113848b8605Smrg 114848b8605Smrg /* Originally for GL_NV_vertex_program, this is also used by dlist.c */ 115848b8605Smrg if (ctx->API == API_OPENGL_COMPAT) { 116848b8605Smrg SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV); 117848b8605Smrg SET_VertexAttrib1fvNV(tab, vfmt->VertexAttrib1fvNV); 118848b8605Smrg SET_VertexAttrib2fNV(tab, vfmt->VertexAttrib2fNV); 119848b8605Smrg SET_VertexAttrib2fvNV(tab, vfmt->VertexAttrib2fvNV); 120848b8605Smrg SET_VertexAttrib3fNV(tab, vfmt->VertexAttrib3fNV); 121848b8605Smrg SET_VertexAttrib3fvNV(tab, vfmt->VertexAttrib3fvNV); 122848b8605Smrg SET_VertexAttrib4fNV(tab, vfmt->VertexAttrib4fNV); 123848b8605Smrg SET_VertexAttrib4fvNV(tab, vfmt->VertexAttrib4fvNV); 124848b8605Smrg } 125848b8605Smrg 126848b8605Smrg if (ctx->API != API_OPENGLES) { 127848b8605Smrg SET_VertexAttrib1fARB(tab, vfmt->VertexAttrib1fARB); 128848b8605Smrg SET_VertexAttrib1fvARB(tab, vfmt->VertexAttrib1fvARB); 129848b8605Smrg SET_VertexAttrib2fARB(tab, vfmt->VertexAttrib2fARB); 130848b8605Smrg SET_VertexAttrib2fvARB(tab, vfmt->VertexAttrib2fvARB); 131848b8605Smrg SET_VertexAttrib3fARB(tab, vfmt->VertexAttrib3fARB); 132848b8605Smrg SET_VertexAttrib3fvARB(tab, vfmt->VertexAttrib3fvARB); 133848b8605Smrg SET_VertexAttrib4fARB(tab, vfmt->VertexAttrib4fARB); 134848b8605Smrg SET_VertexAttrib4fvARB(tab, vfmt->VertexAttrib4fvARB); 135848b8605Smrg } 136848b8605Smrg 137848b8605Smrg /* GL_EXT_gpu_shader4 / OpenGL 3.0 */ 138848b8605Smrg if (_mesa_is_desktop_gl(ctx)) { 139848b8605Smrg SET_VertexAttribI1iEXT(tab, vfmt->VertexAttribI1i); 140848b8605Smrg SET_VertexAttribI2iEXT(tab, vfmt->VertexAttribI2i); 141848b8605Smrg SET_VertexAttribI3iEXT(tab, vfmt->VertexAttribI3i); 142848b8605Smrg SET_VertexAttribI2ivEXT(tab, vfmt->VertexAttribI2iv); 143848b8605Smrg SET_VertexAttribI3ivEXT(tab, vfmt->VertexAttribI3iv); 144848b8605Smrg 145848b8605Smrg SET_VertexAttribI1uiEXT(tab, vfmt->VertexAttribI1ui); 146848b8605Smrg SET_VertexAttribI2uiEXT(tab, vfmt->VertexAttribI2ui); 147848b8605Smrg SET_VertexAttribI3uiEXT(tab, vfmt->VertexAttribI3ui); 148848b8605Smrg SET_VertexAttribI2uivEXT(tab, vfmt->VertexAttribI2uiv); 149848b8605Smrg SET_VertexAttribI3uivEXT(tab, vfmt->VertexAttribI3uiv); 150848b8605Smrg } 151848b8605Smrg 152848b8605Smrg if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) { 153848b8605Smrg SET_VertexAttribI4iEXT(tab, vfmt->VertexAttribI4i); 154848b8605Smrg SET_VertexAttribI4ivEXT(tab, vfmt->VertexAttribI4iv); 155848b8605Smrg SET_VertexAttribI4uiEXT(tab, vfmt->VertexAttribI4ui); 156848b8605Smrg SET_VertexAttribI4uivEXT(tab, vfmt->VertexAttribI4uiv); 157848b8605Smrg } 158848b8605Smrg 159848b8605Smrg if (ctx->API == API_OPENGL_COMPAT) { 160848b8605Smrg /* GL_ARB_vertex_type_10_10_10_2_rev / GL 3.3 */ 161848b8605Smrg SET_VertexP2ui(tab, vfmt->VertexP2ui); 162848b8605Smrg SET_VertexP2uiv(tab, vfmt->VertexP2uiv); 163848b8605Smrg SET_VertexP3ui(tab, vfmt->VertexP3ui); 164848b8605Smrg SET_VertexP3uiv(tab, vfmt->VertexP3uiv); 165848b8605Smrg SET_VertexP4ui(tab, vfmt->VertexP4ui); 166848b8605Smrg SET_VertexP4uiv(tab, vfmt->VertexP4uiv); 167848b8605Smrg 168848b8605Smrg SET_TexCoordP1ui(tab, vfmt->TexCoordP1ui); 169848b8605Smrg SET_TexCoordP1uiv(tab, vfmt->TexCoordP1uiv); 170848b8605Smrg SET_TexCoordP2ui(tab, vfmt->TexCoordP2ui); 171848b8605Smrg SET_TexCoordP2uiv(tab, vfmt->TexCoordP2uiv); 172848b8605Smrg SET_TexCoordP3ui(tab, vfmt->TexCoordP3ui); 173848b8605Smrg SET_TexCoordP3uiv(tab, vfmt->TexCoordP3uiv); 174848b8605Smrg SET_TexCoordP4ui(tab, vfmt->TexCoordP4ui); 175848b8605Smrg SET_TexCoordP4uiv(tab, vfmt->TexCoordP4uiv); 176848b8605Smrg 177848b8605Smrg SET_MultiTexCoordP1ui(tab, vfmt->MultiTexCoordP1ui); 178848b8605Smrg SET_MultiTexCoordP2ui(tab, vfmt->MultiTexCoordP2ui); 179848b8605Smrg SET_MultiTexCoordP3ui(tab, vfmt->MultiTexCoordP3ui); 180848b8605Smrg SET_MultiTexCoordP4ui(tab, vfmt->MultiTexCoordP4ui); 181848b8605Smrg SET_MultiTexCoordP1uiv(tab, vfmt->MultiTexCoordP1uiv); 182848b8605Smrg SET_MultiTexCoordP2uiv(tab, vfmt->MultiTexCoordP2uiv); 183848b8605Smrg SET_MultiTexCoordP3uiv(tab, vfmt->MultiTexCoordP3uiv); 184848b8605Smrg SET_MultiTexCoordP4uiv(tab, vfmt->MultiTexCoordP4uiv); 185848b8605Smrg 186848b8605Smrg SET_NormalP3ui(tab, vfmt->NormalP3ui); 187848b8605Smrg SET_NormalP3uiv(tab, vfmt->NormalP3uiv); 188848b8605Smrg 189848b8605Smrg SET_ColorP3ui(tab, vfmt->ColorP3ui); 190848b8605Smrg SET_ColorP4ui(tab, vfmt->ColorP4ui); 191848b8605Smrg SET_ColorP3uiv(tab, vfmt->ColorP3uiv); 192848b8605Smrg SET_ColorP4uiv(tab, vfmt->ColorP4uiv); 193848b8605Smrg 194848b8605Smrg SET_SecondaryColorP3ui(tab, vfmt->SecondaryColorP3ui); 195848b8605Smrg SET_SecondaryColorP3uiv(tab, vfmt->SecondaryColorP3uiv); 196848b8605Smrg } 197848b8605Smrg 198848b8605Smrg if (_mesa_is_desktop_gl(ctx)) { 199848b8605Smrg SET_VertexAttribP1ui(tab, vfmt->VertexAttribP1ui); 200848b8605Smrg SET_VertexAttribP2ui(tab, vfmt->VertexAttribP2ui); 201848b8605Smrg SET_VertexAttribP3ui(tab, vfmt->VertexAttribP3ui); 202848b8605Smrg SET_VertexAttribP4ui(tab, vfmt->VertexAttribP4ui); 203848b8605Smrg 204848b8605Smrg SET_VertexAttribP1uiv(tab, vfmt->VertexAttribP1uiv); 205848b8605Smrg SET_VertexAttribP2uiv(tab, vfmt->VertexAttribP2uiv); 206848b8605Smrg SET_VertexAttribP3uiv(tab, vfmt->VertexAttribP3uiv); 207848b8605Smrg SET_VertexAttribP4uiv(tab, vfmt->VertexAttribP4uiv); 208b8e80941Smrg 209b8e80941Smrg /* GL_ARB_bindless_texture */ 210b8e80941Smrg SET_VertexAttribL1ui64ARB(tab, vfmt->VertexAttribL1ui64ARB); 211b8e80941Smrg SET_VertexAttribL1ui64vARB(tab, vfmt->VertexAttribL1ui64vARB); 212b8e80941Smrg } 213b8e80941Smrg 214b8e80941Smrg if (_mesa_is_desktop_gl(ctx)) { 215b8e80941Smrg /* GL_ARB_vertex_attrib_64bit */ 216b8e80941Smrg SET_VertexAttribL1d(tab, vfmt->VertexAttribL1d); 217b8e80941Smrg SET_VertexAttribL2d(tab, vfmt->VertexAttribL2d); 218b8e80941Smrg SET_VertexAttribL3d(tab, vfmt->VertexAttribL3d); 219b8e80941Smrg SET_VertexAttribL4d(tab, vfmt->VertexAttribL4d); 220b8e80941Smrg 221b8e80941Smrg SET_VertexAttribL1dv(tab, vfmt->VertexAttribL1dv); 222b8e80941Smrg SET_VertexAttribL2dv(tab, vfmt->VertexAttribL2dv); 223b8e80941Smrg SET_VertexAttribL3dv(tab, vfmt->VertexAttribL3dv); 224b8e80941Smrg SET_VertexAttribL4dv(tab, vfmt->VertexAttribL4dv); 225848b8605Smrg } 226848b8605Smrg} 227848b8605Smrg 228848b8605Smrg 229848b8605Smrg/** 230848b8605Smrg * Install per-vertex functions into the API dispatch table for execution. 231848b8605Smrg */ 232848b8605Smrgvoid 233848b8605Smrg_mesa_install_exec_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt) 234848b8605Smrg{ 235848b8605Smrg install_vtxfmt(ctx, ctx->Exec, vfmt); 236848b8605Smrg if (ctx->BeginEnd) 237848b8605Smrg install_vtxfmt(ctx, ctx->BeginEnd, vfmt); 238848b8605Smrg} 239848b8605Smrg 240848b8605Smrg 241848b8605Smrg/** 242848b8605Smrg * Install per-vertex functions into the API dispatch table for display 243848b8605Smrg * list compilation. 244848b8605Smrg */ 245848b8605Smrgvoid 246848b8605Smrg_mesa_install_save_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt) 247848b8605Smrg{ 248848b8605Smrg if (_mesa_is_desktop_gl(ctx)) 249848b8605Smrg install_vtxfmt(ctx, ctx->Save, vfmt); 250848b8605Smrg} 251848b8605Smrg 252848b8605Smrg 253848b8605Smrg/** 254848b8605Smrg * Install VBO vtxfmt functions. 255848b8605Smrg * 256848b8605Smrg * This function depends on ctx->Version. 257848b8605Smrg */ 258848b8605Smrgvoid 259848b8605Smrg_mesa_initialize_vbo_vtxfmt(struct gl_context *ctx) 260848b8605Smrg{ 261b8e80941Smrg _vbo_install_exec_vtxfmt(ctx); 262848b8605Smrg if (ctx->API == API_OPENGL_COMPAT) { 263848b8605Smrg _mesa_install_save_vtxfmt(ctx, &ctx->ListState.ListVtxfmt); 264848b8605Smrg } 265848b8605Smrg} 266848b8605Smrg 267