1848b8605Smrg/************************************************************************** 2848b8605Smrg 3848b8605SmrgCopyright 2002 VMware, Inc. 4848b8605Smrg 5848b8605SmrgAll Rights Reserved. 6848b8605Smrg 7848b8605SmrgPermission is hereby granted, free of charge, to any person obtaining a 8848b8605Smrgcopy of this software and associated documentation files (the "Software"), 9848b8605Smrgto deal in the Software without restriction, including without limitation 10848b8605Smrgon the rights to use, copy, modify, merge, publish, distribute, sub 11848b8605Smrglicense, and/or sell copies of the Software, and to permit persons to whom 12848b8605Smrgthe Software is furnished to do so, subject to the following conditions: 13848b8605Smrg 14848b8605SmrgThe above copyright notice and this permission notice (including the next 15848b8605Smrgparagraph) shall be included in all copies or substantial portions of the 16848b8605SmrgSoftware. 17848b8605Smrg 18848b8605SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19848b8605SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20848b8605SmrgFITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 21848b8605SmrgVMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 22848b8605SmrgDAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 23848b8605SmrgOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 24848b8605SmrgUSE OR OTHER DEALINGS IN THE SOFTWARE. 25848b8605Smrg 26848b8605Smrg**************************************************************************/ 27848b8605Smrg 28848b8605Smrg/* 29848b8605Smrg * Authors: 30848b8605Smrg * Keith Whitwell <keithw@vmware.com> 31848b8605Smrg * 32848b8605Smrg */ 33848b8605Smrg 34b8e80941Smrg#ifndef VBO_EXEC_H 35b8e80941Smrg#define VBO_EXEC_H 36848b8605Smrg 37b8e80941Smrg#include "main/dd.h" 38b8e80941Smrg#include "main/imports.h" 39848b8605Smrg#include "vbo.h" 40848b8605Smrg#include "vbo_attrib.h" 41848b8605Smrg 42848b8605Smrg 43848b8605Smrg/** 44848b8605Smrg * Max number of primitives (number of glBegin/End pairs) per VBO. 45848b8605Smrg */ 46848b8605Smrg#define VBO_MAX_PRIM 64 47848b8605Smrg 48848b8605Smrg 49848b8605Smrg/** 50b8e80941Smrg * Size (in bytes) of the VBO to use for glBegin/glVertex/glEnd-style rendering. 51848b8605Smrg */ 52b8e80941Smrg#define VBO_VERT_BUFFER_SIZE (1024 * 64) 53848b8605Smrg 54848b8605Smrg 55848b8605Smrgstruct vbo_exec_eval1_map { 56848b8605Smrg struct gl_1d_map *map; 57848b8605Smrg GLuint sz; 58848b8605Smrg}; 59848b8605Smrg 60848b8605Smrgstruct vbo_exec_eval2_map { 61848b8605Smrg struct gl_2d_map *map; 62848b8605Smrg GLuint sz; 63848b8605Smrg}; 64848b8605Smrg 65848b8605Smrg 66848b8605Smrg 67848b8605Smrgstruct vbo_exec_copied_vtx { 68b8e80941Smrg fi_type buffer[VBO_ATTRIB_MAX * 4 * VBO_MAX_COPIED_VERTS]; 69848b8605Smrg GLuint nr; 70848b8605Smrg}; 71848b8605Smrg 72848b8605Smrg 73848b8605Smrgstruct vbo_exec_context 74848b8605Smrg{ 75b8e80941Smrg struct gl_context *ctx; 76848b8605Smrg GLvertexformat vtxfmt; 77848b8605Smrg GLvertexformat vtxfmt_noop; 78848b8605Smrg 79848b8605Smrg struct { 80848b8605Smrg struct gl_buffer_object *bufferobj; 81848b8605Smrg 82848b8605Smrg GLuint vertex_size; /* in dwords */ 83848b8605Smrg 84848b8605Smrg struct _mesa_prim prim[VBO_MAX_PRIM]; 85848b8605Smrg GLuint prim_count; 86848b8605Smrg 87b8e80941Smrg fi_type *buffer_map; 88b8e80941Smrg fi_type *buffer_ptr; /* cursor, points into buffer */ 89848b8605Smrg GLuint buffer_used; /* in bytes */ 90b8e80941Smrg fi_type vertex[VBO_ATTRIB_MAX*4]; /* current vertex */ 91848b8605Smrg 92b8e80941Smrg GLuint vert_count; /**< Number of vertices currently in buffer */ 93b8e80941Smrg GLuint max_vert; /**< Max number of vertices allowed in buffer */ 94848b8605Smrg struct vbo_exec_copied_vtx copied; 95848b8605Smrg 96b8e80941Smrg GLbitfield64 enabled; /**< mask of enabled vbo arrays. */ 97b8e80941Smrg GLubyte attrsz[VBO_ATTRIB_MAX]; /**< nr. of attrib components (1..4) */ 98b8e80941Smrg GLenum16 attrtype[VBO_ATTRIB_MAX]; /**< GL_FLOAT, GL_DOUBLE, GL_INT, etc */ 99b8e80941Smrg GLubyte active_sz[VBO_ATTRIB_MAX]; /**< attrib size (nr. 32-bit words) */ 100848b8605Smrg 101b8e80941Smrg /** pointers into the current 'vertex' array, declared above */ 102b8e80941Smrg fi_type *attrptr[VBO_ATTRIB_MAX]; 103848b8605Smrg } vtx; 104848b8605Smrg 105848b8605Smrg struct { 106848b8605Smrg GLboolean recalculate_maps; 107848b8605Smrg struct vbo_exec_eval1_map map1[VERT_ATTRIB_MAX]; 108848b8605Smrg struct vbo_exec_eval2_map map2[VERT_ATTRIB_MAX]; 109848b8605Smrg } eval; 110848b8605Smrg 111b8e80941Smrg /* Which flags to set in vbo_exec_begin_vertices() */ 112848b8605Smrg GLbitfield begin_vertices_flags; 113848b8605Smrg 114848b8605Smrg#ifdef DEBUG 115848b8605Smrg GLint flush_call_depth; 116848b8605Smrg#endif 117848b8605Smrg}; 118848b8605Smrg 119848b8605Smrg 120848b8605Smrg 121b8e80941Smrgvoid 122b8e80941Smrgvbo_exec_init(struct gl_context *ctx); 123848b8605Smrg 124b8e80941Smrgvoid 125b8e80941Smrgvbo_exec_destroy(struct gl_context *ctx); 126848b8605Smrg 127b8e80941Smrgvoid 128b8e80941Smrgvbo_exec_vtx_init(struct vbo_exec_context *exec); 129848b8605Smrg 130b8e80941Smrgvoid 131b8e80941Smrgvbo_exec_vtx_destroy(struct vbo_exec_context *exec); 132848b8605Smrg 133b8e80941Smrgvoid 134b8e80941Smrgvbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean unmap); 135848b8605Smrg 136b8e80941Smrgvoid 137b8e80941Smrgvbo_exec_vtx_map(struct vbo_exec_context *exec); 138848b8605Smrg 139b8e80941Smrgvoid 140b8e80941Smrgvbo_exec_eval_update(struct vbo_exec_context *exec); 141848b8605Smrg 142b8e80941Smrgvoid 143b8e80941Smrgvbo_exec_do_EvalCoord2f(struct vbo_exec_context *exec, GLfloat u, GLfloat v); 144848b8605Smrg 145b8e80941Smrgvoid 146b8e80941Smrgvbo_exec_do_EvalCoord1f(struct vbo_exec_context *exec, GLfloat u); 147848b8605Smrg 148848b8605Smrg#endif 149