nouveau: Need to surface_copy() without a pipe context.
authorYounes Manton <younes.m@gmail.com>
Sat, 7 Feb 2009 17:53:30 +0000 (12:53 -0500)
committerYounes Manton <younes.m@gmail.com>
Sat, 7 Feb 2009 17:54:48 +0000 (12:54 -0500)
src/gallium/drivers/nv30/nv30_screen.c
src/gallium/drivers/nv40/nv40_screen.c
src/gallium/drivers/nv50/nv50_context.h
src/gallium/drivers/nv50/nv50_miptree.c
src/gallium/drivers/nv50/nv50_surface.c

index 2bc83f815b30cc120cb7e6d0e5f7c4812d7dffdd..e3c9b420448d8fe955f79fb0a79ef7593df75132 100644 (file)
@@ -127,6 +127,14 @@ nv30_screen_surface_format_supported(struct pipe_screen *pscreen,
        return FALSE;
 }
 
+static struct pipe_buffer *
+nv30_surface_buffer(struct pipe_surface *surf)
+{
+       struct nv30_miptree *mt = (struct nv30_miptree *)surf->texture;
+
+       return mt->buffer;
+}
+
 static void *
 nv30_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
                 unsigned flags )
@@ -134,7 +142,6 @@ nv30_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
        struct pipe_winsys      *ws = screen->winsys;
        struct pipe_surface     *surface_to_map;
        void                    *map;
