Lines Matching refs:copy
8 * copy of this software and associated documentation files (the "Software"),
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
119 check_flush( struct copy_context *copy )
121 GLenum mode = copy->dstprim[copy->dstprim_nr].mode;
124 copy->dstelt_nr & 1) { /* see bug9962 */
128 if (copy->dstbuf_nr + 4 > copy->dstbuf_size)
131 if (copy->dstelt_nr + 4 > copy->dstelt_size)
174 flush( struct copy_context *copy )
176 struct gl_context *ctx = copy->ctx;
182 copy->dstib.count = copy->dstelt_nr;
185 dump_draw_info(copy->ctx,
186 copy->dstarray_ptr,
187 copy->dstprim,
188 copy->dstprim_nr,
189 ©->dstib,
191 copy->dstbuf_nr);
196 ctx->Array._DrawArrays = copy->dstarray_ptr;
199 copy->draw( ctx,
200 copy->dstprim,
201 copy->dstprim_nr,
202 ©->dstib,
205 copy->dstbuf_nr - 1,
213 copy->dstprim_nr = 0;
214 copy->dstelt_nr = 0;
215 copy->dstbuf_nr = 0;
216 copy->dstptr = copy->dstbuf;
221 copy->vert_cache[i].in = ~0;
229 begin( struct copy_context *copy, GLenum mode, GLboolean begin_flag )
231 struct _mesa_prim *prim = ©->dstprim[copy->dstprim_nr];
244 elt(struct copy_context *copy, GLuint elt_idx)
246 GLuint elt = copy->srcelt[elt_idx] + copy->prim->basevertex;
254 if (copy->vert_cache[slot].in != elt) {
255 GLubyte *csr = copy->dstptr;
258 /* printf(" --> emit to dstelt %d\n", copy->dstbuf_nr); */
260 for (i = 0; i < copy->nr_varying; i++) {
261 const struct gl_vertex_array *srcarray = copy->varying[i].array;
262 const GLubyte *srcptr = copy->varying[i].src_ptr + elt * srcarray->StrideB;
264 memcpy(csr, srcptr, copy->varying[i].size);
265 csr += copy->varying[i].size;
283 for(j = 0; j < copy->varying[i].size / 4; j++)
289 copy->vert_cache[slot].in = elt;
290 copy->vert_cache[slot].out = copy->dstbuf_nr++;
291 copy->dstptr += copy->vertex_size;
293 assert(csr == copy->dstptr);
294 assert(copy->dstptr == (copy->dstbuf +
295 copy->dstbuf_nr * copy->vertex_size));
300 /* printf(" --> emit %d\n", copy->vert_cache[slot].out); */
301 copy->dstelt[copy->dstelt_nr++] = copy->vert_cache[slot].out;
302 return check_flush(copy);
310 end( struct copy_context *copy, GLboolean end_flag )
312 struct _mesa_prim *prim = ©->dstprim[copy->dstprim_nr];
317 prim->count = copy->dstelt_nr - prim->start;
319 if (++copy->dstprim_nr == MAX_PRIM ||
320 check_flush(copy))
321 flush(copy);
326 replay_elts( struct copy_context *copy )
331 for (i = 0; i < copy->nr_prims; i++) {
332 const struct _mesa_prim *prim = ©->prim[i];
344 begin(copy, GL_LINE_STRIP, prim->begin && j == 0);
347 split = elt(copy, start + j);
355 (void)elt(copy, start + 0);
357 end(copy, prim->end);
363 end(copy, 0);
373 begin(copy, prim->mode, prim->begin && j == 0);
375 split = elt(copy, start+0);
378 split = elt(copy, start+j-1);
382 split = elt(copy, start+j);
384 end(copy, prim->end && j == prim->count);
400 begin(copy, prim->mode, prim->begin && j == 0);
404 split |= elt(copy, start+j);
410 split |= elt(copy, start+j);
412 end(copy, prim->end && j == prim->count);
425 if (copy->dstprim_nr)
426 flush(copy);
431 replay_init( struct copy_context *copy )
433 struct gl_context *ctx = copy->ctx;
441 copy->vertex_size = 0;
443 struct gl_buffer_object *vbo = copy->array[i]->BufferObj;
445 if (copy->array[i]->StrideB == 0) {
446 copy->dstarray_ptr[i] = copy->array[i];
449 GLuint j = copy->nr_varying++;
451 copy->varying[j].attr = i;
452 copy->varying[j].array = copy->array[i];
453 copy->varying[j].size = attr_size(copy->array[i]);
454 copy->vertex_size += attr_size(copy->array[i]);
461 copy->varying[j].src_ptr =
463 copy->array[i]->Ptr);
465 copy->dstarray_ptr[i] = ©->varying[j].dstarray;
473 if (_mesa_is_bufferobj(copy->ib->obj) &&
474 !_mesa_bufferobj_mapped(copy->ib->obj, MAP_INTERNAL))
475 ctx->Driver.MapBufferRange(ctx, 0, copy->ib->obj->Size, GL_MAP_READ_BIT,
476 copy->ib->obj, MAP_INTERNAL);
479 ADD_POINTERS(copy->ib->obj->Mappings[MAP_INTERNAL].Pointer,
480 copy->ib->ptr);
482 switch (copy->ib->type) {
484 copy->translated_elt_buf = malloc(sizeof(GLuint) * copy->ib->count);
485 copy->srcelt = copy->translated_elt_buf;
487 for (i = 0; i < copy->ib->count; i++)
488 copy->translated_elt_buf[i] = ((const GLubyte *)srcptr)[i];
492 copy->translated_elt_buf = malloc(sizeof(GLuint) * copy->ib->count);
493 copy->srcelt = copy->translated_elt_buf;
495 for (i = 0; i < copy->ib->count; i++)
496 copy->translated_elt_buf[i] = ((const GLushort *)srcptr)[i];
500 copy->translated_elt_buf = NULL;
501 copy->srcelt = (const GLuint *)srcptr;
507 if (copy->vertex_size * copy->limits->max_verts <= copy->limits->max_vb_size) {
508 copy->dstbuf_size = copy->limits->max_verts;
511 copy->dstbuf_size = copy->limits->max_vb_size / copy->vertex_size;
518 copy->dstbuf = malloc(copy->dstbuf_size * copy->vertex_size);
519 copy->dstptr = copy->dstbuf;
523 for (offset = 0, i = 0; i < copy->nr_varying; i++) {
524 const struct gl_vertex_array *src = copy->varying[i].array;
525 struct gl_vertex_array *dst = ©->varying[i].dstarray;
530 dst->StrideB = copy->vertex_size;
531 dst->Ptr = copy->dstbuf + offset;
538 offset += copy->varying[i].size;
543 copy->dstelt_size = MIN2(65536,
544 copy->ib->count * 2 + 3);
545 copy->dstelt_size = MIN2(copy->dstelt_size,
546 copy->limits->max_indices);
547 copy->dstelt = malloc(sizeof(GLuint) * copy->dstelt_size);
548 copy->dstelt_nr = 0;
553 copy->dstib.count = 0; /* duplicates dstelt_nr */
554 copy->dstib.type = GL_UNSIGNED_INT;
555 copy->dstib.obj = ctx->Shared->NullBufferObj;
556 copy->dstib.ptr = copy->dstelt;
564 replay_finish( struct copy_context *copy )
566 struct gl_context *ctx = copy->ctx;
571 free(copy->translated_elt_buf);
572 free(copy->dstbuf);
573 free(copy->dstelt);
577 for (i = 0; i < copy->nr_varying; i++) {
578 struct gl_buffer_object *vbo = copy->varying[i].array->BufferObj;
585 if (_mesa_is_bufferobj(copy->ib->obj) &&
586 _mesa_bufferobj_mapped(copy->ib->obj, MAP_INTERNAL)) {
587 ctx->Driver.UnmapBuffer(ctx, copy->ib->obj, MAP_INTERNAL);
603 struct copy_context copy;
617 memset(©, 0, sizeof(copy));
623 copy.ctx = ctx;
624 copy.array = arrays;
625 copy.prim = &prim[i];
626 copy.nr_prims = this_nr_prims;
627 copy.ib = ib;
628 copy.draw = draw;
629 copy.limits = limits;
634 copy.vert_cache[i].in = ~0;
636 replay_init(©);
637 replay_elts(©);
638 replay_finish(©);