Lines Matching full:copy
8 * copy of this software and associated documentation files (the "Software"),
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
109 * Shallow copy one vertex array to another.
126 check_flush(struct copy_context *copy) in check_flush() argument
128 GLenum mode = copy->dstprim[copy->dstprim_nr].mode; in check_flush()
131 copy->dstelt_nr & 1) { /* see bug9962 */ in check_flush()
135 if (copy->dstbuf_nr + 4 > copy->dstbuf_size) in check_flush()
138 if (copy->dstelt_nr + 4 > copy->dstelt_size) in check_flush()
182 flush(struct copy_context *copy) in flush() argument
184 struct gl_context *ctx = copy->ctx; in flush()
189 copy->dstib.count = copy->dstelt_nr; in flush()
192 dump_draw_info(copy->dstarray, in flush()
193 copy->dstprim, in flush()
194 copy->dstprim_nr, in flush()
195 ©->dstib); in flush()
200 copy->draw(ctx, in flush()
201 copy->dstarray, in flush()
202 copy->dstprim, in flush()
203 copy->dstprim_nr, in flush()
204 ©->dstib, in flush()
207 copy->dstbuf_nr - 1, in flush()
213 copy->dstprim_nr = 0; in flush()
214 copy->dstelt_nr = 0; in flush()
215 copy->dstbuf_nr = 0; in flush()
216 copy->dstptr = copy->dstbuf; in flush()
221 copy->vert_cache[i].in = ~0; in flush()
229 begin(struct copy_context *copy, GLenum mode, GLboolean begin_flag) in begin() argument
231 struct _mesa_prim *prim = ©->dstprim[copy->dstprim_nr]; in begin()
243 elt(struct copy_context *copy, GLuint elt_idx) in elt() argument
245 GLuint elt = copy->srcelt[elt_idx] + copy->prim->basevertex; in elt()
251 if (copy->vert_cache[slot].in != elt) { in elt()
252 GLubyte *csr = copy->dstptr; in elt()
255 for (i = 0; i < copy->nr_varying; i++) { in elt()
256 const struct tnl_vertex_array *srcarray = copy->varying[i].array; in elt()
260 = copy->varying[i].src_ptr + elt * srcbinding->Stride; in elt()
262 memcpy(csr, srcptr, copy->varying[i].size); in elt()
263 csr += copy->varying[i].size; in elt()
280 for (j = 0; j < copy->varying[i].size / 4; j++) in elt()
286 copy->vert_cache[slot].in = elt; in elt()
287 copy->vert_cache[slot].out = copy->dstbuf_nr++; in elt()
288 copy->dstptr += copy->vertex_size; in elt()
290 assert(csr == copy->dstptr); in elt()
291 assert(copy->dstptr == (copy->dstbuf + in elt()
292 copy->dstbuf_nr * copy->vertex_size)); in elt()
295 copy->dstelt[copy->dstelt_nr++] = copy->vert_cache[slot].out; in elt()
296 return check_flush(copy); in elt()
304 end(struct copy_context *copy, GLboolean end_flag) in end() argument
306 struct _mesa_prim *prim = ©->dstprim[copy->dstprim_nr]; in end()
309 prim->count = copy->dstelt_nr - prim->start; in end()
311 if (++copy->dstprim_nr == MAX_PRIM || check_flush(copy)) { in end()
312 flush(copy); in end()
318 replay_elts(struct copy_context *copy) in replay_elts() argument
323 for (i = 0; i < copy->nr_prims; i++) { in replay_elts()
324 const struct _mesa_prim *prim = ©->prim[i]; in replay_elts()
335 begin(copy, GL_LINE_STRIP, prim->begin && j == 0); in replay_elts()
338 split = elt(copy, start + j); in replay_elts()
346 (void)elt(copy, start + 0); in replay_elts()
348 end(copy, prim->end); in replay_elts()
354 end(copy, 0); in replay_elts()
364 begin(copy, prim->mode, prim->begin && j == 0); in replay_elts()
366 split = elt(copy, start+0); in replay_elts()
369 split = elt(copy, start+j-1); in replay_elts()
373 split = elt(copy, start+j); in replay_elts()
375 end(copy, prim->end && j == prim->count); in replay_elts()
391 begin(copy, prim->mode, prim->begin && j == 0); in replay_elts()
395 split |= elt(copy, start+j); in replay_elts()
401 split |= elt(copy, start+j); in replay_elts()
403 end(copy, prim->end && j == prim->count); in replay_elts()
416 if (copy->dstprim_nr) in replay_elts()
417 flush(copy); in replay_elts()
422 replay_init(struct copy_context *copy) in replay_init() argument
424 struct gl_context *ctx = copy->ctx; in replay_init()
432 copy->vertex_size = 0; in replay_init()
434 const struct tnl_vertex_array *array = ©->array[i]; in replay_init()
438 copy_vertex_array(©->dstarray[i], array); in replay_init()
444 GLuint j = copy->nr_varying++; in replay_init()
446 copy->varying[j].attr = i; in replay_init()
447 copy->varying[j].array = ©->array[i]; in replay_init()
448 copy->varying[j].size = attrib->Format._ElementSize; in replay_init()
449 copy->vertex_size += attrib->Format._ElementSize; in replay_init()
457 copy->varying[j].src_ptr = in replay_init()
460 copy->varying[j].src_ptr = ptr; in replay_init()
463 copy->dstarray[i].VertexAttrib = ©->varying[j].dstattribs; in replay_init()
464 copy->dstarray[i].BufferBinding = ©->varying[j].dstbinding; in replay_init()
472 if (copy->ib->obj) { in replay_init()
473 if (!_mesa_bufferobj_mapped(copy->ib->obj, MAP_INTERNAL)) in replay_init()
474 ctx->Driver.MapBufferRange(ctx, 0, copy->ib->obj->Size, GL_MAP_READ_BIT, in replay_init()
475 copy->ib->obj, MAP_INTERNAL); in replay_init()
478 ADD_POINTERS(copy->ib->obj->Mappings[MAP_INTERNAL].Pointer, in replay_init()
479 copy->ib->ptr); in replay_init()
481 srcptr = copy->ib->ptr; in replay_init()
483 switch (copy->ib->index_size_shift) { in replay_init()
485 copy->translated_elt_buf = malloc(sizeof(GLuint) * copy->ib->count); in replay_init()
486 copy->srcelt = copy->translated_elt_buf; in replay_init()
488 for (i = 0; i < copy->ib->count; i++) in replay_init()
489 copy->translated_elt_buf[i] = ((const GLubyte *)srcptr)[i]; in replay_init()
493 copy->translated_elt_buf = malloc(sizeof(GLuint) * copy->ib->count); in replay_init()
494 copy->srcelt = copy->translated_elt_buf; in replay_init()
496 for (i = 0; i < copy->ib->count; i++) in replay_init()
497 copy->translated_elt_buf[i] = ((const GLushort *)srcptr)[i]; in replay_init()
501 copy->translated_elt_buf = NULL; in replay_init()
502 copy->srcelt = (const GLuint *)srcptr; in replay_init()
508 if (copy->vertex_size * copy->limits->max_verts <= copy->limits->max_vb_size) { in replay_init()
509 copy->dstbuf_size = copy->limits->max_verts; in replay_init()
512 copy->dstbuf_size = copy->limits->max_vb_size / copy->vertex_size; in replay_init()
519 copy->dstbuf = malloc(copy->dstbuf_size * copy->vertex_size); in replay_init()
520 copy->dstptr = copy->dstbuf; in replay_init()
524 for (offset = 0, i = 0; i < copy->nr_varying; i++) { in replay_init()
525 const struct tnl_vertex_array *src = copy->varying[i].array; in replay_init()
527 struct tnl_vertex_array *dst = ©->dstarray[copy->varying[i].attr]; in replay_init()
528 struct gl_vertex_buffer_binding *dstbind = ©->varying[i].dstbinding; in replay_init()
529 struct gl_array_attributes *dstattr = ©->varying[i].dstattribs; in replay_init()
532 dstattr->Ptr = copy->dstbuf + offset; in replay_init()
533 dstbind->Stride = copy->vertex_size; in replay_init()
538 offset += copy->varying[i].size; in replay_init()
543 copy->dstelt_size = MIN2(65536, copy->ib->count * 2 + 3); in replay_init()
544 copy->dstelt_size = MIN2(copy->dstelt_size, copy->limits->max_indices); in replay_init()
545 copy->dstelt = malloc(sizeof(GLuint) * copy->dstelt_size); in replay_init()
546 copy->dstelt_nr = 0; in replay_init()
551 copy->dstib.count = 0; /* duplicates dstelt_nr */ in replay_init()
552 copy->dstib.index_size_shift = 2; in replay_init()
553 copy->dstib.obj = NULL; in replay_init()
554 copy->dstib.ptr = copy->dstelt; in replay_init()
562 replay_finish(struct copy_context *copy) in replay_finish() argument
564 struct gl_context *ctx = copy->ctx; in replay_finish()
568 free(copy->translated_elt_buf); in replay_finish()
569 free(copy->dstbuf); in replay_finish()
570 free(copy->dstelt); in replay_finish()
573 for (i = 0; i < copy->nr_varying; i++) { in replay_finish()
575 copy->varying[i].array->BufferBinding->BufferObj; in replay_finish()
581 if (copy->ib->obj && in replay_finish()
582 _mesa_bufferobj_mapped(copy->ib->obj, MAP_INTERNAL)) { in replay_finish()
583 ctx->Driver.UnmapBuffer(ctx, copy->ib->obj, MAP_INTERNAL); in replay_finish()
600 struct copy_context copy; in _tnl_split_copy() local
614 memset(©, 0, sizeof(copy)); in _tnl_split_copy()
620 copy.ctx = ctx; in _tnl_split_copy()
621 copy.array = arrays; in _tnl_split_copy()
622 copy.prim = &prim[i]; in _tnl_split_copy()
623 copy.nr_prims = this_nr_prims; in _tnl_split_copy()
624 copy.ib = ib; in _tnl_split_copy()
625 copy.draw = draw; in _tnl_split_copy()
626 copy.limits = limits; in _tnl_split_copy()
631 copy.vert_cache[i].in = ~0; in _tnl_split_copy()
633 replay_init(©); in _tnl_split_copy()
634 replay_elts(©); in _tnl_split_copy()
635 replay_finish(©); in _tnl_split_copy()