vbo_context.c revision 4992806ae54d7d1db86eed9c6524aa05f4a2fbd6
1e5f5895bda30f374b0b51412fd4d837fa59aed66Alexey Samsonov/* 21e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * Mesa 3-D graphics library 31e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * Version: 6.3 41e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * 51e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. 61e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * 71e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * Permission is hereby granted, free of charge, to any person obtaining a 81e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * copy of this software and associated documentation files (the "Software"), 91e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * to deal in the Software without restriction, including without limitation 101e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * the rights to use, copy, modify, merge, publish, distribute, sublicense, 111e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * and/or sell copies of the Software, and to permit persons to whom the 12d47189c1b63a4de755d7ec071f8d56c8d01cc667Kostya Serebryany * Software is furnished to do so, subject to the following conditions: 131e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * 141e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * The above copyright notice and this permission notice shall be included 151e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * in all copies or substantial portions of the Software. 161e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * 1705bf9a51dfeac0f84f6dbc2dacf987249c0fc612Alexander Potapenko * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 181e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 191e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 207e8434940a1fe7dce531d4c458ccd714da48f609Alexey Samsonov * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 21487fee7f6f7497906a00d7d2fe2c75e6d5d4feb1Alexey Samsonov * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 221e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 231e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany * 245b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov * Authors: 25c0d78c1de1f2607c874020d27b72cf989c5ce092Alexey Samsonov * Keith Whitwell <keith@tungstengraphics.com> 26c0d78c1de1f2607c874020d27b72cf989c5ce092Alexey Samsonov */ 271e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany 281e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany#include "main/imports.h" 29a84805f1ccb2b7d4b6c0ba384bd3541fa4eaf808Kostya Serebryany#include "main/mtypes.h" 30a84805f1ccb2b7d4b6c0ba384bd3541fa4eaf808Kostya Serebryany#include "main/api_arrayelt.h" 31a84805f1ccb2b7d4b6c0ba384bd3541fa4eaf808Kostya Serebryany#include "vbo.h" 32a84805f1ccb2b7d4b6c0ba384bd3541fa4eaf808Kostya Serebryany#include "vbo_context.h" 33a84805f1ccb2b7d4b6c0ba384bd3541fa4eaf808Kostya Serebryany 34a84805f1ccb2b7d4b6c0ba384bd3541fa4eaf808Kostya Serebryany#if 0 35a84805f1ccb2b7d4b6c0ba384bd3541fa4eaf808Kostya Serebryany/* Reach out and grab this to use as the default: 36a84805f1ccb2b7d4b6c0ba384bd3541fa4eaf808Kostya Serebryany */ 37a84805f1ccb2b7d4b6c0ba384bd3541fa4eaf808Kostya Serebryanyextern void _tnl_draw_prims( GLcontext *ctx, 38a84805f1ccb2b7d4b6c0ba384bd3541fa4eaf808Kostya Serebryany const struct gl_client_array *arrays[], 391e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany const struct _mesa_prim *prims, 401e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany GLuint nr_prims, 411e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany const struct _mesa_index_buffer *ib, 421e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany GLuint min_index, 43eb2809311c94b73c269ccef8d68ae368642e5754Kostya Serebryany GLuint max_index ); 44589dcdaa520de1033a0f6112c9b67ab9eb7931afEvgeniy Stepanov#endif 45589dcdaa520de1033a0f6112c9b67ab9eb7931afEvgeniy Stepanov 46589dcdaa520de1033a0f6112c9b67ab9eb7931afEvgeniy Stepanov 471b057b20db71ec6cc2bac460c8b2848f0889d47dKostya Serebryany 48a84805f1ccb2b7d4b6c0ba384bd3541fa4eaf808Kostya Serebryany#define NR_LEGACY_ATTRIBS 16 491b057b20db71ec6cc2bac460c8b2848f0889d47dKostya Serebryany#define NR_GENERIC_ATTRIBS 16 50589dcdaa520de1033a0f6112c9b67ab9eb7931afEvgeniy Stepanov#define NR_MAT_ATTRIBS 12 511b057b20db71ec6cc2bac460c8b2848f0889d47dKostya Serebryany 52589dcdaa520de1033a0f6112c9b67ab9eb7931afEvgeniy Stepanovstatic GLuint check_size( const GLfloat *attr ) 53589dcdaa520de1033a0f6112c9b67ab9eb7931afEvgeniy Stepanov{ 541e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany if (attr[3] != 1.0) return 4; 55eb2809311c94b73c269ccef8d68ae368642e5754Kostya Serebryany if (attr[2] != 0.0) return 3; 56341b9e63f63a8eacf1b699d4c79edee55241ebe6Evgeniy Stepanov if (attr[1] != 0.0) return 2; 571e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany return 1; 581e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany} 591e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany 601e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryanystatic void init_legacy_currval(GLcontext *ctx) 613f4c3875c42078e22c7e5356c5746fd18756d958Kostya Serebryany{ 623f4c3875c42078e22c7e5356c5746fd18756d958Kostya Serebryany struct vbo_context *vbo = vbo_context(ctx); 630985ca240812ac5519168a6aecbccf4c513ae243Kostya Serebryany struct gl_client_array *arrays = vbo->legacy_currval; 641e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany GLuint i; 65c5e72a3b7c60f1b2d9d9be3a07d397d5b5f872beKostya Serebryany 661e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany memset(arrays, 0, sizeof(*arrays) * NR_LEGACY_ATTRIBS); 671e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany 680985ca240812ac5519168a6aecbccf4c513ae243Kostya Serebryany /* Set up a constant (StrideB == 0) array for each current 69a30c8f9eac981dcf137e84226810b760e35c7be1Kostya Serebryany * attribute: 70487fee7f6f7497906a00d7d2fe2c75e6d5d4feb1Alexey Samsonov */ 71487fee7f6f7497906a00d7d2fe2c75e6d5d4feb1Alexey Samsonov for (i = 0; i < NR_LEGACY_ATTRIBS; i++) { 721e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany struct gl_client_array *cl = &arrays[i]; 73e130191a254064bfd1c8d373afdacf6d52979713Kostya Serebryany 741e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany /* Size will have to be determined at runtime: 75e130191a254064bfd1c8d373afdacf6d52979713Kostya Serebryany */ 76e130191a254064bfd1c8d373afdacf6d52979713Kostya Serebryany cl->Size = check_size(ctx->Current.Attrib[i]); 77e130191a254064bfd1c8d373afdacf6d52979713Kostya Serebryany cl->Stride = 0; 78e130191a254064bfd1c8d373afdacf6d52979713Kostya Serebryany cl->StrideB = 0; 79e130191a254064bfd1c8d373afdacf6d52979713Kostya Serebryany cl->Enabled = 1; 80e130191a254064bfd1c8d373afdacf6d52979713Kostya Serebryany cl->Type = GL_FLOAT; 811e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany cl->Ptr = (const void *)ctx->Current.Attrib[i]; 82c925697df6626bb0ea27ea96539bf0580f8f3d3dAlexey Samsonov cl->BufferObj = ctx->Array.NullBufferObj; 8381a7a4ab53c94e76c3b131d6f0ed82894640900bAlexey Samsonov } 843f4c3875c42078e22c7e5356c5746fd18756d958Kostya Serebryany} 8509672caefb5694f1981a1712fdefa44840a95e67Alexey Samsonov 861e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany 87f2598fc21bf651d23feab396a7581d48c01c3be5Alexey Samsonovstatic void init_generic_currval(GLcontext *ctx) 88c925697df6626bb0ea27ea96539bf0580f8f3d3dAlexey Samsonov{ 89a4ccf878e464d29a4a18756c5c4f626dc530a12eKostya Serebryany struct vbo_context *vbo = vbo_context(ctx); 901e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany struct gl_client_array *arrays = vbo->generic_currval; 91c20b321d49f0eff60f1394d56e623d8ca94f24d7Kostya Serebryany GLuint i; 9289c1384464848c1ad041becf8b97936fa10de21bAlexey Samsonov 93c20b321d49f0eff60f1394d56e623d8ca94f24d7Kostya Serebryany memset(arrays, 0, sizeof(*arrays) * NR_GENERIC_ATTRIBS); 94def1be9b7ef4091ce465c0fbfb26cdb52128ade8Alexey Samsonov 95c20b321d49f0eff60f1394d56e623d8ca94f24d7Kostya Serebryany for (i = 0; i < NR_GENERIC_ATTRIBS; i++) { 96c20b321d49f0eff60f1394d56e623d8ca94f24d7Kostya Serebryany struct gl_client_array *cl = &arrays[i]; 971e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany 981e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany /* This will have to be determined at runtime: 991e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany */ 1001e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany cl->Size = 1; 1011e172b4bdec57329bf904f063a29f99cddf2d85fKostya Serebryany cl->Type = GL_FLOAT; 10212eb79dd701d9d40551759330a9257316601373bEvgeniy Stepanov cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i]; 10312eb79dd701d9d40551759330a9257316601373bEvgeniy Stepanov cl->Stride = 0; 10412eb79dd701d9d40551759330a9257316601373bEvgeniy Stepanov cl->StrideB = 0; 1053fa122e6a8e12db6583793861f6cf776fe1c98a0Evgeniy Stepanov cl->Enabled = 1; 1063fa122e6a8e12db6583793861f6cf776fe1c98a0Evgeniy Stepanov cl->BufferObj = ctx->Array.NullBufferObj; 1073fa122e6a8e12db6583793861f6cf776fe1c98a0Evgeniy Stepanov } 10882a9080eaff95d69b270cd863e9df63e3b4e59adEvgeniy Stepanov} 10982a9080eaff95d69b270cd863e9df63e3b4e59adEvgeniy Stepanov 110996c4f2fa53cce8f9d7b517073f38569460de505Evgeniy Stepanov 1119d1525ec52430d0b8ffd6d0893b7f5529105b321Evgeniy Stepanovstatic void init_mat_currval(GLcontext *ctx) 1129d1525ec52430d0b8ffd6d0893b7f5529105b321Evgeniy Stepanov{ 1139d1525ec52430d0b8ffd6d0893b7f5529105b321Evgeniy Stepanov struct vbo_context *vbo = vbo_context(ctx); 1149d1525ec52430d0b8ffd6d0893b7f5529105b321Evgeniy Stepanov struct gl_client_array *arrays = vbo->mat_currval; 1159d1525ec52430d0b8ffd6d0893b7f5529105b321Evgeniy Stepanov GLuint i; 1169d1525ec52430d0b8ffd6d0893b7f5529105b321Evgeniy Stepanov 1179d1525ec52430d0b8ffd6d0893b7f5529105b321Evgeniy Stepanov memset(arrays, 0, sizeof(*arrays) * NR_MAT_ATTRIBS); 1189d1525ec52430d0b8ffd6d0893b7f5529105b321Evgeniy Stepanov 1199d1525ec52430d0b8ffd6d0893b7f5529105b321Evgeniy Stepanov /* Set up a constant (StrideB == 0) array for each current 1209d1525ec52430d0b8ffd6d0893b7f5529105b321Evgeniy Stepanov * attribute: 1219d1525ec52430d0b8ffd6d0893b7f5529105b321Evgeniy Stepanov */ 1229d1525ec52430d0b8ffd6d0893b7f5529105b321Evgeniy Stepanov for (i = 0; i < NR_MAT_ATTRIBS; i++) { 1239d1525ec52430d0b8ffd6d0893b7f5529105b321Evgeniy Stepanov struct gl_client_array *cl = &arrays[i]; 1249d1525ec52430d0b8ffd6d0893b7f5529105b321Evgeniy Stepanov 1259d1525ec52430d0b8ffd6d0893b7f5529105b321Evgeniy Stepanov /* Size is fixed for the material attributes, for others will 12682a9080eaff95d69b270cd863e9df63e3b4e59adEvgeniy Stepanov * be determined at runtime: 127996c4f2fa53cce8f9d7b517073f38569460de505Evgeniy Stepanov */ 1284f32c0beaa83ffbb84db23d2e6205bee57c39ce1Evgeniy Stepanov switch (i - VERT_ATTRIB_GENERIC0) { 1298530e2b953f0b34ecd267a6aba5f155d5c08c5c8Kostya Serebryany case MAT_ATTRIB_FRONT_SHININESS: 130881b677c189e65872fd315a75a0e56f077339189Evgeniy Stepanov case MAT_ATTRIB_BACK_SHININESS: 131881b677c189e65872fd315a75a0e56f077339189Evgeniy Stepanov cl->Size = 1; 132ae4e6fd0300b13812a02a779619b1a451478cdd1Evgeniy Stepanov break; 133ae4e6fd0300b13812a02a779619b1a451478cdd1Evgeniy Stepanov case MAT_ATTRIB_FRONT_INDEXES: 134ae4e6fd0300b13812a02a779619b1a451478cdd1Evgeniy Stepanov case MAT_ATTRIB_BACK_INDEXES: 135ae4e6fd0300b13812a02a779619b1a451478cdd1Evgeniy Stepanov cl->Size = 3; 136ae4e6fd0300b13812a02a779619b1a451478cdd1Evgeniy Stepanov break; 137ae4e6fd0300b13812a02a779619b1a451478cdd1Evgeniy Stepanov default: 138881b677c189e65872fd315a75a0e56f077339189Evgeniy Stepanov cl->Size = 4; 139881b677c189e65872fd315a75a0e56f077339189Evgeniy Stepanov break; 140600972e3427173cc8904d741decd1af0ed5de9fdTimur Iskhodzhanov } 1414803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany 14289c1384464848c1ad041becf8b97936fa10de21bAlexey Samsonov if (i < MAT_ATTRIB_MAX) 143def1be9b7ef4091ce465c0fbfb26cdb52128ade8Alexey Samsonov cl->Ptr = (const void *)ctx->Light.Material.Attrib[i]; 1444803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany else 1454803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i]; 146fd2ae4fc7df0e5acd200f30d87bbc6b96830a989Alexey Samsonov 147def1be9b7ef4091ce465c0fbfb26cdb52128ade8Alexey Samsonov cl->Type = GL_FLOAT; 148def1be9b7ef4091ce465c0fbfb26cdb52128ade8Alexey Samsonov cl->Stride = 0; 149b8ef925563f8dde5be837c4b0569082867c5f14cEvgeniy Stepanov cl->StrideB = 0; 150b8ef925563f8dde5be837c4b0569082867c5f14cEvgeniy Stepanov cl->Enabled = 1; 151c6ac98d7fcc81768b2ef7ddc785c27e3fc1bdef6Sergey Matveev cl->BufferObj = ctx->Array.NullBufferObj; 152bdd0966deb04068ea94cf416c7fb46516013bd26Alexey Samsonov } 1539465cbdbe73590746b57916f46ea1aa4bf3dd13dAlexey Samsonov} 1549465cbdbe73590746b57916f46ea1aa4bf3dd13dAlexey Samsonov 155a30c8f9eac981dcf137e84226810b760e35c7be1Kostya Serebryany#if 0 156def1be9b7ef4091ce465c0fbfb26cdb52128ade8Alexey Samsonov 157def1be9b7ef4091ce465c0fbfb26cdb52128ade8Alexey Samsonovstatic void vbo_exec_current_init( struct vbo_exec_context *exec ) 158def1be9b7ef4091ce465c0fbfb26cdb52128ade8Alexey Samsonov{ 159def1be9b7ef4091ce465c0fbfb26cdb52128ade8Alexey Samsonov GLcontext *ctx = exec->ctx; 16089c1384464848c1ad041becf8b97936fa10de21bAlexey Samsonov GLint i; 161def1be9b7ef4091ce465c0fbfb26cdb52128ade8Alexey Samsonov 162def1be9b7ef4091ce465c0fbfb26cdb52128ade8Alexey Samsonov /* setup the pointers for the typical 16 vertex attributes */ 163def1be9b7ef4091ce465c0fbfb26cdb52128ade8Alexey Samsonov for (i = 0; i < VBO_ATTRIB_FIRST_MATERIAL; i++) 16409672caefb5694f1981a1712fdefa44840a95e67Alexey Samsonov exec->vtx.current[i] = ctx->Current.Attrib[i]; 1654803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany 166fd2ae4fc7df0e5acd200f30d87bbc6b96830a989Alexey Samsonov /* setup pointers for the 12 material attributes */ 1674803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany for (i = 0; i < MAT_ATTRIB_MAX; i++) 16834a3202a2c22816a6da66959e266a2d078ded37bAlexey Samsonov exec->vtx.current[VBO_ATTRIB_FIRST_MATERIAL + i] = 169f2598fc21bf651d23feab396a7581d48c01c3be5Alexey Samsonov ctx->Light.Material.Attrib[i]; 170332bf3340435a85d39d6abefbf4d6a145e17da1cAlexey Samsonov} 171034bda5eab7cda14fac0bed3a39de4a3dbce3cffAlexander Potapenko#endif 1724803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany 1733f4c3875c42078e22c7e5356c5746fd18756d958Kostya SerebryanyGLboolean _vbo_CreateContext( GLcontext *ctx ) 1744803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany{ 1754803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany struct vbo_context *vbo = CALLOC_STRUCT(vbo_context); 176da13ba833b046553f50b54538e4828287ddbf5c0Alexey Samsonov 177da13ba833b046553f50b54538e4828287ddbf5c0Alexey Samsonov ctx->swtnl_im = (void *)vbo; 178332bf3340435a85d39d6abefbf4d6a145e17da1cAlexey Samsonov 179034bda5eab7cda14fac0bed3a39de4a3dbce3cffAlexander Potapenko /* Initialize the arrayelt helper 1804803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany */ 181034bda5eab7cda14fac0bed3a39de4a3dbce3cffAlexander Potapenko if (!ctx->aelt_context && 1824803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany !_ae_create_context( ctx )) { 183e1ba0009d5be18d513ffd29c1b6fccea1a3bffa0Evgeniy Stepanov return GL_FALSE; 18434a3202a2c22816a6da66959e266a2d078ded37bAlexey Samsonov } 18534a3202a2c22816a6da66959e266a2d078ded37bAlexey Samsonov 186fdde5a97a71b142297d7b2270c2a7f564a37dbaeAlexey Samsonov /* TODO: remove these pointers. 18734a3202a2c22816a6da66959e266a2d078ded37bAlexey Samsonov */ 1884803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany vbo->legacy_currval = &vbo->currval[VBO_ATTRIB_POS]; 1890870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov vbo->generic_currval = &vbo->currval[VBO_ATTRIB_GENERIC0]; 19057db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov vbo->mat_currval = &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT]; 19157db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov 19257db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov init_legacy_currval( ctx ); 19357db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov init_generic_currval( ctx ); 19457db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov init_mat_currval( ctx ); 19557db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov 19657db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov /* Build mappings from VERT_ATTRIB -> VBO_ATTRIB depending on type 197541cfb10f5daa17e48eb42365a74233cd551c545Kostya Serebryany * of vertex program active. 19857db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov */ 19957db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov { 20057db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov GLuint i; 20157db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov 2020870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov /* When no vertex program, pull in the material attributes in 2030870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov * the 16..32 generic range. 2040870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov */ 2050870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov for (i = 0; i < 16; i++) 2060870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov vbo->map_vp_none[i] = i; 2070870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov for (i = 0; i < 12; i++) 2080870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov vbo->map_vp_none[16+i] = VBO_ATTRIB_MAT_FRONT_AMBIENT + i; 2090870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov for (i = 0; i < 4; i++) 2100870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov vbo->map_vp_none[28+i] = i; 2110870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov 21257db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov for (i = 0; i < VERT_ATTRIB_MAX; i++) 21357db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov vbo->map_vp_arb[i] = i; 21457db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov } 2150870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov 2160870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov 2170870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov /* By default: 2180870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov */ 2190870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov#if 0 /* dead - see vbo_set_draw_func() */ 22057db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov vbo->draw_prims = _tnl_draw_prims; 2210870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov#endif 2220870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov 22357db4bae483e7268dd7fc5bc42b0e55564014048Alexey Samsonov /* Hook our functions into exec and compile dispatch tables. These 2240870028410087e67a0049c76cb7c64f02c260d24Alexey Samsonov * will pretty much be permanently installed, which means that the 225f2598fc21bf651d23feab396a7581d48c01c3be5Alexey Samsonov * vtxfmt mechanism can be removed now. 226f54b1f9b73a6855d77ee270c282bd61407fa73a0Kostya Serebryany */ 22709672caefb5694f1981a1712fdefa44840a95e67Alexey Samsonov vbo_exec_init( ctx ); 2284803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany#if FEATURE_dlist 2294803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany vbo_save_init( ctx ); 230fd2ae4fc7df0e5acd200f30d87bbc6b96830a989Alexey Samsonov#endif 231f2598fc21bf651d23feab396a7581d48c01c3be5Alexey Samsonov 232f54b1f9b73a6855d77ee270c282bd61407fa73a0Kostya Serebryany return GL_TRUE; 23309672caefb5694f1981a1712fdefa44840a95e67Alexey Samsonov} 2344803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany 235fd2ae4fc7df0e5acd200f30d87bbc6b96830a989Alexey Samsonovvoid _vbo_InvalidateState( GLcontext *ctx, GLuint new_state ) 2364803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany{ 237fd2ae4fc7df0e5acd200f30d87bbc6b96830a989Alexey Samsonov _ae_invalidate_state(ctx, new_state); 238f2598fc21bf651d23feab396a7581d48c01c3be5Alexey Samsonov vbo_exec_invalidate_state(ctx, new_state); 239f54b1f9b73a6855d77ee270c282bd61407fa73a0Kostya Serebryany} 24009672caefb5694f1981a1712fdefa44840a95e67Alexey Samsonov 2414803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany 24207bb9f1e3600195119aec1aae1aa48a6ed2f5febTimur Iskhodzhanovvoid _vbo_DestroyContext( GLcontext *ctx ) 2434803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany{ 244fd2ae4fc7df0e5acd200f30d87bbc6b96830a989Alexey Samsonov if (ctx->aelt_context) { 245f2598fc21bf651d23feab396a7581d48c01c3be5Alexey Samsonov _ae_destroy_context( ctx ); 24609672caefb5694f1981a1712fdefa44840a95e67Alexey Samsonov ctx->aelt_context = NULL; 247f54b1f9b73a6855d77ee270c282bd61407fa73a0Kostya Serebryany } 24809672caefb5694f1981a1712fdefa44840a95e67Alexey Samsonov 2494803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany if (vbo_context(ctx)) { 2504803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany vbo_exec_destroy(ctx); 2514803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany#if FEATURE_dlist 2524803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany vbo_save_destroy(ctx); 2534803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany#endif 2544803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany FREE(vbo_context(ctx)); 2554803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany ctx->swtnl_im = NULL; 2568d2438a7ebb01201c652f91d1e8043a1f3d03bffTimur Iskhodzhanov } 2574803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany} 2584803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany 259eaca82cf249021afa31dbc970278f2f28ea2a1aaTimur Iskhodzhanov 260eaca82cf249021afa31dbc970278f2f28ea2a1aaTimur Iskhodzhanovvoid vbo_set_draw_func(GLcontext *ctx, vbo_draw_func func) 261eaca82cf249021afa31dbc970278f2f28ea2a1aaTimur Iskhodzhanov{ 262eaca82cf249021afa31dbc970278f2f28ea2a1aaTimur Iskhodzhanov struct vbo_context *vbo = vbo_context(ctx); 2634803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany vbo->draw_prims = func; 2643389b8ea81f51a28365a421b2646d594bac490f5Alexey Samsonov} 26500f1c091441be5c2cacb99e21bd1965a5e418242Alexander Potapenko 2664803ab90ead451b55a5833f0fd38b10fd1fc83ebKostya Serebryany