Lines Matching refs:copy
9 * copy of this software and associated documentation files (the "Software"),
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
117 check_flush( struct copy_context *copy )
119 GLenum mode = copy->dstprim[copy->dstprim_nr].mode;
122 copy->dstelt_nr & 1) { /* see bug9962 */
126 if (copy->dstbuf_nr + 4 > copy->dstbuf_size)
129 if (copy->dstelt_nr + 4 > copy->dstelt_size)
172 flush( struct copy_context *copy )
174 struct gl_context *ctx = copy->ctx;
180 copy->dstib.count = copy->dstelt_nr;
183 dump_draw_info(copy->ctx,
184 copy->dstarray_ptr,
185 copy->dstprim,
186 copy->dstprim_nr,
187 ©->dstib,
189 copy->dstbuf_nr);
194 ctx->Array._DrawArrays = copy->dstarray_ptr;
197 copy->draw( ctx,
198 copy->dstprim,
199 copy->dstprim_nr,
200 ©->dstib,
203 copy->dstbuf_nr - 1,
211 copy->dstprim_nr = 0;
212 copy->dstelt_nr = 0;
213 copy->dstbuf_nr = 0;
214 copy->dstptr = copy->dstbuf;
219 copy->vert_cache[i].in = ~0;
227 begin( struct copy_context *copy, GLenum mode, GLboolean begin_flag )
229 struct _mesa_prim *prim = ©->dstprim[copy->dstprim_nr];
242 elt(struct copy_context *copy, GLuint elt_idx)
244 GLuint elt = copy->srcelt[elt_idx];
252 if (copy->vert_cache[slot].in != elt) {
253 GLubyte *csr = copy->dstptr;
256 /* printf(" --> emit to dstelt %d\n", copy->dstbuf_nr); */
258 for (i = 0; i < copy->nr_varying; i++) {
259 const struct gl_client_array *srcarray = copy->varying[i].array;
260 const GLubyte *srcptr = copy->varying[i].src_ptr + elt * srcarray->StrideB;
262 memcpy(csr, srcptr, copy->varying[i].size);
263 csr += copy->varying[i].size;
281 for(j = 0; j < copy->varying[i].size / 4; j++)
287 copy->vert_cache[slot].in = elt;
288 copy->vert_cache[slot].out = copy->dstbuf_nr++;
289 copy->dstptr += copy->vertex_size;
291 assert(csr == copy->dstptr);
292 assert(copy->dstptr == (copy->dstbuf +
293 copy->dstbuf_nr * copy->vertex_size));
298 /* printf(" --> emit %d\n", copy->vert_cache[slot].out); */
299 copy->dstelt[copy->dstelt_nr++] = copy->vert_cache[slot].out;
300 return check_flush(copy);
308 end( struct copy_context *copy, GLboolean end_flag )
310 struct _mesa_prim *prim = ©->dstprim[copy->dstprim_nr];
315 prim->count = copy->dstelt_nr - prim->start;
317 if (++copy->dstprim_nr == MAX_PRIM ||
318 check_flush(copy))
319 flush(copy);
324 replay_elts( struct copy_context *copy )
329 for (i = 0; i < copy->nr_prims; i++) {
330 const struct _mesa_prim *prim = ©->prim[i];
342 begin(copy, GL_LINE_STRIP, prim->begin && j == 0);
345 split = elt(copy, start + j);
353 (void)elt(copy, start + 0);
355 end(copy, prim->end);
361 end(copy, 0);
371 begin(copy, prim->mode, prim->begin && j == 0);
373 split = elt(copy, start+0);
376 split = elt(copy, start+j-1);
380 split = elt(copy, start+j);
382 end(copy, prim->end && j == prim->count);
398 begin(copy, prim->mode, prim->begin && j == 0);
402 split |= elt(copy, start+j);
408 split |= elt(copy, start+j);
410 end(copy, prim->end && j == prim->count);
423 if (copy->dstprim_nr)
424 flush(copy);
429 replay_init( struct copy_context *copy )
431 struct gl_context *ctx = copy->ctx;
439 copy->vertex_size = 0;
441 struct gl_buffer_object *vbo = copy->array[i]->BufferObj;
443 if (copy->array[i]->StrideB == 0) {
444 copy->dstarray_ptr[i] = copy->array[i];
447 GLuint j = copy->nr_varying++;
449 copy->varying[j].attr = i;
450 copy->varying[j].array = copy->array[i];
451 copy->varying[j].size = attr_size(copy->array[i]);
452 copy->vertex_size += attr_size(copy->array[i]);
457 copy->varying[j].src_ptr = ADD_POINTERS(vbo->Pointer,
458 copy->array[i]->Ptr);
460 copy->dstarray_ptr[i] = ©->varying[j].dstarray;
468 if (_mesa_is_bufferobj(copy->ib->obj) &&
469 !_mesa_bufferobj_mapped(copy->ib->obj))
470 ctx->Driver.MapBufferRange(ctx, 0, copy->ib->obj->Size, GL_MAP_READ_BIT,
471 copy->ib->obj);
473 srcptr = (const GLubyte *) ADD_POINTERS(copy->ib->obj->Pointer,
474 copy->ib->ptr);
476 switch (copy->ib->type) {
478 copy->translated_elt_buf = malloc(sizeof(GLuint) * copy->ib->count);
479 copy->srcelt = copy->translated_elt_buf;
481 for (i = 0; i < copy->ib->count; i++)
482 copy->translated_elt_buf[i] = ((const GLubyte *)srcptr)[i];
486 copy->translated_elt_buf = malloc(sizeof(GLuint) * copy->ib->count);
487 copy->srcelt = copy->translated_elt_buf;
489 for (i = 0; i < copy->ib->count; i++)
490 copy->translated_elt_buf[i] = ((const GLushort *)srcptr)[i];
494 copy->translated_elt_buf = NULL;
495 copy->srcelt = (const GLuint *)srcptr;
501 if (copy->vertex_size * copy->limits->max_verts <= copy->limits->max_vb_size) {
502 copy->dstbuf_size = copy->limits->max_verts;
505 copy->dstbuf_size = copy->limits->max_vb_size / copy->vertex_size;
512 copy->dstbuf = malloc(copy->dstbuf_size * copy->vertex_size);
513 copy->dstptr = copy->dstbuf;
517 for (offset = 0, i = 0; i < copy->nr_varying; i++) {
518 const struct gl_client_array *src = copy->varying[i].array;
519 struct gl_client_array *dst = ©->varying[i].dstarray;
524 dst->Stride = copy->vertex_size;
525 dst->StrideB = copy->vertex_size;
526 dst->Ptr = copy->dstbuf + offset;
532 dst->_MaxElement = copy->dstbuf_size; /* may be less! */
534 offset += copy->varying[i].size;
539 copy->dstelt_size = MIN2(65536,
540 copy->ib->count * 2 + 3);
541 copy->dstelt_size = MIN2(copy->dstelt_size,
542 copy->limits->max_indices);
543 copy->dstelt = malloc(sizeof(GLuint) * copy->dstelt_size);
544 copy->dstelt_nr = 0;
549 copy->dstib.count = 0; /* duplicates dstelt_nr */
550 copy->dstib.type = GL_UNSIGNED_INT;
551 copy->dstib.obj = ctx->Shared->NullBufferObj;
552 copy->dstib.ptr = copy->dstelt;
560 replay_finish( struct copy_context *copy )
562 struct gl_context *ctx = copy->ctx;
567 free(copy->translated_elt_buf);
568 free(copy->dstbuf);
569 free(copy->dstelt);
573 for (i = 0; i < copy->nr_varying; i++) {
574 struct gl_buffer_object *vbo = copy->varying[i].array->BufferObj;
581 if (_mesa_is_bufferobj(copy->ib->obj) &&
582 _mesa_bufferobj_mapped(copy->ib->obj)) {
583 ctx->Driver.UnmapBuffer(ctx, copy->ib->obj);
599 struct copy_context copy;
613 memset(©, 0, sizeof(copy));
619 copy.ctx = ctx;
620 copy.array = arrays;
621 copy.prim = &prim[i];
622 copy.nr_prims = this_nr_prims;
623 copy.ib = ib;
624 copy.draw = draw;
625 copy.limits = limits;
630 copy.vert_cache[i].in = ~0;
632 replay_init(©);
633 replay_elts(©);
634 replay_finish(©);