{
struct pipe_winsys *ws = pscreen->winsys;
struct nv50_miptree *mt = nv50_miptree(pt);
+ struct nv50_surface *s;
struct pipe_surface *ps;
- ps = CALLOC_STRUCT(pipe_surface);
+ s = CALLOC_STRUCT(nv50_surface);
+ if (!s)
+ return NULL;
+ ps = &s->base;
+
ps->refcount = 1;
ps->winsys = ws;
ps->format = pt->format;
struct pipe_surface **psurface)
{
struct pipe_winsys *ws = pscreen->winsys;
- struct pipe_surface *surf = *psurface;
+ struct pipe_surface *ps = *psurface;
+ struct nv50_surface *s = nv50_surface(ps);
*psurface = NULL;
- if (--surf->refcount <= 0) {
- pipe_texture_reference(&surf->texture, NULL);
- pipe_buffer_reference(ws, &surf->buffer, NULL);
- FREE(surf);
+ if (--ps->refcount <= 0) {
+ pipe_texture_reference(&ps->texture, NULL);
+ pipe_buffer_reference(ws, &ps->buffer, NULL);
+ FREE(s);
}
}
}
static void *
-nv50_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
+nv50_surface_map(struct pipe_screen *screen, struct pipe_surface *ps,
unsigned flags )
{
+ struct nouveau_winsys *nvws = nv50_screen(screen)->nvws;
struct pipe_winsys *ws = screen->winsys;
+ struct nv50_surface *s = nv50_surface(ps);
+ struct nv50_surface m = *s;
void *map;
- map = ws->buffer_map(ws, surface->buffer, flags);
+ if (!s->untiled) {
+ s->untiled = ws->buffer_create(ws, 0, 0, ps->buffer->size);
+
+ m.base.buffer = s->untiled;
+ nvws->surface_copy(nvws, &m.base, 0, 0, &s->base, 0, 0,
+ ps->width, ps->height);
+ }
+
+ /* Map original tiled surface to disallow it being validated while
+ * untiled mirror is mapped.
+ */
+ ws->buffer_map(ws, ps->buffer, flags);
+
+ map = ws->buffer_map(ws, s->untiled, flags);
if (!map)
return NULL;
- return map + surface->offset;
+ return map;
}
static void
-nv50_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
+nv50_surface_unmap(struct pipe_screen *screen, struct pipe_surface *ps)
{
+ struct nouveau_winsys *nvws = nv50_screen(screen)->nvws;
struct pipe_winsys *ws = screen->winsys;
+ struct nv50_surface *s = nv50_surface(ps);
+ struct nv50_surface m = *s;
+
+ ws->buffer_unmap(ws, s->untiled);
+ ws->buffer_unmap(ws, ps->buffer);
+
+ m.base.buffer = s->untiled;
+ nvws->surface_copy(nvws, &s->base, 0, 0, &m.base, 0, 0,
+ ps->width, ps->height);
- ws->buffer_unmap(ws, surface->buffer);
+ pipe_buffer_reference(ws, &s->untiled, NULL);
}
void