-static void
-nouveau_teximage_map(struct gl_context *ctx, struct gl_texture_image *ti,
- int access, int x, int y, int w, int h)
-{
- struct nouveau_teximage *nti = to_nouveau_teximage(ti);
- struct nouveau_surface *s = &nti->surface;
- struct nouveau_surface *st = &nti->transfer.surface;
- struct nouveau_client *client = context_client(ctx);
-
- if (s->bo) {
- if (!(access & GL_MAP_READ_BIT) &&
- nouveau_pushbuf_refd(context_push(ctx), s->bo)) {
- unsigned size;
- /*
- * Heuristic: use a bounce buffer to pipeline
- * teximage transfers.
- */
- st->layout = LINEAR;
- st->format = s->format;
- st->cpp = s->cpp;
- st->width = w;
- st->height = h;
- st->pitch = s->pitch;
- nti->transfer.x = x;
- nti->transfer.y = y;
-
- size = get_format_blocksy(st->format, h) * st->pitch;
- nti->base.Map = nouveau_get_scratch(ctx, size,
- &st->bo, &st->offset);
-
- } else {
- int ret, flags = 0;
-
- if (access & GL_MAP_READ_BIT)
- flags |= NOUVEAU_BO_RD;
- if (access & GL_MAP_WRITE_BIT)
- flags |= NOUVEAU_BO_WR;
-
- if (!s->bo->map) {
- ret = nouveau_bo_map(s->bo, flags, client);
- assert(!ret);
- }
-
- nti->base.Map = s->bo->map +
- get_format_blocksy(s->format, y) * s->pitch +
- get_format_blocksx(s->format, x) * s->cpp;
-
- }
- }
-}
-
-static void
-nouveau_teximage_unmap(struct gl_context *ctx, struct gl_texture_image *ti)
-{
- struct nouveau_teximage *nti = to_nouveau_teximage(ti);
- struct nouveau_surface *s = &nti->surface;
- struct nouveau_surface *st = &nti->transfer.surface;
-
- if (st->bo) {
- context_drv(ctx)->surface_copy(ctx, s, st, nti->transfer.x,
- nti->transfer.y, 0, 0,
- st->width, st->height);
- nouveau_surface_ref(NULL, st);
-
- }
- nti->base.Map = NULL;
-}
-
-