-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;
-
- if (s->bo) {
- if (!(access & GL_MAP_READ_BIT) &&
- nouveau_bo_pending(s->bo)) {
- /*
- * 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;
-
- nti->base.Map = nouveau_get_scratch(ctx, st->pitch * h,
- &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);
- assert(!ret);
- }
-
- nti->base.Map = s->bo->map + y * s->pitch + 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);
-
- } else if (s->bo) {
- nouveau_bo_unmap(s->bo);
- }
-
- nti->base.Map = NULL;
-}
-
-