Lines Matching full:exec

60 static void reset_attrfv( struct vbo_exec_context *exec );
67 static void vbo_exec_wrap_buffers( struct vbo_exec_context *exec ) in vbo_exec_wrap_buffers() argument
69 if (exec->vtx.prim_count == 0) { in vbo_exec_wrap_buffers()
70 exec->vtx.copied.nr = 0; in vbo_exec_wrap_buffers()
71 exec->vtx.vert_count = 0; in vbo_exec_wrap_buffers()
72 exec->vtx.buffer_ptr = exec->vtx.buffer_map; in vbo_exec_wrap_buffers()
75 GLuint last_begin = exec->vtx.prim[exec->vtx.prim_count-1].begin; in vbo_exec_wrap_buffers()
78 if (exec->ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { in vbo_exec_wrap_buffers()
79 GLint i = exec->vtx.prim_count - 1; in vbo_exec_wrap_buffers()
81 exec->vtx.prim[i].count = (exec->vtx.vert_count - in vbo_exec_wrap_buffers()
82 exec->vtx.prim[i].start); in vbo_exec_wrap_buffers()
85 last_count = exec->vtx.prim[exec->vtx.prim_count-1].count; in vbo_exec_wrap_buffers()
89 if (exec->vtx.vert_count) in vbo_exec_wrap_buffers()
90 vbo_exec_vtx_flush( exec, GL_FALSE ); in vbo_exec_wrap_buffers()
92 exec->vtx.prim_count = 0; in vbo_exec_wrap_buffers()
93 exec->vtx.copied.nr = 0; in vbo_exec_wrap_buffers()
98 assert(exec->vtx.prim_count == 0); in vbo_exec_wrap_buffers()
100 if (exec->ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { in vbo_exec_wrap_buffers()
101 exec->vtx.prim[0].mode = exec->ctx->Driver.CurrentExecPrimitive; in vbo_exec_wrap_buffers()
102 exec->vtx.prim[0].start = 0; in vbo_exec_wrap_buffers()
103 exec->vtx.prim[0].count = 0; in vbo_exec_wrap_buffers()
104 exec->vtx.prim_count++; in vbo_exec_wrap_buffers()
106 if (exec->vtx.copied.nr == last_count) in vbo_exec_wrap_buffers()
107 exec->vtx.prim[0].begin = last_begin; in vbo_exec_wrap_buffers()
117 void vbo_exec_vtx_wrap( struct vbo_exec_context *exec ) in vbo_exec_vtx_wrap() argument
119 GLfloat *data = exec->vtx.copied.buffer; in vbo_exec_vtx_wrap()
123 * to exec->vtx.copied. in vbo_exec_vtx_wrap()
125 vbo_exec_wrap_buffers( exec ); in vbo_exec_vtx_wrap()
127 if (!exec->vtx.buffer_ptr) { in vbo_exec_vtx_wrap()
134 assert(exec->vtx.max_vert - exec->vtx.vert_count > exec->vtx.copied.nr); in vbo_exec_vtx_wrap()
136 for (i = 0 ; i < exec->vtx.copied.nr ; i++) { in vbo_exec_vtx_wrap()
137 memcpy( exec->vtx.buffer_ptr, data, in vbo_exec_vtx_wrap()
138 exec->vtx.vertex_size * sizeof(GLfloat)); in vbo_exec_vtx_wrap()
139 exec->vtx.buffer_ptr += exec->vtx.vertex_size; in vbo_exec_vtx_wrap()
140 data += exec->vtx.vertex_size; in vbo_exec_vtx_wrap()
141 exec->vtx.vert_count++; in vbo_exec_vtx_wrap()
144 exec->vtx.copied.nr = 0; in vbo_exec_vtx_wrap()
151 static void vbo_exec_copy_to_current( struct vbo_exec_context *exec ) in vbo_exec_copy_to_current() argument
153 struct gl_context *ctx = exec->ctx; in vbo_exec_copy_to_current()
158 if (exec->vtx.attrsz[i]) { in vbo_exec_copy_to_current()
159 /* Note: the exec->vtx.current[i] pointers point into the in vbo_exec_copy_to_current()
166 exec->vtx.attrsz[i], in vbo_exec_copy_to_current()
167 exec->vtx.attrptr[i], in vbo_exec_copy_to_current()
168 exec->vtx.attrtype[i]); in vbo_exec_copy_to_current()
170 if (exec->vtx.attrtype[i] != vbo->currval[i].Type || in vbo_exec_copy_to_current()
179 vbo->currval[i].Size = exec->vtx.attrsz[i]; in vbo_exec_copy_to_current()
181 vbo->currval[i].Type = exec->vtx.attrtype[i]; in vbo_exec_copy_to_current()
183 vbo_attrtype_to_integer_flag(exec->vtx.attrtype[i]); in vbo_exec_copy_to_current()
200 exec->vtx.attrsz[VBO_ATTRIB_COLOR0]) { in vbo_exec_copy_to_current()
211 vbo_exec_copy_from_current(struct vbo_exec_context *exec) in vbo_exec_copy_from_current() argument
213 struct gl_context *ctx = exec->ctx; in vbo_exec_copy_from_current()
219 switch (exec->vtx.attrsz[i]) { in vbo_exec_copy_from_current()
220 case 4: exec->vtx.attrptr[i][3] = current[3]; in vbo_exec_copy_from_current()
221 case 3: exec->vtx.attrptr[i][2] = current[2]; in vbo_exec_copy_from_current()
222 case 2: exec->vtx.attrptr[i][1] = current[1]; in vbo_exec_copy_from_current()
223 case 1: exec->vtx.attrptr[i][0] = current[0]; in vbo_exec_copy_from_current()
238 vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, in vbo_exec_wrap_upgrade_vertex() argument
241 struct gl_context *ctx = exec->ctx; in vbo_exec_wrap_upgrade_vertex()
243 const GLint lastcount = exec->vtx.vert_count; in vbo_exec_wrap_upgrade_vertex()
245 const GLuint old_vtx_size = exec->vtx.vertex_size; /* floats per vertex */ in vbo_exec_wrap_upgrade_vertex()
246 const GLuint oldSize = exec->vtx.attrsz[attr]; in vbo_exec_wrap_upgrade_vertex()
250 * to exec->vtx.copied. in vbo_exec_wrap_upgrade_vertex()
252 vbo_exec_wrap_buffers( exec ); in vbo_exec_wrap_upgrade_vertex()
254 if (unlikely(exec->vtx.copied.nr)) { in vbo_exec_wrap_upgrade_vertex()
259 memcpy(old_attrptr, exec->vtx.attrptr, sizeof(old_attrptr)); in vbo_exec_wrap_upgrade_vertex()
267 vbo_exec_copy_to_current( exec ); in vbo_exec_wrap_upgrade_vertex()
274 !oldSize && lastcount > 8 && exec->vtx.vertex_size) { in vbo_exec_wrap_upgrade_vertex()
275 vbo_exec_copy_to_current( exec ); in vbo_exec_wrap_upgrade_vertex()
276 reset_attrfv( exec ); in vbo_exec_wrap_upgrade_vertex()
281 exec->vtx.attrsz[attr] = newSize; in vbo_exec_wrap_upgrade_vertex()
282 exec->vtx.vertex_size += newSize - oldSize; in vbo_exec_wrap_upgrade_vertex()
283 exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / in vbo_exec_wrap_upgrade_vertex()
284 (exec->vtx.vertex_size * sizeof(GLfloat))); in vbo_exec_wrap_upgrade_vertex()
285 exec->vtx.vert_count = 0; in vbo_exec_wrap_upgrade_vertex()
286 exec->vtx.buffer_ptr = exec->vtx.buffer_map; in vbo_exec_wrap_upgrade_vertex()
291 GLfloat *tmp = exec->vtx.vertex; in vbo_exec_wrap_upgrade_vertex()
294 if (exec->vtx.attrsz[i]) { in vbo_exec_wrap_upgrade_vertex()
295 exec->vtx.attrptr[i] = tmp; in vbo_exec_wrap_upgrade_vertex()
296 tmp += exec->vtx.attrsz[i]; in vbo_exec_wrap_upgrade_vertex()
299 exec->vtx.attrptr[i] = NULL; /* will not be dereferenced */ in vbo_exec_wrap_upgrade_vertex()
305 vbo_exec_copy_from_current( exec ); in vbo_exec_wrap_upgrade_vertex()
309 exec->vtx.attrptr[attr] = exec->vtx.vertex + in vbo_exec_wrap_upgrade_vertex()
310 exec->vtx.vertex_size - newSize; in vbo_exec_wrap_upgrade_vertex()
318 if (unlikely(exec->vtx.copied.nr)) { in vbo_exec_wrap_upgrade_vertex()
319 GLfloat *data = exec->vtx.copied.buffer; in vbo_exec_wrap_upgrade_vertex()
320 GLfloat *dest = exec->vtx.buffer_ptr; in vbo_exec_wrap_upgrade_vertex()
323 assert(exec->vtx.buffer_ptr == exec->vtx.buffer_map); in vbo_exec_wrap_upgrade_vertex()
325 for (i = 0 ; i < exec->vtx.copied.nr ; i++) { in vbo_exec_wrap_upgrade_vertex()
327 GLuint sz = exec->vtx.attrsz[j]; in vbo_exec_wrap_upgrade_vertex()
330 GLint old_offset = old_attrptr[j] - exec->vtx.vertex; in vbo_exec_wrap_upgrade_vertex()
331 GLint new_offset = exec->vtx.attrptr[j] - exec->vtx.vertex; in vbo_exec_wrap_upgrade_vertex()
338 exec->vtx.attrtype[j]); in vbo_exec_wrap_upgrade_vertex()
352 dest += exec->vtx.vertex_size; in vbo_exec_wrap_upgrade_vertex()
355 exec->vtx.buffer_ptr = dest; in vbo_exec_wrap_upgrade_vertex()
356 exec->vtx.vert_count += exec->vtx.copied.nr; in vbo_exec_wrap_upgrade_vertex()
357 exec->vtx.copied.nr = 0; in vbo_exec_wrap_upgrade_vertex()
370 struct vbo_exec_context *exec = &vbo_context(ctx)->exec; in vbo_exec_fixup_vertex() local
372 if (newSize > exec->vtx.attrsz[attr]) { in vbo_exec_fixup_vertex()
376 vbo_exec_wrap_upgrade_vertex( exec, attr, newSize ); in vbo_exec_fixup_vertex()
378 else if (newSize < exec->vtx.active_sz[attr]) { in vbo_exec_fixup_vertex()
381 vbo_get_default_vals_as_float(exec->vtx.attrtype[attr]); in vbo_exec_fixup_vertex()
386 for (i = newSize; i <= exec->vtx.attrsz[attr]; i++) in vbo_exec_fixup_vertex()
387 exec->vtx.attrptr[attr][i-1] = id[i-1]; in vbo_exec_fixup_vertex()
390 exec->vtx.active_sz[attr] = newSize; in vbo_exec_fixup_vertex()
407 struct vbo_exec_context *exec = &vbo_context(ctx)->exec; \
412 if (unlikely(exec->vtx.active_sz[A] != N)) \
416 GLfloat *dest = exec->vtx.attrptr[A]; \
421 exec->vtx.attrtype[A] = T; \
428 for (i = 0; i < exec->vtx.vertex_size; i++) \
429 exec->vtx.buffer_ptr[i] = exec->vtx.vertex[i]; \
431 exec->vtx.buffer_ptr += exec->vtx.vertex_size; \
437 if (++exec->vtx.vert_count >= exec->vtx.max_vert) \
438 vbo_exec_vtx_wrap( exec ); \
553 vbo_exec_FlushVertices_internal(struct vbo_exec_context *exec, GLboolean unmap) in vbo_exec_FlushVertices_internal() argument
555 if (exec->vtx.vert_count || unmap) { in vbo_exec_FlushVertices_internal()
556 vbo_exec_vtx_flush( exec, unmap ); in vbo_exec_FlushVertices_internal()
559 if (exec->vtx.vertex_size) { in vbo_exec_FlushVertices_internal()
560 vbo_exec_copy_to_current( exec ); in vbo_exec_FlushVertices_internal()
561 reset_attrfv( exec ); in vbo_exec_FlushVertices_internal()
574 struct vbo_exec_context *exec = &vbo_context(ctx)->exec; in vbo_exec_EvalCoord1f() local
578 if (exec->eval.recalculate_maps) in vbo_exec_EvalCoord1f()
579 vbo_exec_eval_update( exec ); in vbo_exec_EvalCoord1f()
582 if (exec->eval.map1[i].map) in vbo_exec_EvalCoord1f()
583 if (exec->vtx.active_sz[i] != exec->eval.map1[i].sz) in vbo_exec_EvalCoord1f()
584 vbo_exec_fixup_vertex( ctx, i, exec->eval.map1[i].sz ); in vbo_exec_EvalCoord1f()
589 memcpy( exec->vtx.copied.buffer, exec->vtx.vertex, in vbo_exec_EvalCoord1f()
590 exec->vtx.vertex_size * sizeof(GLfloat)); in vbo_exec_EvalCoord1f()
592 vbo_exec_do_EvalCoord1f( exec, u ); in vbo_exec_EvalCoord1f()
594 memcpy( exec->vtx.vertex, exec->vtx.copied.buffer, in vbo_exec_EvalCoord1f()
595 exec->vtx.vertex_size * sizeof(GLfloat)); in vbo_exec_EvalCoord1f()
601 struct vbo_exec_context *exec = &vbo_context(ctx)->exec; in vbo_exec_EvalCoord2f() local
605 if (exec->eval.recalculate_maps) in vbo_exec_EvalCoord2f()
606 vbo_exec_eval_update( exec ); in vbo_exec_EvalCoord2f()
609 if (exec->eval.map2[i].map) in vbo_exec_EvalCoord2f()
610 if (exec->vtx.active_sz[i] != exec->eval.map2[i].sz) in vbo_exec_EvalCoord2f()
611 vbo_exec_fixup_vertex( ctx, i, exec->eval.map2[i].sz ); in vbo_exec_EvalCoord2f()
615 if (exec->vtx.active_sz[VBO_ATTRIB_NORMAL] != 3) in vbo_exec_EvalCoord2f()
619 memcpy( exec->vtx.copied.buffer, exec->vtx.vertex, in vbo_exec_EvalCoord2f()
620 exec->vtx.vertex_size * sizeof(GLfloat)); in vbo_exec_EvalCoord2f()
622 vbo_exec_do_EvalCoord2f( exec, u, v ); in vbo_exec_EvalCoord2f()
624 memcpy( exec->vtx.vertex, exec->vtx.copied.buffer, in vbo_exec_EvalCoord2f()
625 exec->vtx.vertex_size * sizeof(GLfloat)); in vbo_exec_EvalCoord2f()
808 struct vbo_exec_context *exec = &vbo_context(ctx)->exec; in vbo_exec_Begin() local
823 CALL_Begin(ctx->Exec, (mode)); in vbo_exec_Begin()
834 if (exec->vtx.vertex_size && !exec->vtx.attrsz[0]) in vbo_exec_Begin()
835 vbo_exec_FlushVertices_internal(exec, GL_FALSE); in vbo_exec_Begin()
837 i = exec->vtx.prim_count++; in vbo_exec_Begin()
838 exec->vtx.prim[i].mode = mode; in vbo_exec_Begin()
839 exec->vtx.prim[i].begin = 1; in vbo_exec_Begin()
840 exec->vtx.prim[i].end = 0; in vbo_exec_Begin()
841 exec->vtx.prim[i].indexed = 0; in vbo_exec_Begin()
842 exec->vtx.prim[i].weak = 0; in vbo_exec_Begin()
843 exec->vtx.prim[i].pad = 0; in vbo_exec_Begin()
844 exec->vtx.prim[i].start = exec->vtx.vert_count; in vbo_exec_Begin()
845 exec->vtx.prim[i].count = 0; in vbo_exec_Begin()
846 exec->vtx.prim[i].num_instances = 1; in vbo_exec_Begin()
847 exec->vtx.prim[i].base_instance = 0; in vbo_exec_Begin()
865 struct vbo_exec_context *exec = &vbo_context(ctx)->exec; in vbo_exec_End() local
867 if (exec->vtx.prim_count > 0) { in vbo_exec_End()
869 int idx = exec->vtx.vert_count; in vbo_exec_End()
870 int i = exec->vtx.prim_count - 1; in vbo_exec_End()
872 exec->vtx.prim[i].end = 1; in vbo_exec_End()
873 exec->vtx.prim[i].count = idx - exec->vtx.prim[i].start; in vbo_exec_End()
878 if (exec->vtx.prim_count == VBO_MAX_PRIM) in vbo_exec_End()
879 vbo_exec_vtx_flush( exec, GL_FALSE ); in vbo_exec_End()
912 static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) in vbo_exec_vtxfmt_init() argument
914 struct gl_context *ctx = exec->ctx; in vbo_exec_vtxfmt_init()
915 GLvertexformat *vfmt = &exec->vtxfmt; in vbo_exec_vtxfmt_init()
1067 static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) in vbo_exec_vtxfmt_init() argument
1140 struct vbo_exec_context *exec = &vbo_context(ctx)->exec; in vbo_use_buffer_objects() local
1150 assert(exec->vtx.bufferobj == ctx->Shared->NullBufferObj); in vbo_use_buffer_objects()
1151 if (exec->vtx.buffer_map) { in vbo_use_buffer_objects()
1152 _mesa_align_free(exec->vtx.buffer_map); in vbo_use_buffer_objects()
1153 exec->vtx.buffer_map = NULL; in vbo_use_buffer_objects()
1154 exec->vtx.buffer_ptr = NULL; in vbo_use_buffer_objects()
1158 _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL); in vbo_use_buffer_objects()
1159 exec->vtx.bufferobj = ctx->Driver.NewBufferObject(ctx, bufName, target); in vbo_use_buffer_objects()
1160 if (!ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj)) { in vbo_use_buffer_objects()
1175 struct vbo_exec_context *exec = &vbo_context(ctx)->exec; in vbo_always_unmap_buffers() local
1176 exec->begin_vertices_flags |= FLUSH_STORED_VERTICES; in vbo_always_unmap_buffers()
1180 void vbo_exec_vtx_init( struct vbo_exec_context *exec ) in vbo_exec_vtx_init() argument
1182 struct gl_context *ctx = exec->ctx; in vbo_exec_vtx_init()
1191 &exec->vtx.bufferobj, in vbo_exec_vtx_init()
1194 ASSERT(!exec->vtx.buffer_map); in vbo_exec_vtx_init()
1195 exec->vtx.buffer_map = (GLfloat *)_mesa_align_malloc(VBO_VERT_BUFFER_SIZE, 64); in vbo_exec_vtx_init()
1196 exec->vtx.buffer_ptr = exec->vtx.buffer_map; in vbo_exec_vtx_init()
1198 vbo_exec_vtxfmt_init( exec ); in vbo_exec_vtx_init()
1199 _mesa_noop_vtxfmt_init(&exec->vtxfmt_noop); in vbo_exec_vtx_init()
1203 _mesa_install_exec_vtxfmt( ctx, &exec->vtxfmt ); in vbo_exec_vtx_init()
1206 ASSERT(i < Elements(exec->vtx.attrsz)); in vbo_exec_vtx_init()
1207 exec->vtx.attrsz[i] = 0; in vbo_exec_vtx_init()
1208 ASSERT(i < Elements(exec->vtx.attrtype)); in vbo_exec_vtx_init()
1209 exec->vtx.attrtype[i] = GL_FLOAT; in vbo_exec_vtx_init()
1210 ASSERT(i < Elements(exec->vtx.active_sz)); in vbo_exec_vtx_init()
1211 exec->vtx.active_sz[i] = 0; in vbo_exec_vtx_init()
1214 ASSERT(i < Elements(exec->vtx.inputs)); in vbo_exec_vtx_init()
1215 ASSERT(i < Elements(exec->vtx.arrays)); in vbo_exec_vtx_init()
1216 exec->vtx.inputs[i] = &exec->vtx.arrays[i]; in vbo_exec_vtx_init()
1220 struct gl_client_array *arrays = exec->vtx.arrays; in vbo_exec_vtx_init()
1246 exec->vtx.vertex_size = 0; in vbo_exec_vtx_init()
1248 exec->begin_vertices_flags = FLUSH_UPDATE_CURRENT; in vbo_exec_vtx_init()
1252 void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) in vbo_exec_vtx_destroy() argument
1255 struct gl_context *ctx = exec->ctx; in vbo_exec_vtx_destroy()
1260 if (exec->vtx.buffer_map) { in vbo_exec_vtx_destroy()
1261 ASSERT(exec->vtx.bufferobj->Name == 0 || in vbo_exec_vtx_destroy()
1262 exec->vtx.bufferobj->Name == IMM_BUFFER_NAME); in vbo_exec_vtx_destroy()
1263 if (exec->vtx.bufferobj->Name == 0) { in vbo_exec_vtx_destroy()
1264 _mesa_align_free(exec->vtx.buffer_map); in vbo_exec_vtx_destroy()
1265 exec->vtx.buffer_map = NULL; in vbo_exec_vtx_destroy()
1266 exec->vtx.buffer_ptr = NULL; in vbo_exec_vtx_destroy()
1272 for (i = 0; i < Elements(exec->vtx.arrays); i++) { in vbo_exec_vtx_destroy()
1274 &exec->vtx.arrays[i].BufferObj, in vbo_exec_vtx_destroy()
1280 if (_mesa_bufferobj_mapped(exec->vtx.bufferobj)) { in vbo_exec_vtx_destroy()
1281 ctx->Driver.UnmapBuffer(ctx, exec->vtx.bufferobj); in vbo_exec_vtx_destroy()
1283 _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL); in vbo_exec_vtx_destroy()
1292 struct vbo_exec_context *exec = &vbo_context(ctx)->exec; in vbo_exec_BeginVertices() local
1294 vbo_exec_vtx_map( exec ); in vbo_exec_BeginVertices()
1297 assert(exec->begin_vertices_flags); in vbo_exec_BeginVertices()
1299 ctx->Driver.NeedFlush |= exec->begin_vertices_flags; in vbo_exec_BeginVertices()
1309 struct vbo_exec_context *exec = &vbo_context(ctx)->exec; in vbo_exec_FlushVertices() local
1313 exec->flush_call_depth++; in vbo_exec_FlushVertices()
1314 assert(exec->flush_call_depth == 1); in vbo_exec_FlushVertices()
1320 exec->flush_call_depth--; in vbo_exec_FlushVertices()
1321 assert(exec->flush_call_depth == 0); in vbo_exec_FlushVertices()
1327 vbo_exec_FlushVertices_internal(exec, GL_TRUE); in vbo_exec_FlushVertices()
1334 exec->flush_call_depth--; in vbo_exec_FlushVertices()
1335 assert(exec->flush_call_depth == 0); in vbo_exec_FlushVertices()
1340 static void reset_attrfv( struct vbo_exec_context *exec ) in reset_attrfv() argument
1345 exec->vtx.attrsz[i] = 0; in reset_attrfv()
1346 exec->vtx.attrtype[i] = GL_FLOAT; in reset_attrfv()
1347 exec->vtx.active_sz[i] = 0; in reset_attrfv()
1350 exec->vtx.vertex_size = 0; in reset_attrfv()