-       struct nv30_miptree *nv30mt = (struct nv30_miptree *)surface->texture;
 
        if (!(surface->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
                struct nv30_miptree *mt = (struct nv30_miptree *)surface->texture;
@@ -163,7 +170,7 @@ nv30_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
 
        assert(surface_to_map);
 
-       map = ws->buffer_map(ws, nv30mt->buffer, flags);
+       map = ws->buffer_map(ws, nv30_surface_buffer(surface_to_map), flags);
        if (!map)
                return NULL;
 
@@ -175,7 +182,6 @@ nv30_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
 {
        struct pipe_winsys      *ws = screen->winsys;
        struct pipe_surface     *surface_to_unmap;
-       struct nv30_miptree *nv30mt = (struct nv30_miptree *)surface->texture;
 
        /* TODO: Copy from shadow just before push buffer is flushed instead.
                 There are probably some programs that map/unmap excessively
@@ -192,15 +198,14 @@ nv30_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
 
        assert(surface_to_unmap);
 
-       ws->buffer_unmap(ws, nv30mt->buffer);
+       ws->buffer_unmap(ws, nv30_surface_buffer(surface_to_unmap));
 
        if (surface_to_unmap != surface) {
                struct nv30_screen *nvscreen = nv30_screen(screen);
 
-               nvscreen->nvws->surface_copy(nvscreen->nvws,
-                                            surface, 0, 0,
-                                            surface_to_unmap, 0, 0,
-                                            surface->width, surface->height);
+               nvscreen->eng2d->copy(nvscreen->eng2d, surface, 0, 0,
+                                     surface_to_unmap, 0, 0,
+                                     surface->width, surface->height);
        }
 }
 
@@ -220,14 +225,6 @@ nv30_screen_destroy(struct pipe_screen *pscreen)
        FREE(pscreen);
 }
 
-static struct pipe_buffer *
-nv30_surface_buffer(struct pipe_surface *surf)
-{
-       struct nv30_miptree *mt = (struct nv30_miptree *)surf->texture;
-
-       return mt->buffer;
-}
-
 struct pipe_screen *
 nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
 {
index a2b124d2289c22cab47c331a30a003a6f36dcc7d..88a329ea2453471bd220e6dbacd5b11b34423359 100644 (file)
@@ -136,6 +136,14 @@ nv40_screen_surface_format_supported(struct pipe_screen *pscreen,
        return FALSE;
 }
 
+static struct pipe_buffer *
+nv40_surface_buffer(struct pipe_surface *surf)
+{
+       struct nv40_miptree *mt = (struct nv40_miptree *)surf->texture;
+
+       return mt->buffer;
+}
+
 static void *
 nv40_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
                 unsigned flags )
@@ -143,7 +151,6 @@ nv40_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
        struct pipe_winsys      *ws = screen->winsys;
        struct pipe_surface     *surface_to_map;
        void                    *map;
-        struct nv40_miptree *mt;
 
        if (!(surface->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
                struct nv40_miptree *mt = (struct nv40_miptree *)surface->texture;
@@ -171,8 +178,7 @@ nv40_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
                surface_to_map = surface;
 
        assert(surface_to_map);
-        mt = (struct nv40_miptree *)surface_to_map->texture;
-       map = ws->buffer_map(ws, mt->buffer, flags);
+       map = ws->buffer_map(ws, nv40_surface_buffer(surface_to_map), flags);
        if (!map)
                return NULL;
 
@@ -184,7 +190,6 @@ nv40_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
 {
        struct pipe_winsys      *ws = screen->winsys;
        struct pipe_surface     *surface_to_unmap;
-        struct nv40_miptree *mt;
 
        /* TODO: Copy from shadow just before push buffer is flushed instead.
                 There are probably some programs that map/unmap excessively
@@ -201,16 +206,14 @@ nv40_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
 
        assert(surface_to_unmap);
 
-        mt = (struct nv40_miptree *)surface_to_unmap->texture;
-       ws->buffer_unmap(ws, mt->buffer);
+       ws->buffer_unmap(ws, nv40_surface_buffer(surface_to_unmap));
 
        if (surface_to_unmap != surface) {
                struct nv40_screen *nvscreen = nv40_screen(screen);
 
-               nvscreen->nvws->surface_copy(nvscreen->nvws,
-                                            surface, 0, 0,
-                                            surface_to_unmap, 0, 0,
-                                            surface->width, surface->height);
+               nvscreen->eng2d->copy(nvscreen->eng2d, surface, 0, 0,
+                                     surface_to_unmap, 0, 0,
+                                     surface->width, surface->height);
        }
 }
 
@@ -230,14 +233,6 @@ nv40_screen_destroy(struct pipe_screen *pscreen)
        FREE(pscreen);
 }
 
-static struct pipe_buffer *
-nv40_surface_buffer(struct pipe_surface *surf)
-{
-       struct nv40_miptree *mt = (struct nv40_miptree *)surf->texture;
-
-       return mt->buffer;
-}
-
 struct pipe_screen *
 nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
 {
index 6a11572590a8cc1dc2c2447e7181d963211892f3..1e9d45cb3409c30fb771594b847f76c5f906e9f6 100644 (file)
@@ -167,6 +167,11 @@ extern void nv50_init_query_functions(struct nv50_context *nv50);
 
 extern void nv50_screen_init_miptree_functions(struct pipe_screen *pscreen);
 
+extern int
+nv50_surface_do_copy(struct nv50_screen *screen, struct pipe_surface *dst,
+                    int dx, int dy, struct pipe_surface *src, int sx, int sy,
+                    int w, int h);
+
 /* nv50_draw.c */
 extern struct draw_stage *nv50_draw_render_stage(struct nv50_context *nv50);
 
index a6ef76ff7539103eca5295ba1c64c1157a93baff..91091d53f57391355819f9dad1e54058476bc363 100644 (file)
@@ -166,7 +166,7 @@ void
 nv50_miptree_sync(struct pipe_screen *pscreen, struct nv50_miptree *mt,
                  unsigned level, unsigned image)
 {
-       struct nouveau_winsys *nvws = nv50_screen(pscreen)->nvws;
+       struct nv50_screen *nvscreen = nv50_screen(pscreen);
        struct nv50_miptree_level *lvl = &mt->level[level];
        struct pipe_surface *dst, *src;
        unsigned face = 0, zslice = 0;
@@ -197,7 +197,7 @@ nv50_miptree_sync(struct pipe_screen *pscreen, struct nv50_miptree *mt,
        dst = pscreen->get_tex_surface(pscreen, &mt->base, face, level, zslice,
                                       PIPE_BUFFER_USAGE_GPU_READ);
 
-       nvws->surface_copy(nvws, dst, 0, 0, src, 0, 0, dst->width, dst->height);
+       nv50_surface_do_copy(nvscreen, dst, 0, 0, src, 0, 0, dst->width, dst->height);
 
        pscreen->tex_surface_release(pscreen, &dst);
        pscreen->tex_surface_release(pscreen, &src);
@@ -208,7 +208,7 @@ static void
 nv50_miptree_sync_cpu(struct pipe_screen *pscreen, struct nv50_miptree *mt,
                      unsigned level, unsigned image)
 {
-       struct nouveau_winsys *nvws = nv50_screen(pscreen)->nvws;
+       struct nv50_screen *nvscreen = nv50_screen(pscreen);
        struct nv50_miptree_level *lvl = &mt->level[level];
        struct pipe_surface *dst, *src;
        unsigned face = 0, zslice = 0;
@@ -229,7 +229,7 @@ nv50_miptree_sync_cpu(struct pipe_screen *pscreen, struct nv50_miptree *mt,
        dst = pscreen->get_tex_surface(pscreen, &mt->base, face, level, zslice,
                                       PIPE_BUFFER_USAGE_CPU_READ);
 
-       nvws->surface_copy(nvws, dst, 0, 0, src, 0, 0, dst->width, dst->height);
+       nv50_surface_do_copy(nvscreen, dst, 0, 0, src, 0, 0, dst->width, dst->height);
 
        pscreen->tex_surface_release(pscreen, &dst);
        pscreen->tex_surface_release(pscreen, &src);
index b3c04505cfbe0a172c9ee0b82ba7fc1dc94df2dd..f2dd2eb30bef112cbbac6fcd578e53ec53581ab9 100644 (file)
@@ -102,7 +102,7 @@ nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst)
        return 0;
 }
 
-static int
+int
 nv50_surface_do_copy(struct nv50_screen *screen, struct pipe_surface *dst,
                     int dx, int dy, struct pipe_surface *src, int sx, int sy,
                     int w, int h)