OSDN Git Service

nouveau: introduce nouveau_miptree common to all nouveau pipe drivers
authorBen Skeggs <bskeggs@redhat.com>
Mon, 31 Aug 2009 03:00:34 +0000 (13:00 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Mon, 31 Aug 2009 03:39:38 +0000 (13:39 +1000)
The winsys once again has to know about textures it seems, so we need a
common representation between all our pipe drivers to store some
information the winsys will need.

Only the nv50 driver has been fixed so far.

src/gallium/drivers/nouveau/nouveau_screen.h
src/gallium/drivers/nv50/nv50_context.h
src/gallium/drivers/nv50/nv50_miptree.c
src/gallium/drivers/nv50/nv50_state_validate.c
src/gallium/drivers/nv50/nv50_surface.c
src/gallium/drivers/nv50/nv50_tex.c
src/gallium/drivers/nv50/nv50_transfer.c

index 9968b07..ebfc67a 100644 (file)
@@ -22,4 +22,15 @@ nouveau_bo(struct pipe_buffer *pb)
 int nouveau_screen_init(struct nouveau_screen *, struct nouveau_device *);
 void nouveau_screen_fini(struct nouveau_screen *);
 
+struct nouveau_miptree {
+       struct pipe_texture base;
+       struct nouveau_bo *bo;
+};
+
+static inline struct nouveau_miptree *
+nouveau_miptree(struct pipe_texture *pt)
+{
+       return (struct nouveau_miptree *)pt;
+}
+
 #endif
index 4de6e8c..1e9e8e4 100644 (file)
@@ -75,9 +75,7 @@ struct nv50_miptree_level {
 };
 
 struct nv50_miptree {
-       struct pipe_texture base;
-
-       struct nouveau_bo *bo;
+       struct nouveau_miptree base;
 
        struct nv50_miptree_level level[PIPE_MAX_TEXTURE_LEVELS];
        int image_nr;
index dd1b030..03b9243 100644 (file)
@@ -31,15 +31,15 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
 {
        struct nouveau_device *dev = nouveau_screen(pscreen)->device;
        struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree);
-       struct pipe_texture *pt = &mt->base;
+       struct pipe_texture *pt = &mt->base.base;
        unsigned width = tmp->width[0], height = tmp->height[0];
        unsigned depth = tmp->depth[0];
        uint32_t tile_mode, tile_flags, tile_h;
        int ret, i, l;
 
-       mt->base = *tmp;
-       pipe_reference_init(&mt->base.reference, 1);
-       mt->base.screen = pscreen;
+       *pt = *tmp;
+       pipe_reference_init(&pt->reference, 1);
+       pt->screen = pscreen;
 
        switch (pt->format) {
        case PIPE_FORMAT_Z32_FLOAT:
@@ -116,13 +116,14 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
        }
 
        ret = nouveau_bo_new_tile(dev, NOUVEAU_BO_VRAM, 256, mt->total_size,
-                                 mt->level[0].tile_mode, tile_flags, &mt->bo);
+                                 mt->level[0].tile_mode, tile_flags,
+                                 &mt->base.bo);
        if (ret) {
                FREE(mt);
                return NULL;
        }
 
-       return &mt->base;
+       return pt;
 }
 
 static struct pipe_texture *
@@ -141,15 +142,15 @@ nv50_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
        if (!mt)
                return NULL;
 
-       mt->base = *pt;
-       pipe_reference_init(&mt->base.reference, 1);
-       mt->base.screen = pscreen;
+       mt->base.base = *pt;
+       pipe_reference_init(&mt->base.base.reference, 1);
+       mt->base.base.screen = pscreen;
        mt->image_nr = 1;
        mt->level[0].pitch = *stride;
        mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
 
-       nouveau_bo_ref(bo, &mt->bo);
-       return &mt->base;
+       nouveau_bo_ref(bo, &mt->base.bo);
+       return &mt->base.base;
 }
 
 static void
@@ -157,7 +158,7 @@ nv50_miptree_destroy(struct pipe_texture *pt)
 {
        struct nv50_miptree *mt = nv50_miptree(pt);
 
-       nouveau_bo_ref(NULL, &mt->bo);
+       nouveau_bo_ref(NULL, &mt->base.bo);
        FREE(mt);
 }
 
