vbo_exec_draw.c revision 2708ddfb06a36d8568e2aa130bf1f7d551fcd309
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" 30c223c6b663cd5db39ba19c2be74b88cc3b8f53f3Brian#include "main/context.h" 31c223c6b663cd5db39ba19c2be74b88cc3b8f53f3Brian#include "main/enums.h" 32c223c6b663cd5db39ba19c2be74b88cc3b8f53f3Brian#include "main/state.h" 33c223c6b663cd5db39ba19c2be74b88cc3b8f53f3Brian#include "main/macros.h" 34fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 35fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell#include "vbo_context.h" 36fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 37fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 384b55e3695279daef221669ff063631cf3675da0cBrian Paulstatic void 394b55e3695279daef221669ff063631cf3675da0cBrian Paulvbo_exec_debug_verts( struct vbo_exec_context *exec ) 40fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell{ 41fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLuint count = exec->vtx.vert_count; 42fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLuint i; 43fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 44fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell _mesa_printf("%s: %u vertices %d primitives, %d vertsize\n", 45fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell __FUNCTION__, 46fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell count, 47fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.prim_count, 48fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.vertex_size); 49fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 50fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell for (i = 0 ; i < exec->vtx.prim_count ; i++) { 51fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell struct _mesa_prim *prim = &exec->vtx.prim[i]; 52fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell _mesa_printf(" prim %d: %s%s %d..%d %s %s\n", 53fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell i, 540846c88ec3a63ac5e4096aedcdc107cbe71f306bKeith Whitwell _mesa_lookup_prim_by_nr(prim->mode), 55fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell prim->weak ? " (weak)" : "", 56fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell prim->start, 57fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell prim->start + prim->count, 58fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell prim->begin ? "BEGIN" : "(wrap)", 59fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell prim->end ? "END" : "(wrap)"); 60fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 61fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell} 62fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 63fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 64fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell/* 65fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * NOTE: Need to have calculated primitives by this point -- do it on the fly. 66fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * NOTE: Old 'parity' issue is gone. 67fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell */ 684b55e3695279daef221669ff063631cf3675da0cBrian Paulstatic GLuint 694b55e3695279daef221669ff063631cf3675da0cBrian Paulvbo_copy_vertices( struct vbo_exec_context *exec ) 70fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell{ 71fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLuint nr = exec->vtx.prim[exec->vtx.prim_count-1].count; 72fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLuint ovf, i; 73fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLuint sz = exec->vtx.vertex_size; 74fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLfloat *dst = exec->vtx.copied.buffer; 754b55e3695279daef221669ff063631cf3675da0cBrian Paul const GLfloat *src = (exec->vtx.buffer_map + 764b55e3695279daef221669ff063631cf3675da0cBrian Paul exec->vtx.prim[exec->vtx.prim_count-1].start * 774b55e3695279daef221669ff063631cf3675da0cBrian Paul exec->vtx.vertex_size); 78fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 79fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 804b55e3695279daef221669ff063631cf3675da0cBrian Paul switch (exec->ctx->Driver.CurrentExecPrimitive) { 81fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_POINTS: 82fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 0; 83fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_LINES: 84fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell ovf = nr&1; 85fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell for (i = 0 ; i < ovf ; i++) 86fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); 87fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return i; 88fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_TRIANGLES: 89fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell ovf = nr%3; 90fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell for (i = 0 ; i < ovf ; i++) 91fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); 92fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return i; 93fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_QUADS: 94fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell ovf = nr&3; 95fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell for (i = 0 ; i < ovf ; i++) 96fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); 97fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return i; 98fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_LINE_STRIP: 994b55e3695279daef221669ff063631cf3675da0cBrian Paul if (nr == 0) { 100fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 0; 1014b55e3695279daef221669ff063631cf3675da0cBrian Paul } 102fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell else { 103fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell _mesa_memcpy( dst, src+(nr-1)*sz, sz * sizeof(GLfloat) ); 104fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 1; 105fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 106fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_LINE_LOOP: 107fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_TRIANGLE_FAN: 108fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_POLYGON: 1094b55e3695279daef221669ff063631cf3675da0cBrian Paul if (nr == 0) { 110fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 0; 1114b55e3695279daef221669ff063631cf3675da0cBrian Paul } 112fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell else if (nr == 1) { 113fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell _mesa_memcpy( dst, src+0, sz * sizeof(GLfloat) ); 114fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 1; 1154b55e3695279daef221669ff063631cf3675da0cBrian Paul } 1164b55e3695279daef221669ff063631cf3675da0cBrian Paul else { 117fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell _mesa_memcpy( dst, src+0, sz * sizeof(GLfloat) ); 118fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell _mesa_memcpy( dst+sz, src+(nr-1)*sz, sz * sizeof(GLfloat) ); 119fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 2; 120fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 121fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_TRIANGLE_STRIP: 1225970400476c5c0a1223a49e9ec2eb511ae94b246Roland Scheidegger /* no parity issue, but need to make sure the tri is not drawn twice */ 1235970400476c5c0a1223a49e9ec2eb511ae94b246Roland Scheidegger if (nr & 1) { 1245970400476c5c0a1223a49e9ec2eb511ae94b246Roland Scheidegger exec->vtx.prim[exec->vtx.prim_count-1].count--; 1255970400476c5c0a1223a49e9ec2eb511ae94b246Roland Scheidegger } 1265970400476c5c0a1223a49e9ec2eb511ae94b246Roland Scheidegger /* fallthrough */ 127fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell case GL_QUAD_STRIP: 128fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell switch (nr) { 1294b55e3695279daef221669ff063631cf3675da0cBrian Paul case 0: 1304b55e3695279daef221669ff063631cf3675da0cBrian Paul ovf = 0; 1314b55e3695279daef221669ff063631cf3675da0cBrian Paul break; 1324b55e3695279daef221669ff063631cf3675da0cBrian Paul case 1: 1334b55e3695279daef221669ff063631cf3675da0cBrian Paul ovf = 1; 1344b55e3695279daef221669ff063631cf3675da0cBrian Paul break; 1354b55e3695279daef221669ff063631cf3675da0cBrian Paul default: 1364b55e3695279daef221669ff063631cf3675da0cBrian Paul ovf = 2 + (nr & 1); 1374b55e3695279daef221669ff063631cf3675da0cBrian Paul break; 138fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 139fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell for (i = 0 ; i < ovf ; i++) 140fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); 141fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return i; 1429acf207277b4de91b917b37a92f6b612f4710c80Brian Paul case PRIM_OUTSIDE_BEGIN_END: 143fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 0; 144fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell default: 145fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell assert(0); 146fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell return 0; 147fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 148fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell} 149fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 150fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 15199efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell 152fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell/* TODO: populate these as the vertex is defined: 153fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell */ 1544b55e3695279daef221669ff063631cf3675da0cBrian Paulstatic void 1554b55e3695279daef221669ff063631cf3675da0cBrian Paulvbo_exec_bind_arrays( GLcontext *ctx ) 156fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell{ 15799efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell struct vbo_context *vbo = vbo_context(ctx); 15899efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell struct vbo_exec_context *exec = &vbo->exec; 159fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell struct gl_client_array *arrays = exec->vtx.arrays; 1604b55e3695279daef221669ff063631cf3675da0cBrian Paul const GLuint count = exec->vtx.vert_count; 1614b55e3695279daef221669ff063631cf3675da0cBrian Paul const GLubyte *data = (GLubyte *) exec->vtx.buffer_map; 16299efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell const GLuint *map; 163fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLuint attr; 164239617fbe22d4dd7b2794510a6665f09602b5adfBrian Paul GLbitfield varying_inputs = 0x0; 165fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 16699efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell /* Install the default (ie Current) attributes first, then overlay 16799efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell * all active ones. 16899efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell */ 16999efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell switch (get_program_mode(exec->ctx)) { 17099efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell case VP_NONE: 17137c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul for (attr = 0; attr < 16; attr++) { 17237c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul exec->vtx.inputs[attr] = &vbo->legacy_currval[attr]; 17337c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul } 17437c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) { 17537c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul exec->vtx.inputs[attr + 16] = &vbo->mat_currval[attr]; 17637c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul } 17799efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell map = vbo->map_vp_none; 17899efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell break; 17999efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell case VP_NV: 18099efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell case VP_ARB: 18199efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell /* The aliasing of attributes for NV vertex programs has already 18299efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell * occurred. NV vertex programs cannot access material values, 18399efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell * nor attributes greater than VERT_ATTRIB_TEX7. 18499efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell */ 18537c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul for (attr = 0; attr < 16; attr++) { 18637c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul exec->vtx.inputs[attr] = &vbo->legacy_currval[attr]; 18737c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul exec->vtx.inputs[attr + 16] = &vbo->generic_currval[attr]; 18837c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul } 18999efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell map = vbo->map_vp_arb; 190dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul 191dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul /* check if VERT_ATTRIB_POS is not read but VERT_BIT_GENERIC0 is read. 192dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul * In that case we effectively need to route the data from 193dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul * glVertexAttrib(0, val) calls to feed into the GENERIC0 input. 194dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul */ 195dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul if ((ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_POS) == 0 && 196dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_GENERIC0)) { 197dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul exec->vtx.inputs[16] = exec->vtx.inputs[0]; 198dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul exec->vtx.attrsz[16] = exec->vtx.attrsz[0]; 199c3538969e1ae3e626a618934aa8f35a7a22ddb39Brian Paul exec->vtx.attrptr[16] = exec->vtx.attrptr[0]; 200dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul exec->vtx.attrsz[0] = 0; 201dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul } 20299efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell break; 203dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul default: 204dea0d4d56326f148a42c766bdbaf1b5bb247cc59Brian Paul assert(0); 20599efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell } 206fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 207fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell /* Make all active attributes (including edgeflag) available as 208fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * arrays of floats. 209fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell */ 21099efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell for (attr = 0; attr < VERT_ATTRIB_MAX ; attr++) { 2116f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian const GLuint src = map[attr]; 21299efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell 21399efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell if (exec->vtx.attrsz[src]) { 21437c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul /* override the default array set above */ 21537c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul exec->vtx.inputs[attr] = &arrays[attr]; 21637c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul 2176f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian if (exec->vtx.bufferobj->Name) { 2186f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian /* a real buffer obj: Ptr is an offset, not a pointer*/ 219460e5b11c98e07d12c655e5bf2f1e993d05bd7a1Brian Paul GLsizeiptr offset; 2206f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian assert(exec->vtx.bufferobj->Pointer); /* buf should be mapped */ 2216f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian offset = (GLbyte *) data - (GLbyte *) exec->vtx.bufferobj->Pointer; 2226f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian assert(offset >= 0); 2236f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian arrays[attr].Ptr = (void *) offset; 2246f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian } 2256f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian else { 2266f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian /* Ptr into ordinary app memory */ 2276f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian arrays[attr].Ptr = (void *) data; 2286f765fbde42a4f729780aa39d2b0ed9d736dd5a8Brian } 22999efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell arrays[attr].Size = exec->vtx.attrsz[src]; 230fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat); 231fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat); 232fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell arrays[attr].Type = GL_FLOAT; 233ded949ed06e02ef26b1168b101daba04be78155eBrian Paul arrays[attr].Format = GL_RGBA; 234fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell arrays[attr].Enabled = 1; 23537c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul _mesa_reference_buffer_object(ctx, 23637c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul &arrays[attr].BufferObj, 23737c74af01ce52b603f565a6c8a9094500d5cb87aBrian Paul exec->vtx.bufferobj); 238fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell arrays[attr]._MaxElement = count; /* ??? */ 239fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 240a2e6beade196aef269bda6bb3efb68809f85a683Brian Paul data += exec->vtx.attrsz[src] * sizeof(GLfloat); 2414b55e3695279daef221669ff063631cf3675da0cBrian Paul varying_inputs |= 1 << attr; 242fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 243fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 2441680ef869625dc1fe9cf481b180382a34e0738e7Keith Whitwell 2451680ef869625dc1fe9cf481b180382a34e0738e7Keith Whitwell _mesa_set_varying_vp_inputs( ctx, varying_inputs ); 246fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell} 247fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 248fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 2494b55e3695279daef221669ff063631cf3675da0cBrian Paulstatic void 2504b55e3695279daef221669ff063631cf3675da0cBrian Paulvbo_exec_vtx_unmap( struct vbo_exec_context *exec ) 251c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell{ 252c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell GLenum target = GL_ARRAY_BUFFER_ARB; 253c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 254c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell if (exec->vtx.bufferobj->Name) { 255c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell GLcontext *ctx = exec->ctx; 256cfd5298f240612ef69ae321aebbc425710a8d731José Fonseca 2574b55e3695279daef221669ff063631cf3675da0cBrian Paul if (ctx->Driver.FlushMappedBufferRange) { 2588ad65a23d14f82461c00b1d8dcc1393167f36ab0José Fonseca GLintptr offset = exec->vtx.buffer_used - exec->vtx.bufferobj->Offset; 2598ad65a23d14f82461c00b1d8dcc1393167f36ab0José Fonseca GLsizeiptr length = (exec->vtx.buffer_ptr - exec->vtx.buffer_map) * sizeof(float); 2608ad65a23d14f82461c00b1d8dcc1393167f36ab0José Fonseca 2614b55e3695279daef221669ff063631cf3675da0cBrian Paul if (length) 2628ad65a23d14f82461c00b1d8dcc1393167f36ab0José Fonseca ctx->Driver.FlushMappedBufferRange(ctx, target, 2638ad65a23d14f82461c00b1d8dcc1393167f36ab0José Fonseca offset, length, 2648ad65a23d14f82461c00b1d8dcc1393167f36ab0José Fonseca exec->vtx.bufferobj); 2658ad65a23d14f82461c00b1d8dcc1393167f36ab0José Fonseca } 266c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 267c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_used += (exec->vtx.buffer_ptr - 268c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_map) * sizeof(float); 269368ca83a3fdfbe8dfe591ab73d29c500d1a91c0aKeith Whitwell 270368ca83a3fdfbe8dfe591ab73d29c500d1a91c0aKeith Whitwell assert(exec->vtx.buffer_used <= VBO_VERT_BUFFER_SIZE); 271368ca83a3fdfbe8dfe591ab73d29c500d1a91c0aKeith Whitwell assert(exec->vtx.buffer_ptr != NULL); 272368ca83a3fdfbe8dfe591ab73d29c500d1a91c0aKeith Whitwell 273c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj); 274c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_map = NULL; 275c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_ptr = NULL; 276c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.max_vert = 0; 277c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell } 278c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell} 279c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 2804b55e3695279daef221669ff063631cf3675da0cBrian Paul 2814b55e3695279daef221669ff063631cf3675da0cBrian Paulvoid 2824b55e3695279daef221669ff063631cf3675da0cBrian Paulvbo_exec_vtx_map( struct vbo_exec_context *exec ) 283c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell{ 284c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell GLcontext *ctx = exec->ctx; 2856e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca const GLenum target = GL_ARRAY_BUFFER_ARB; 2866e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca const GLenum access = GL_READ_WRITE_ARB; /* for MapBuffer */ 2876e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca const GLenum accessRange = GL_MAP_WRITE_BIT | /* for MapBufferRange */ 2886e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca GL_MAP_INVALIDATE_RANGE_BIT | 2896e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca GL_MAP_UNSYNCHRONIZED_BIT | 2906e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca GL_MAP_FLUSH_EXPLICIT_BIT | 2916e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca MESA_MAP_NOWAIT_BIT; 2926e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca const GLenum usage = GL_STREAM_DRAW_ARB; 293c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 294c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell if (exec->vtx.bufferobj->Name == 0) 295c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell return; 296c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 297c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell if (exec->vtx.buffer_map != NULL) { 298c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell assert(0); 299c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_map = NULL; 300368ca83a3fdfbe8dfe591ab73d29c500d1a91c0aKeith Whitwell exec->vtx.buffer_ptr = NULL; 301c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell } 302c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 303c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell if (VBO_VERT_BUFFER_SIZE > exec->vtx.buffer_used + 1024 && 3044b55e3695279daef221669ff063631cf3675da0cBrian Paul ctx->Driver.MapBufferRange) { 305c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_map = 306c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell (GLfloat *)ctx->Driver.MapBufferRange(ctx, 307c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell target, 308c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_used, 309c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell (VBO_VERT_BUFFER_SIZE - 310c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_used), 3116e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca accessRange, 312c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.bufferobj); 313368ca83a3fdfbe8dfe591ab73d29c500d1a91c0aKeith Whitwell exec->vtx.buffer_ptr = exec->vtx.buffer_map; 314c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell } 315004d8f11882c6c149a395cf2e86d5d5fb3fa114bJosé Fonseca 316004d8f11882c6c149a395cf2e86d5d5fb3fa114bJosé Fonseca if (!exec->vtx.buffer_map) { 317c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_used = 0; 318c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 319c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell ctx->Driver.BufferData(ctx, target, 320c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell VBO_VERT_BUFFER_SIZE, 321c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell NULL, usage, exec->vtx.bufferobj); 322c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 3236e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca 3246e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca if (ctx->Driver.MapBufferRange) 3256e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca exec->vtx.buffer_map = 3266e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca (GLfloat *)ctx->Driver.MapBufferRange(ctx, target, 3276e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca 0, VBO_VERT_BUFFER_SIZE, 3286e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca accessRange, 3296e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca exec->vtx.bufferobj); 3309a0b570ab64169cee66f848d97d65f22c43d13ecCorbin Simpson if (!exec->vtx.buffer_map) 3316e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca exec->vtx.buffer_map = 3326e09c1fd085361212c5bfccf6b2810f3f8052231José Fonseca (GLfloat *)ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); 3339a0b570ab64169cee66f848d97d65f22c43d13ecCorbin Simpson assert(exec->vtx.buffer_map); 334368ca83a3fdfbe8dfe591ab73d29c500d1a91c0aKeith Whitwell exec->vtx.buffer_ptr = exec->vtx.buffer_map; 335c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell } 336c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 3374b55e3695279daef221669ff063631cf3675da0cBrian Paul if (0) 3384b55e3695279daef221669ff063631cf3675da0cBrian Paul _mesa_printf("map %d..\n", exec->vtx.buffer_used); 339c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell} 340c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 341c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 342c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 343fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell/** 344fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * Execute the buffer and save copied verts. 345fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell */ 3464b55e3695279daef221669ff063631cf3675da0cBrian Paulvoid 3474b55e3695279daef221669ff063631cf3675da0cBrian Paulvbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap ) 348fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell{ 349fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (0) 350fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell vbo_exec_debug_verts( exec ); 351fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 352fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (exec->vtx.prim_count && 353fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.vert_count) { 354fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 355fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.copied.nr = vbo_copy_vertices( exec ); 356fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 357fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (exec->vtx.copied.nr != exec->vtx.vert_count) { 358fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLcontext *ctx = exec->ctx; 35933fef8be825ee8ec6abc0c2ffd9a3a967d84df88Keith Whitwell 360c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell /* Before the update_state() as this may raise _NEW_ARRAY 361c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell * from _mesa_set_varying_vp_inputs(). 36233fef8be825ee8ec6abc0c2ffd9a3a967d84df88Keith Whitwell */ 36399efde461d3b8615863bdb7308e05289e0db0422Keith Whitwell vbo_exec_bind_arrays( ctx ); 364fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 3651680ef869625dc1fe9cf481b180382a34e0738e7Keith Whitwell if (ctx->NewState) 3661680ef869625dc1fe9cf481b180382a34e0738e7Keith Whitwell _mesa_update_state( ctx ); 3671680ef869625dc1fe9cf481b180382a34e0738e7Keith Whitwell 3686222eb3fcd12147ea2e7ccc20a71a921cebbb0d2Brian Paul if (exec->vtx.bufferobj->Name) { 369c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell vbo_exec_vtx_unmap( exec ); 3706222eb3fcd12147ea2e7ccc20a71a921cebbb0d2Brian Paul } 37133fef8be825ee8ec6abc0c2ffd9a3a967d84df88Keith Whitwell 3724b55e3695279daef221669ff063631cf3675da0cBrian Paul if (0) 3734b55e3695279daef221669ff063631cf3675da0cBrian Paul _mesa_printf("%s %d %d\n", __FUNCTION__, exec->vtx.prim_count, 3744b55e3695279daef221669ff063631cf3675da0cBrian Paul exec->vtx.vert_count); 3759d4ab42f4be3a26f702729cc79ef67f8afc2eca5Keith Whitwell 376fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell vbo_context(ctx)->draw_prims( ctx, 377fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.inputs, 378fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.prim, 379fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.prim_count, 380fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell NULL, 3812708ddfb06a36d8568e2aa130bf1f7d551fcd309Eric Anholt GL_TRUE, 382fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 0, 383c080123998f28d9317331aec7ddfcd1074b29dafAapo Tahkola exec->vtx.vert_count - 1); 38433fef8be825ee8ec6abc0c2ffd9a3a967d84df88Keith Whitwell 385c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell /* If using a real VBO, get new storage -- unless asked not to. 386c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell */ 387c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell if (exec->vtx.bufferobj->Name && !unmap) { 388c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell vbo_exec_vtx_map( exec ); 3894b55e3695279daef221669ff063631cf3675da0cBrian Paul } 390fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 391fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 392fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 393c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell /* May have to unmap explicitly if we didn't draw: 394c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell */ 395c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell if (unmap && 396c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.bufferobj->Name && 397c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_map) { 398c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell vbo_exec_vtx_unmap( exec ); 399c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell } 400c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 401c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell if (unmap) 402c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.max_vert = 0; 403c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell else 404c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / 405c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell (exec->vtx.vertex_size * sizeof(GLfloat))); 406c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell 407c4d1f4607abf3dfbcfcffc5c67bb89d420d3381aKeith Whitwell exec->vtx.buffer_ptr = exec->vtx.buffer_map; 408fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.prim_count = 0; 409fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.vert_count = 0; 410fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell} 411