vbo_exec_draw.c revision 6183edc070e2d3dce36ab5ee7aee72b0c38775a7
1fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell/* 2fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * Mesa 3-D graphics library 337c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul * Version: 7.2 4fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * 537c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 6fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * 7fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 8fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * copy of this software and associated documentation files (the "Software"), 9fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * to deal in the Software without restriction, including without limitation 10fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * and/or sell copies of the Software, and to permit persons to whom the 12fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * Software is furnished to do so, subject to the following conditions: 13fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * 14fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * The above copyright notice and this permission notice shall be included 15fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * in all copies or substantial portions of the Software. 16fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * 17fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 21fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * 24fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * Authors: 25fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * Keith Whitwell <keith@tungstengraphics.com> 26fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell */ 27fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 28c223c6b663cd5db39ba19c2be74b88cc3b8f53f3Brian#include "main/glheader.h" 2937c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul#include "main/bufferobj.h" 309846b0627149e221c9fbd7c3379e33fb68e68511Vinson Lee#include "main/compiler.h" 31c223c6b663cd5db39ba19c2be74b88cc3b8f53f3Brian#include "main/enums.h" 3214b36cd568b7f3ae963430248fcd7ef0b7a165f6Vinson Lee#include "main/mfeatures.h" 33c223c6b663cd5db39ba19c2be74b88cc3b8f53f3Brian#include "main/state.h" 34fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 35fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell#include "vbo_context.h" 36fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 37fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 38cef97267d696d37f4dccb22951499ca25d5d87adChia-I Wu#if FEATURE_beginend 39cef97267d696d37f4dccb22951499ca25d5d87adChia-I Wu 40cef97267d696d37f4dccb22951499ca25d5d87adChia-I Wu 414b55e3695279daef221669ff063631cf3675da0cBrian Paulstatic void 424b55e3695279daef221669ff063631cf3675da0cBrian Paulvbo_exec_debug_verts( struct vbo_exec_context *exec ) 43fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell{ 44fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLuint count = exec->vtx.vert_count; 45fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLuint i; 46fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 47298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg printf("%s: %u vertices %d primitives, %d vertsize\n", 48298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg __FUNCTION__, 49298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg count, 50298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg exec->vtx.prim_count, 51298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg exec->vtx.vertex_size); 52fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 53fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell for (i = 0 ; i < exec->vtx.prim_count ; i++) { 54fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell struct _mesa_prim *prim = &exec->vtx.prim[i]; 55298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg printf(" prim %d: %s%s %d..%d %s %s\n", 56298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg i, 57298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg _mesa_lookup_prim_by_nr(prim->mode), 58298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg prim->weak ? " (weak)" : "", 59298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg prim->start, 60298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg prim->start + prim->count, 61298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg prim->begin ? "BEGIN" : "(wrap)", 62298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg prim->end ? "END" : "(wrap)"); 63fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 64fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell} 65fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 66fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 67fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell/* 68fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * NOTE: Need to have calculated primitives by this point -- do it on the fly. 69fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * NOTE: Old 'parity' issue is gone. 70fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell */ 714b55e3695279daef221669ff063631cf3675da0cBrian Paulstatic GLuint 724b55e3695279daef221669ff063631cf3675da0cBrian Paulvbo_copy_vertices( struct vbo_exec_context *exec ) 73fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell{ 74fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLuint nr = exec->vtx.prim[exec->vtx.prim_count-1].count; 75fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLuint ovf, i; 76fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLuint sz = exec->vtx.vertex_size; 77fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLfloat *dst = exec->vtx.copied.buffer; 784b55e3695279daef221669ff063631cf3675da0cBrian Paul const GLfloat *src = (exec->vtx.buffer_map + 794b55e3695279daef221669ff063631cf3675da0cBrian Paul exec->vtx.prim[exec->vtx.prim_count-1].start * 804b55e3695279daef221669ff063631cf3675da0cBrian Paul exec->vtx.vertex_size); 81fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 82fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 834b55e3695279daef221669ff063631cf3675da0cBrian Paul switch (exec->ctx->Driver.CurrentExecPrimitive) { 84fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_POINTS: 85fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 0; 86fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_LINES: 87fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell ovf = nr&1; 88fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell for (i = 0 ; i < ovf ; i++) 89c7ac486261ad30ef654f6d0b1608da4e8483cd40Kenneth Graunke memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); 90fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return i; 91fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_TRIANGLES: 92fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell ovf = nr%3; 93fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell for (i = 0 ; i < ovf ; i++) 94c7ac486261ad30ef654f6d0b1608da4e8483cd40Kenneth Graunke memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); 95fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return i; 96fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_QUADS: 97fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell ovf = nr&3; 98fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell for (i = 0 ; i < ovf ; i++) 99c7ac486261ad30ef654f6d0b1608da4e8483cd40Kenneth Graunke memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); 100fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return i; 101fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_LINE_STRIP: 1024b55e3695279daef221669ff063631cf3675da0cBrian Paul if (nr == 0) { 103fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 0; 1044b55e3695279daef221669ff063631cf3675da0cBrian Paul } 105fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell else { 106c7ac486261ad30ef654f6d0b1608da4e8483cd40Kenneth Graunke memcpy( dst, src+(nr-1)*sz, sz * sizeof(GLfloat) ); 107fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 1; 108fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 109fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_LINE_LOOP: 110fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_TRIANGLE_FAN: 111fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_POLYGON: 1124b55e3695279daef221669ff063631cf3675da0cBrian Paul if (nr == 0) { 113fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 0; 1144b55e3695279daef221669ff063631cf3675da0cBrian Paul } 115fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell else if (nr == 1) { 116c7ac486261ad30ef654f6d0b1608da4e8483cd40Kenneth Graunke memcpy( dst, src+0, sz * sizeof(GLfloat) ); 117fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 1; 1184b55e3695279daef221669ff063631cf3675da0cBrian Paul } 1194b55e3695279daef221669ff063631cf3675da0cBrian Paul else { 120c7ac486261ad30ef654f6d0b1608da4e8483cd40Kenneth Graunke memcpy( dst, src+0, sz * sizeof(GLfloat) ); 121c7ac486261ad30ef654f6d0b1608da4e8483cd40Kenneth Graunke memcpy( dst+sz, src+(nr-1)*sz, sz * sizeof(GLfloat) ); 122fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 2; 123fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 124fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_TRIANGLE_STRIP: 1255970400476c5c0a1223a49e9ec2eb511ae94b246Roland Scheidegger /* no parity issue, but need to make sure the tri is not drawn twice */ 1265970400476c5c0a1223a49e9ec2eb511ae94b246Roland Scheidegger if (nr & 1) { 1275970400476c5c0a1223a49e9ec2eb511ae94b246Roland Scheidegger exec->vtx.prim[exec->vtx.prim_count-1].count--; 1285970400476c5c0a1223a49e9ec2eb511ae94b246Roland Scheidegger } 1295970400476c5c0a1223a49e9ec2eb511ae94b246Roland Scheidegger /* fallthrough */ 130fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_QUAD_STRIP: 131fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell switch (nr) { 1324b55e3695279daef221669ff063631cf3675da0cBrian Paul case 0: 1334b55e3695279daef221669ff063631cf3675da0cBrian Paul ovf = 0; 1344b55e3695279daef221669ff063631cf3675da0cBrian Paul break; 1354b55e3695279daef221669ff063631cf3675da0cBrian Paul case 1: 1364b55e3695279daef221669ff063631cf3675da0cBrian Paul ovf = 1; 1374b55e3695279daef221669ff063631cf3675da0cBrian Paul break; 1384b55e3695279daef221669ff063631cf3675da0cBrian Paul default: 1394b55e3695279daef221669ff063631cf3675da0cBrian Paul ovf = 2 + (nr & 1); 1404b55e3695279daef221669ff063631cf3675da0cBrian Paul break; 141fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 142fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell for (i = 0 ; i < ovf ; i++) 143c7ac486261ad30ef654f6d0b1608da4e8483cd40Kenneth Graunke memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); 144fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return i; 1459acf207277b4de91b917b37a92f6b612f4710c80Brian Paul case PRIM_OUTSIDE_BEGIN_END: 146fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 0; 147fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell default: 148fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell assert(0); 149fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 0; 150fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 151fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell} 152fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 153fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 15499efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell 155fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell/* TODO: populate these as the vertex is defined: 156fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell */ 1574b55e3695279daef221669ff063631cf3675da0cBrian Paulstatic void 158f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergvbo_exec_bind_arrays( struct gl_context *ctx ) 159fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell{ 16099efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell struct vbo_context *vbo = vbo_context(ctx); 16199efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell struct vbo_exec_context *exec = &vbo->exec; 162fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell struct gl_client_array *arrays = exec->vtx.arrays; 1634b55e3695279daef221669ff063631cf3675da0cBrian Paul const GLuint count = exec->vtx.vert_count; 16499efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell const GLuint *map; 165fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLuint attr; 166239617fbe22d4dd7b2794510a6665f09602b5adfBrian Paul GLbitfield varying_inputs = 0x0; 167fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 16899efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell /* Install the default (ie Current) attributes first, then overlay 16999efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell * all active ones. 17099efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell */ 17199efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell switch (get_program_mode(exec->ctx)) { 17299efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell case VP_NONE: 17337c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul for (attr = 0; attr < 16; attr++) { 17437c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul exec->vtx.inputs[attr] = &vbo->legacy_currval[attr]; 17537c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul } 17637c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) { 1771c3f7ab74ce492d6c92f2e3a0f29957fa9a71d96Brian Paul ASSERT(attr + 16 < Elements(exec->vtx.inputs)); 17837c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul exec->vtx.inputs[attr + 16] = &vbo->mat_currval[attr]; 17937c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul } 18099efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell map = vbo->map_vp_none; 18199efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell break; 18299efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell case VP_NV: 18399efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell case VP_ARB: 18499efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell /* The aliasing of attributes for NV vertex programs has already 18599efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell * occurred. NV vertex programs cannot access material values, 18699efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell * nor attributes greater than VERT_ATTRIB_TEX7. 18799efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell */ 18837c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul for (attr = 0; attr < 16; attr++) { 18937c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul exec->vtx.inputs[attr] = &vbo->legacy_currval[attr]; 1901c3f7ab74ce492d6c92f2e3a0f29957fa9a71d96Brian Paul ASSERT(attr + 16 < Elements(exec->vtx.inputs)); 19137c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul exec->vtx.inputs[attr + 16] = &vbo->generic_currval[attr]; 19237c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul } 19399efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell map = vbo->map_vp_arb; 194dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul 195dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul /* check if VERT_ATTRIB_POS is not read but VERT_BIT_GENERIC0 is read. 196dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul * In that case we effectively need to route the data from 197dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul * glVertexAttrib(0, val) calls to feed into the GENERIC0 input. 198dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul */ 199dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul if ((ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_POS) == 0 && 200dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_GENERIC0)) { 201dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul exec->vtx.inputs[16] = exec->vtx.inputs[0]; 202dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul exec->vtx.attrsz[16] = exec->vtx.attrsz[0]; 203c3538969e1ae3e626a618934aa8f35a7a22ddb39Brian Paul exec->vtx.attrptr[16] = exec->vtx.attrptr[0]; 204dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul exec->vtx.attrsz[0] = 0; 205dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul } 20699efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell break; 207dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul default: 208dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul assert(0); 20999efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell } 210fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 211fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell /* Make all active attributes (including edgeflag) available as 212fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * arrays of floats. 213fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell */ 21499efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell for (attr = 0; attr < VERT_ATTRIB_MAX ; attr++) { 2156f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian const GLuint src = map[attr]; 21699efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell 21799efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell if (exec->vtx.attrsz[src]) { 2182e64c2209e7f9d5acbcc9d70bf315732f3c403b3Francisco Jerez GLsizeiptr offset = (GLbyte *)exec->vtx.attrptr[src] - 2192e64c2209e7f9d5acbcc9d70bf315732f3c403b3Francisco Jerez (GLbyte *)exec->vtx.vertex; 2202e64c2209e7f9d5acbcc9d70bf315732f3c403b3Francisco Jerez 22137c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul /* override the default array set above */ 2221c3f7ab74ce492d6c92f2e3a0f29957fa9a71d96Brian Paul ASSERT(attr < Elements(exec->vtx.inputs)); 2231c3f7ab74ce492d6c92f2e3a0f29957fa9a71d96Brian Paul ASSERT(attr < Elements(exec->vtx.arrays)); /* arrays[] */ 22437c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul exec->vtx.inputs[attr] = &arrays[attr]; 22537c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul 226bd4c6a2e503db43e81ef41f77d876308badd93ebBrian Paul if (_mesa_is_bufferobj(exec->vtx.bufferobj)) { 2276f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian /* a real buffer obj: Ptr is an offset, not a pointer*/ 2286f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian assert(exec->vtx.bufferobj->Pointer); /* buf should be mapped */ 2296f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian assert(offset >= 0); 2302e64c2209e7f9d5acbcc9d70bf315732f3c403b3Francisco Jerez arrays[attr].Ptr = (GLubyte *)exec->vtx.bufferobj->Offset + offset; 2316f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian } 2326f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian else { 2336f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian /* Ptr into ordinary app memory */ 2342e64c2209e7f9d5acbcc9d70bf315732f3c403b3Francisco Jerez arrays[attr].Ptr = (GLubyte *)exec->vtx.buffer_map + offset; 2356f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian } 23699efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell arrays[attr].Size = exec->vtx.attrsz[src]; 237fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat); 238fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat); 239fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell arrays[attr].Type = GL_FLOAT; 240ded949ed06e02ef26b1168b101daba04be78155eBrian Paul arrays[attr].Format = GL_RGBA; 241fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell arrays[attr].Enabled = 1; 242204991bf5d29caa3fa54df9e4f6898faa73752cfBrian Paul arrays[attr]._ElementSize = arrays[attr].Size * sizeof(GLfloat); 24337c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul _mesa_reference_buffer_object(ctx, 24437c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul &arrays[attr].BufferObj, 24537c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul exec->vtx.bufferobj); 246fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell arrays[attr]._MaxElement = count; /* ??? */ 247fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 2484b55e3695279daef221669ff063631cf3675da0cBrian Paul varying_inputs |= 1 << attr; 2495a01361ceaf29614ba008278e31cf2ffe85f251bMarek Olšák ctx->NewState |= _NEW_ARRAY; 250fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 251fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 2521680ef869625dc1fe9cf481b180382a34e0738e7Keith Whitwell 2531680ef869625dc1fe9cf481b180382a34e0738e7Keith Whitwell _mesa_set_varying_vp_inputs( ctx, varying_inputs ); 254fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell} 255fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 256fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 257f0c8e7c32766cb78756de24a9ca5e8c28017a682Brian Paul/** 258f0c8e7c32766cb78756de24a9ca5e8c28017a682Brian Paul * Unmap the VBO. This is called before drawing. 259f0c8e7c32766cb78756de24a9ca5e8c28017a682Brian Paul */ 2604b55e3695279daef221669ff063631cf3675da0cBrian Paulstatic void 2614b55e3695279daef221669ff063631cf3675da0cBrian Paulvbo_exec_vtx_unmap( struct vbo_exec_context *exec ) 262c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell{ 263c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell GLenum target = GL_ARRAY_BUFFER_ARB; 264c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 265bd4c6a2e503db43e81ef41f77d876308badd93ebBrian Paul if (_mesa_is_bufferobj(exec->vtx.bufferobj)) { 266f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg struct gl_context *ctx = exec->ctx; 267cfd5298f240612ef69ae321aebbc425710a8d731José Fonseca 2684b55e3695279daef221669ff063631cf3675da0cBrian Paul if (ctx->Driver.FlushMappedBufferRange) { 2698ad65a23d14f82461c00b1d8dcc1393167f36ab0José Fonseca GLintptr offset = exec->vtx.buffer_used - exec->vtx.bufferobj->Offset; 2708ad65a23d14f82461c00b1d8dcc1393167f36ab0José Fonseca GLsizeiptr length = (exec->vtx.buffer_ptr - exec->vtx.buffer_map) * sizeof(float); 2718ad65a23d14f82461c00b1d8dcc1393167f36ab0José Fonseca 2724b55e3695279daef221669ff063631cf3675da0cBrian Paul if (length) 2736183edc070e2d3dce36ab5ee7aee72b0c38775a7Ian Romanick ctx->Driver.FlushMappedBufferRange(ctx, offset, length, 2748ad65a23d14f82461c00b1d8dcc1393167f36ab0José Fonseca exec->vtx.bufferobj); 2758ad65a23d14f82461c00b1d8dcc1393167f36ab0José Fonseca } 276c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 277c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_used += (exec->vtx.buffer_ptr - 278c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_map) * sizeof(float); 279368ca83a3fdfbe8dfe591ab73d29c500d1a91c0aKeith Whitwell 280368ca83a3fdfbe8dfe591ab73d29c500d1a91c0aKeith Whitwell assert(exec->vtx.buffer_used <= VBO_VERT_BUFFER_SIZE); 281368ca83a3fdfbe8dfe591ab73d29c500d1a91c0aKeith Whitwell assert(exec->vtx.buffer_ptr != NULL); 282368ca83a3fdfbe8dfe591ab73d29c500d1a91c0aKeith Whitwell 28356f0c00f125ee75caeadc1c9e8cab8a488635e5eIan Romanick ctx->Driver.UnmapBuffer(ctx, exec->vtx.bufferobj); 284c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_map = NULL; 285c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_ptr = NULL; 286c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.max_vert = 0; 287c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell } 288c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell} 289c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 2904b55e3695279daef221669ff063631cf3675da0cBrian Paul 291f0c8e7c32766cb78756de24a9ca5e8c28017a682Brian Paul/** 292f0c8e7c32766cb78756de24a9ca5e8c28017a682Brian Paul * Map the vertex buffer to begin storing glVertex, glColor, etc data. 293f0c8e7c32766cb78756de24a9ca5e8c28017a682Brian Paul */ 2944b55e3695279daef221669ff063631cf3675da0cBrian Paulvoid 2954b55e3695279daef221669ff063631cf3675da0cBrian Paulvbo_exec_vtx_map( struct vbo_exec_context *exec ) 296c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell{ 297f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg struct gl_context *ctx = exec->ctx; 2986e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca const GLenum target = GL_ARRAY_BUFFER_ARB; 2996e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca const GLenum access = GL_READ_WRITE_ARB; /* for MapBuffer */ 3006e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca const GLenum accessRange = GL_MAP_WRITE_BIT | /* for MapBufferRange */ 3016e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca GL_MAP_INVALIDATE_RANGE_BIT | 3026e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca GL_MAP_UNSYNCHRONIZED_BIT | 3036e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca GL_MAP_FLUSH_EXPLICIT_BIT | 3046e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca MESA_MAP_NOWAIT_BIT; 3056e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca const GLenum usage = GL_STREAM_DRAW_ARB; 306c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 307bd4c6a2e503db43e81ef41f77d876308badd93ebBrian Paul if (!_mesa_is_bufferobj(exec->vtx.bufferobj)) 308c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell return; 309c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 3100ba2810e47d68ec24a93c5fc74cf99afe50e8c9bBrian Paul assert(!exec->vtx.buffer_map); 3110ba2810e47d68ec24a93c5fc74cf99afe50e8c9bBrian Paul assert(!exec->vtx.buffer_ptr); 312c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 313c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell if (VBO_VERT_BUFFER_SIZE > exec->vtx.buffer_used + 1024 && 3144b55e3695279daef221669ff063631cf3675da0cBrian Paul ctx->Driver.MapBufferRange) { 315f0c8e7c32766cb78756de24a9ca5e8c28017a682Brian Paul /* The VBO exists and there's room for more */ 316c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_map = 317c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell (GLfloat *)ctx->Driver.MapBufferRange(ctx, 318c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_used, 319c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell (VBO_VERT_BUFFER_SIZE - 320c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_used), 3216e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca accessRange, 322c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.bufferobj); 323368ca83a3fdfbe8dfe591ab73d29c500d1a91c0aKeith Whitwell exec->vtx.buffer_ptr = exec->vtx.buffer_map; 324c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell } 325004d8f11882c6c149a395cf2e86d5d5fb3fa114bJosé Fonseca 326004d8f11882c6c149a395cf2e86d5d5fb3fa114bJosé Fonseca if (!exec->vtx.buffer_map) { 327f0c8e7c32766cb78756de24a9ca5e8c28017a682Brian Paul /* Need to allocate a new VBO */ 328c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_used = 0; 329c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 330c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell ctx->Driver.BufferData(ctx, target, 331c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell VBO_VERT_BUFFER_SIZE, 332c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell NULL, usage, exec->vtx.bufferobj); 333c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 3346e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca 3356e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca if (ctx->Driver.MapBufferRange) 3366e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca exec->vtx.buffer_map = 3374ddae2fb666c86e3267ef6e3d2699f9bfb40d206Ian Romanick (GLfloat *)ctx->Driver.MapBufferRange(ctx, 3386e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca 0, VBO_VERT_BUFFER_SIZE, 3396e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca accessRange, 3406e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca exec->vtx.bufferobj); 3419a0b570ab64169cee66f848d97d65f22c43d13ecCorbin Simpson if (!exec->vtx.buffer_map) 3426e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca exec->vtx.buffer_map = 34312d924c5ae14a1c6a05a3dcae29b77e7668e227dIan Romanick (GLfloat *)ctx->Driver.MapBuffer(ctx, access, exec->vtx.bufferobj); 3449a0b570ab64169cee66f848d97d65f22c43d13ecCorbin Simpson assert(exec->vtx.buffer_map); 345368ca83a3fdfbe8dfe591ab73d29c500d1a91c0aKeith Whitwell exec->vtx.buffer_ptr = exec->vtx.buffer_map; 346c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell } 347c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 3484b55e3695279daef221669ff063631cf3675da0cBrian Paul if (0) 349298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg printf("map %d..\n", exec->vtx.buffer_used); 350c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell} 351c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 352c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 353c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 354fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell/** 355fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * Execute the buffer and save copied verts. 3567cba2df4a6f3b4435fe4be277db4a87b2a0f89e3Brian Paul * \param keep_unmapped if true, leave the VBO unmapped when we're done. 357fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell */ 3584b55e3695279daef221669ff063631cf3675da0cBrian Paulvoid 3597cba2df4a6f3b4435fe4be277db4a87b2a0f89e3Brian Paulvbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean keepUnmapped) 360fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell{ 361fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (0) 362fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell vbo_exec_debug_verts( exec ); 363fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 364fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (exec->vtx.prim_count && 365fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.vert_count) { 366fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 367fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.copied.nr = vbo_copy_vertices( exec ); 368fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 369fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (exec->vtx.copied.nr != exec->vtx.vert_count) { 370f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg struct gl_context *ctx = exec->ctx; 37133fef8be825ee8ec6abc0c2ffd9a3a967d84df88Keith Whitwell 372c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell /* Before the update_state() as this may raise _NEW_ARRAY 373c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell * from _mesa_set_varying_vp_inputs(). 37433fef8be825ee8ec6abc0c2ffd9a3a967d84df88Keith Whitwell */ 37599efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell vbo_exec_bind_arrays( ctx ); 376fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 3771680ef869625dc1fe9cf481b180382a34e0738e7Keith Whitwell if (ctx->NewState) 3781680ef869625dc1fe9cf481b180382a34e0738e7Keith Whitwell _mesa_update_state( ctx ); 3791680ef869625dc1fe9cf481b180382a34e0738e7Keith Whitwell 380bd4c6a2e503db43e81ef41f77d876308badd93ebBrian Paul if (_mesa_is_bufferobj(exec->vtx.bufferobj)) { 381c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell vbo_exec_vtx_unmap( exec ); 3826222eb3fcd12147ea2e7ccc20a71a921cebbb0d2Brian Paul } 38333fef8be825ee8ec6abc0c2ffd9a3a967d84df88Keith Whitwell 3844b55e3695279daef221669ff063631cf3675da0cBrian Paul if (0) 385298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg printf("%s %d %d\n", __FUNCTION__, exec->vtx.prim_count, 386298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg exec->vtx.vert_count); 3879d4ab42f4be3a26f702729cc79ef67f8afc2eca5Keith Whitwell 388fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell vbo_context(ctx)->draw_prims( ctx, 389fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.inputs, 390fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.prim, 391fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.prim_count, 392fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell NULL, 3932708ddfb06a36d8568e2aa130bf1f7d551fcd309Eric Anholt GL_TRUE, 394fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 0, 395c080123998f28d9317331aec7ddfcd1074b29dafAapo Tahkola exec->vtx.vert_count - 1); 39633fef8be825ee8ec6abc0c2ffd9a3a967d84df88Keith Whitwell 397c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell /* If using a real VBO, get new storage -- unless asked not to. 398c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell */ 3997cba2df4a6f3b4435fe4be277db4a87b2a0f89e3Brian Paul if (_mesa_is_bufferobj(exec->vtx.bufferobj) && !keepUnmapped) { 400c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell vbo_exec_vtx_map( exec ); 4014b55e3695279daef221669ff063631cf3675da0cBrian Paul } 402fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 403fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 404fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 405c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell /* May have to unmap explicitly if we didn't draw: 406c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell */ 4077cba2df4a6f3b4435fe4be277db4a87b2a0f89e3Brian Paul if (keepUnmapped && 408bd4c6a2e503db43e81ef41f77d876308badd93ebBrian Paul _mesa_is_bufferobj(exec->vtx.bufferobj) && 409c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_map) { 410c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell vbo_exec_vtx_unmap( exec ); 411c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell } 412c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 4137cba2df4a6f3b4435fe4be277db4a87b2a0f89e3Brian Paul if (keepUnmapped || exec->vtx.vertex_size == 0) 414c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.max_vert = 0; 415c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell else 416c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / 417c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell (exec->vtx.vertex_size * sizeof(GLfloat))); 418c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 419c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_ptr = exec->vtx.buffer_map; 420fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.prim_count = 0; 421fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.vert_count = 0; 422fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell} 423cef97267d696d37f4dccb22951499ca25d5d87adChia-I Wu 424cef97267d696d37f4dccb22951499ca25d5d87adChia-I Wu 425cef97267d696d37f4dccb22951499ca25d5d87adChia-I Wu#endif /* FEATURE_beginend */ 426