index 99d5b96..344c2cf 100644 (file)
@@ -33,7 +33,7 @@ nv50_state_validate_fb(struct nv50_context *nv50)
 
        for (i = 0; i < fb->nr_cbufs; i++) {
                struct pipe_texture *pt = fb->cbufs[i]->texture;
-               struct nouveau_bo *bo = nv50_miptree(pt)->bo;
+               struct nouveau_bo *bo = nv50_miptree(pt)->base.bo;
 
                if (!gw) {
                        w = fb->cbufs[i]->width;
@@ -75,7 +75,7 @@ nv50_state_validate_fb(struct nv50_context *nv50)
 
        if (fb->zsbuf) {
                struct pipe_texture *pt = fb->zsbuf->texture;
-               struct nouveau_bo *bo = nv50_miptree(pt)->bo;
+               struct nouveau_bo *bo = nv50_miptree(pt)->base.bo;
 
                if (!gw) {
                        w = fb->zsbuf->width;
index edaf4b0..b266324 100644 (file)
@@ -53,7 +53,7 @@ nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst)
        struct nv50_miptree *mt = nv50_miptree(ps->texture);
        struct nouveau_channel *chan = screen->eng2d->channel;
        struct nouveau_grobj *eng2d = screen->eng2d;
-       struct nouveau_bo *bo = nv50_miptree(ps->texture)->bo;
+       struct nouveau_bo *bo = nv50_miptree(ps->texture)->base.bo;
        int format, mthd = dst ? NV50_2D_DST_FORMAT : NV50_2D_SRC_FORMAT;
        int flags = NOUVEAU_BO_VRAM | (dst ? NOUVEAU_BO_WR : NOUVEAU_BO_RD);
 
index 14c68b9..033cb50 100644 (file)
@@ -29,7 +29,7 @@ static int
 nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so,
                   struct nv50_miptree *mt, int unit)
 {
-       switch (mt->base.format) {
+       switch (mt->base.base.format) {
        case PIPE_FORMAT_A8R8G8B8_UNORM:
                so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
                            NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
@@ -118,18 +118,18 @@ nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so,
                return 1;
        }
 
-       so_reloc(so, mt->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW |
+       so_reloc(so, mt->base.bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW |
                     NOUVEAU_BO_RD, 0, 0);
        if (nv50->sampler[unit]->normalized)
-               so_data (so, 0xd0005000 | mt->bo->tile_mode << 22);
+               so_data (so, 0xd0005000 | mt->base.bo->tile_mode << 22);
        else
-               so_data (so, 0x5001d000 | mt->bo->tile_mode << 22);
+               so_data (so, 0x5001d000 | mt->base.bo->tile_mode << 22);
        so_data (so, 0x00300000);
-       so_data (so, mt->base.width[0]);
-       so_data (so, (mt->base.last_level << 28) |
-                    (mt->base.depth[0] << 16) | mt->base.height[0]);
+       so_data (so, mt->base.base.width[0]);
+       so_data (so, (mt->base.base.last_level << 28) |
+                    (mt->base.base.depth[0] << 16) | mt->base.base.height[0]);
        so_data (so, 0x03000000);
-       so_data (so, mt->base.last_level << 4);
+       so_data (so, mt->base.base.last_level << 4);
 
        return 0;
 }
index d2b5e4d..e9c3562 100644 (file)
@@ -148,8 +148,8 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        tx->base.usage = usage;
 
        tx->level_pitch = lvl->pitch;
-       tx->level_width = mt->base.width[level];
-       tx->level_height = mt->base.height[level];
+       tx->level_width = mt->base.base.width[level];
+       tx->level_height = mt->base.base.height[level];
        tx->level_offset = lvl->image_offset[image];
        tx->level_tiling = lvl->tile_mode;
        tx->level_x = x;
@@ -162,7 +162,7 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        }
 
        if (usage != PIPE_TRANSFER_WRITE) {
-               nv50_transfer_rect_m2mf(pscreen, mt->bo, tx->level_offset,
+               nv50_transfer_rect_m2mf(pscreen, mt->base.bo, tx->level_offset,
                                        tx->level_pitch, tx->level_tiling,
                                        x, y,
                                        tx->level_width, tx->level_height,
@@ -188,7 +188,7 @@ nv50_transfer_del(struct pipe_transfer *ptx)
                nv50_transfer_rect_m2mf(pscreen, tx->bo, 0, tx->base.stride,
                                        tx->bo->tile_mode, 0, 0,
                                        tx->base.width, tx->base.height,
-                                       mt->bo, tx->level_offset,
+                                       mt->base.bo, tx->level_offset,
                                        tx->level_pitch, tx->level_tiling,
                                        tx->level_x, tx->level_y,
                                        tx->level_width, tx->level_height,