vbo.h revision 7117f1b4
17117f1b4Smrg/* 27117f1b4Smrg * mesa 3-D graphics library 37117f1b4Smrg * Version: 6.5 47117f1b4Smrg * 57117f1b4Smrg * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 67117f1b4Smrg * 77117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 87117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 97117f1b4Smrg * to deal in the Software without restriction, including without limitation 107117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 117117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 127117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 137117f1b4Smrg * 147117f1b4Smrg * The above copyright notice and this permission notice shall be included 157117f1b4Smrg * in all copies or substantial portions of the Software. 167117f1b4Smrg * 177117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 187117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 197117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 207117f1b4Smrg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 217117f1b4Smrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 227117f1b4Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 237117f1b4Smrg */ 247117f1b4Smrg 257117f1b4Smrg/** 267117f1b4Smrg * \file vbo_context.h 277117f1b4Smrg * \brief VBO builder module datatypes and definitions. 287117f1b4Smrg * \author Keith Whitwell 297117f1b4Smrg */ 307117f1b4Smrg 317117f1b4Smrg 327117f1b4Smrg#ifndef _VBO_H 337117f1b4Smrg#define _VBO_H 347117f1b4Smrg 357117f1b4Smrg#include "mtypes.h" 367117f1b4Smrg 377117f1b4Smrgstruct _mesa_prim { 387117f1b4Smrg GLuint mode:8; 397117f1b4Smrg GLuint indexed:1; 407117f1b4Smrg GLuint begin:1; 417117f1b4Smrg GLuint end:1; 427117f1b4Smrg GLuint weak:1; 437117f1b4Smrg GLuint pad:20; 447117f1b4Smrg 457117f1b4Smrg GLuint start; 467117f1b4Smrg GLuint count; 477117f1b4Smrg}; 487117f1b4Smrg 497117f1b4Smrg/* Would like to call this a "vbo_index_buffer", but this would be 507117f1b4Smrg * confusing as the indices are not neccessarily yet in a non-null 517117f1b4Smrg * buffer object. 527117f1b4Smrg */ 537117f1b4Smrgstruct _mesa_index_buffer { 547117f1b4Smrg GLuint count; 557117f1b4Smrg GLenum type; 567117f1b4Smrg struct gl_buffer_object *obj; 577117f1b4Smrg const void *ptr; 587117f1b4Smrg}; 597117f1b4Smrg 607117f1b4Smrg 617117f1b4Smrg 627117f1b4SmrgGLboolean _vbo_CreateContext( GLcontext *ctx ); 637117f1b4Smrgvoid _vbo_DestroyContext( GLcontext *ctx ); 647117f1b4Smrgvoid _vbo_InvalidateState( GLcontext *ctx, GLuint new_state ); 657117f1b4Smrg 667117f1b4Smrg 677117f1b4Smrgtypedef void (*vbo_draw_func)( GLcontext *ctx, 687117f1b4Smrg const struct gl_client_array **arrays, 697117f1b4Smrg const struct _mesa_prim *prims, 707117f1b4Smrg GLuint nr_prims, 717117f1b4Smrg const struct _mesa_index_buffer *ib, 727117f1b4Smrg GLuint min_index, 737117f1b4Smrg GLuint max_index ); 747117f1b4Smrg 757117f1b4Smrg 767117f1b4Smrg 777117f1b4Smrg 787117f1b4Smrg/* Utility function to cope with various constraints on tnl modules or 797117f1b4Smrg * hardware. This can be used to split an incoming set of arrays and 807117f1b4Smrg * primitives against the following constraints: 817117f1b4Smrg * - Maximum number of indices in index buffer. 827117f1b4Smrg * - Maximum number of vertices referenced by index buffer. 837117f1b4Smrg * - Maximum hardware vertex buffer size. 847117f1b4Smrg */ 857117f1b4Smrgstruct split_limits { 867117f1b4Smrg GLuint max_verts; 877117f1b4Smrg GLuint max_indices; 887117f1b4Smrg GLuint max_vb_size; /* bytes */ 897117f1b4Smrg}; 907117f1b4Smrg 917117f1b4Smrg 927117f1b4Smrgvoid vbo_split_prims( GLcontext *ctx, 937117f1b4Smrg const struct gl_client_array *arrays[], 947117f1b4Smrg const struct _mesa_prim *prim, 957117f1b4Smrg GLuint nr_prims, 967117f1b4Smrg const struct _mesa_index_buffer *ib, 977117f1b4Smrg GLuint min_index, 987117f1b4Smrg GLuint max_index, 997117f1b4Smrg vbo_draw_func draw, 1007117f1b4Smrg const struct split_limits *limits ); 1017117f1b4Smrg 1027117f1b4Smrg 1037117f1b4Smrg/* Helpers for dealing translating away non-zero min_index. 1047117f1b4Smrg */ 1057117f1b4SmrgGLboolean vbo_all_varyings_in_vbos( const struct gl_client_array *arrays[] ); 1067117f1b4Smrg 1077117f1b4Smrgvoid vbo_rebase_prims( GLcontext *ctx, 1087117f1b4Smrg const struct gl_client_array *arrays[], 1097117f1b4Smrg const struct _mesa_prim *prim, 1107117f1b4Smrg GLuint nr_prims, 1117117f1b4Smrg const struct _mesa_index_buffer *ib, 1127117f1b4Smrg GLuint min_index, 1137117f1b4Smrg GLuint max_index, 1147117f1b4Smrg vbo_draw_func draw ); 1157117f1b4Smrg 1167117f1b4Smrg 1177117f1b4Smrg#endif 118