Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenvbo_save_loopback.c
Go to the documentation of this file.
00001 /************************************************************************** 00002 * 00003 * Copyright 2005 Tungsten Graphics, Inc., Cedar Park, Texas. 00004 * All Rights Reserved. 00005 * 00006 * Permission is hereby granted, free of charge, to any person obtaining a 00007 * copy of this software and associated documentation files (the 00008 * "Software"), to deal in the Software without restriction, including 00009 * without limitation the rights to use, copy, modify, merge, publish, 00010 * distribute, sub license, and/or sell copies of the Software, and to 00011 * permit persons to whom the Software is furnished to do so, subject to 00012 * the following conditions: 00013 * 00014 * The above copyright notice and this permission notice (including the 00015 * next paragraph) shall be included in all copies or substantial portions 00016 * 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 00020 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 00021 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 00022 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 00023 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 00024 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00025 * 00026 **************************************************************************/ 00027 00028 #include "main/context.h" 00029 #include "main/glheader.h" 00030 #include "main/enums.h" 00031 #include "main/imports.h" 00032 #include "main/macros.h" 00033 #include "main/mtypes.h" 00034 #include "glapi/dispatch.h" 00035 #include "glapi/glapi.h" 00036 00037 #include "vbo_context.h" 00038 00039 00040 00041 typedef void (*attr_func)( GLcontext *ctx, GLint target, const GLfloat * ); 00042 00043 00044 /* This file makes heavy use of the aliasing of NV vertex attributes 00045 * with the legacy attributes, and also with ARB and Material 00046 * attributes as currently implemented. 00047 */ 00048 static void VertexAttrib1fvNV(GLcontext *ctx, GLint target, const GLfloat *v) 00049 { 00050 CALL_VertexAttrib1fvNV(ctx->Exec, (target, v)); 00051 } 00052 00053 static void VertexAttrib2fvNV(GLcontext *ctx, GLint target, const GLfloat *v) 00054 { 00055 CALL_VertexAttrib2fvNV(ctx->Exec, (target, v)); 00056 } 00057 00058 static void VertexAttrib3fvNV(GLcontext *ctx, GLint target, const GLfloat *v) 00059 { 00060 CALL_VertexAttrib3fvNV(ctx->Exec, (target, v)); 00061 } 00062 00063 static void VertexAttrib4fvNV(GLcontext *ctx, GLint target, const GLfloat *v) 00064 { 00065 CALL_VertexAttrib4fvNV(ctx->Exec, (target, v)); 00066 } 00067 00068 static attr_func vert_attrfunc[4] = { 00069 VertexAttrib1fvNV, 00070 VertexAttrib2fvNV, 00071 VertexAttrib3fvNV, 00072 VertexAttrib4fvNV 00073 }; 00074 00075 struct loopback_attr { 00076 GLint target; 00077 GLint sz; 00078 attr_func func; 00079 }; 00080 00081 /* Don't emit ends and begins on wrapped primitives. Don't replay 00082 * wrapped vertices. If we get here, it's probably because the the 00083 * precalculated wrapping is wrong. 00084 */ 00085 static void loopback_prim( GLcontext *ctx, 00086 const GLfloat *buffer, 00087 const struct _mesa_prim *prim, 00088 GLuint wrap_count, 00089 GLuint vertex_size, 00090 const struct loopback_attr *la, GLuint nr ) 00091 { 00092 GLint start = prim->start; 00093 GLint end = start + prim->count; 00094 const GLfloat *data; 00095 GLint j; 00096 GLuint k; 00097 00098 if (0) 00099 _mesa_printf("loopback prim %s(%s,%s) verts %d..%d\n", 00100 _mesa_lookup_enum_by_nr(prim->mode), 00101 prim->begin ? "begin" : "..", 00102 prim->end ? "end" : "..", 00103 start, 00104 end); 00105 00106 if (prim->begin) { 00107 CALL_Begin(GET_DISPATCH(), ( prim->mode )); 00108 } 00109 else { 00110 assert(start == 0); 00111 start += wrap_count; 00112 } 00113 00114 data = buffer + start * vertex_size; 00115 00116 for (j = start ; j < end ; j++) { 00117 const GLfloat *tmp = data + la[0].sz; 00118 00119 for (k = 1 ; k < nr ; k++) { 00120 la[k].func( ctx, la[k].target, tmp ); 00121 tmp += la[k].sz; 00122 } 00123 00124 /* Fire the vertex 00125 */ 00126 la[0].func( ctx, VBO_ATTRIB_POS, data ); 00127 data = tmp; 00128 } 00129 00130 if (prim->end) { 00131 CALL_End(GET_DISPATCH(), ()); 00132 } 00133 } 00134 00135 /* Primitives generated by DrawArrays/DrawElements/Rectf may be 00136 * caught here. If there is no primitive in progress, execute them 00137 * normally, otherwise need to track and discard the generated 00138 * primitives. 00139 */ 00140 static void loopback_weak_prim( GLcontext *ctx, 00141 const struct _mesa_prim *prim ) 00142 { 00143 /* Use the prim_weak flag to ensure that if this primitive 00144 * wraps, we don't mistake future vertex_lists for part of the 00145 * surrounding primitive. 00146 * 00147 * While this flag is set, we are simply disposing of data 00148 * generated by an operation now known to be a noop. 00149 */ 00150 if (prim->begin) 00151 ctx->Driver.CurrentExecPrimitive |= VBO_SAVE_PRIM_WEAK; 00152 if (prim->end) 00153 ctx->Driver.CurrentExecPrimitive &= ~VBO_SAVE_PRIM_WEAK; 00154 } 00155 00156 00157 void vbo_loopback_vertex_list( GLcontext *ctx, 00158 const GLfloat *buffer, 00159 const GLubyte *attrsz, 00160 const struct _mesa_prim *prim, 00161 GLuint prim_count, 00162 GLuint wrap_count, 00163 GLuint vertex_size) 00164 { 00165 struct loopback_attr la[VBO_ATTRIB_MAX]; 00166 GLuint i, nr = 0; 00167 00168 /* All Legacy, NV, ARB and Material attributes are routed through 00169 * the NV attributes entrypoints: 00170 */ 00171 for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) { 00172 if (attrsz[i]) { 00173 la[nr].target = i; 00174 la[nr].sz = attrsz[i]; 00175 la[nr].func = vert_attrfunc[attrsz[i]-1]; 00176 nr++; 00177 } 00178 } 00179 00180 for (i = 0 ; i < prim_count ; i++) { 00181 if ((prim[i].mode & VBO_SAVE_PRIM_WEAK) && 00182 (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END)) 00183 { 00184 loopback_weak_prim( ctx, &prim[i] ); 00185 } 00186 else 00187 { 00188 loopback_prim( ctx, buffer, &prim[i], wrap_count, vertex_size, la, nr ); 00189 } 00190 } 00191 } Generated on Sun May 27 2012 04:20:48 for ReactOS by
1.7.6.1
|