Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenvbo_split.c
Go to the documentation of this file.
00001 00002 /* 00003 * Mesa 3-D graphics library 00004 * Version: 6.5 00005 * 00006 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining a 00009 * copy of this software and associated documentation files (the "Software"), 00010 * to deal in the Software without restriction, including without limitation 00011 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00012 * and/or sell copies of the Software, and to permit persons to whom the 00013 * Software is furnished to do so, subject to the following conditions: 00014 * 00015 * The above copyright notice and this permission notice shall be included 00016 * in all copies or substantial portions of the Software. 00017 * 00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00019 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00020 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00021 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00022 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00023 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00024 * 00025 * Authors: 00026 * Keith Whitwell <keith@tungstengraphics.com> 00027 */ 00028 00029 /* Deal with hardware and/or swtnl maximums: 00030 * - maximum number of vertices in buffer 00031 * - maximum number of elements (maybe zero) 00032 * 00033 * The maximums may vary with opengl state (eg if a larger hardware 00034 * vertex is required in this state, the maximum number of vertices 00035 * may be smaller than in another state). 00036 * 00037 * We want buffer splitting to be a convenience function for the code 00038 * actually drawing the primitives rather than a system-wide maximum, 00039 * otherwise it is hard to avoid pessimism. 00040 * 00041 * For instance, if a driver has no hardware limits on vertex buffer 00042 * dimensions, it would not ordinarily want to split vbos. But if 00043 * there is an unexpected fallback, eg memory manager fails to upload 00044 * textures, it will want to pass the drawing commands onto swtnl, 00045 * which does have limitations. A convenience function allows swtnl 00046 * to split the drawing and vbos internally without imposing its 00047 * limitations on drivers which want to use it as a fallback path. 00048 */ 00049 00050 #include "main/glheader.h" 00051 #include "main/imports.h" 00052 #include "main/mtypes.h" 00053 00054 #include "vbo_split.h" 00055 #include "vbo.h" 00056 00057 /* True if a primitive can be split without copying of vertices, false 00058 * otherwise. 00059 */ 00060 GLboolean split_prim_inplace(GLenum mode, GLuint *first, GLuint *incr) 00061 { 00062 switch (mode) { 00063 case GL_POINTS: 00064 *first = 1; 00065 *incr = 1; 00066 return GL_TRUE; 00067 case GL_LINES: 00068 *first = 2; 00069 *incr = 2; 00070 return GL_TRUE; 00071 case GL_LINE_STRIP: 00072 *first = 2; 00073 *incr = 1; 00074 return GL_TRUE; 00075 case GL_TRIANGLES: 00076 *first = 3; 00077 *incr = 3; 00078 return GL_TRUE; 00079 case GL_TRIANGLE_STRIP: 00080 *first = 3; 00081 *incr = 1; 00082 return GL_TRUE; 00083 case GL_QUADS: 00084 *first = 4; 00085 *incr = 4; 00086 return GL_TRUE; 00087 case GL_QUAD_STRIP: 00088 *first = 4; 00089 *incr = 2; 00090 return GL_TRUE; 00091 default: 00092 *first = 0; 00093 *incr = 1; /* so that count % incr works */ 00094 return GL_FALSE; 00095 } 00096 } 00097 00098 00099 00100 void vbo_split_prims( GLcontext *ctx, 00101 const struct gl_client_array *arrays[], 00102 const struct _mesa_prim *prim, 00103 GLuint nr_prims, 00104 const struct _mesa_index_buffer *ib, 00105 GLuint min_index, 00106 GLuint max_index, 00107 vbo_draw_func draw, 00108 const struct split_limits *limits ) 00109 { 00110 00111 if (ib) { 00112 if (limits->max_indices == 0) { 00113 /* Could traverse the indices, re-emitting vertices in turn. 00114 * But it's hard to see why this case would be needed - for 00115 * software tnl, it is better to convert to non-indexed 00116 * rendering after transformation is complete, as is done in 00117 * the t_dd_rendertmp.h templates. Are there any devices 00118 * with hardware tnl that cannot do indexed rendering? 00119 * 00120 * For now, this path is disabled. 00121 */ 00122 assert(0); 00123 } 00124 else if (max_index - min_index >= limits->max_verts) { 00125 /* The vertex buffers are too large for hardware (or the 00126 * swtnl module). Traverse the indices, re-emitting vertices 00127 * in turn. Use a vertex cache to preserve some of the 00128 * sharing from the original index list. 00129 */ 00130 vbo_split_copy(ctx, arrays, prim, nr_prims, ib, 00131 draw, limits ); 00132 } 00133 else if (ib->count > limits->max_indices) { 00134 /* The index buffer is too large for hardware. Try to split 00135 * on whole-primitive boundaries, otherwise try to split the 00136 * individual primitives. 00137 */ 00138 vbo_split_inplace(ctx, arrays, prim, nr_prims, ib, 00139 min_index, max_index, draw, limits ); 00140 } 00141 else { 00142 /* Why were we called? */ 00143 assert(0); 00144 } 00145 } 00146 else { 00147 if (max_index - min_index >= limits->max_verts) { 00148 /* The vertex buffer is too large for hardware (or the swtnl 00149 * module). Try to split on whole-primitive boundaries, 00150 * otherwise try to split the individual primitives. 00151 */ 00152 vbo_split_inplace(ctx, arrays, prim, nr_prims, ib, 00153 min_index, max_index, draw, limits ); 00154 } 00155 else { 00156 /* Why were we called? */ 00157 assert(0); 00158 } 00159 } 00160 } 00161 Generated on Sat May 26 2012 04:19:38 for ReactOS by
1.7.6.1
|