nouveau: adapt to cpp->pf_block changes
authorBen Skeggs <skeggsb@gmail.com>
Sun, 29 Jun 2008 03:26:04 +0000 (13:26 +1000)
committerBen Skeggs <skeggsb@gmail.com>
Sun, 29 Jun 2008 05:00:28 +0000 (15:00 +1000)
13 files changed:
src/gallium/drivers/nv10/nv10_miptree.c
src/gallium/drivers/nv10/nv10_state_emit.c
src/gallium/drivers/nv30/nv30_miptree.c
src/gallium/drivers/nv30/nv30_state.c
src/gallium/drivers/nv30/nv30_state_fb.c
src/gallium/drivers/nv40/nv40_miptree.c
src/gallium/drivers/nv40/nv40_state_fb.c
src/gallium/drivers/nv40/nv40_surface.c
src/gallium/drivers/nv50/nv50_miptree.c
src/gallium/winsys/dri/nouveau/nouveau_context.c
src/gallium/winsys/dri/nouveau/nouveau_screen.c
src/gallium/winsys/dri/nouveau/nv04_surface.c
src/gallium/winsys/dri/nouveau/nv50_surface.c

index 1b9947354d6d60fc3d8a192a9c54b4080ccf0aa2..f1486a35df52d127d9e80c96ff6d792f06a698b8 100644 (file)
@@ -25,11 +25,13 @@ nv10_miptree_layout(struct nv10_miptree *nv10mt)
                pt->width[l] = width;
                pt->height[l] = height;
                pt->depth[l] = depth;
+               pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
+               pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
 
                if (swizzled)
-                       nv10mt->level[l].pitch = pt->width[l] * pt->cpp;
+                       nv10mt->level[l].pitch = pt->nblocksx[l] * pt->block.size;
                else
-                       nv10mt->level[l].pitch = pt->width[0] * pt->cpp;
+                       nv10mt->level[l].pitch = pt->nblocksx[0] * pt->block.size;
                nv10mt->level[l].pitch = (nv10mt->level[l].pitch + 63) & ~63;
 
                nv10mt->level[l].image_offset =
@@ -117,10 +119,12 @@ nv10_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
                return NULL;
        pipe_buffer_reference(ws, &ps->buffer, nv10mt->buffer);
        ps->format = pt->format;
-       ps->cpp = pt->cpp;
        ps->width = pt->width[level];
        ps->height = pt->height[level];
-       ps->pitch = nv10mt->level[level].pitch / ps->cpp;
+       ps->block = pt->block;
+       ps->nblocksx = pt->nblocksx[level];
+       ps->nblocksy = pt->nblocksy[level];
+       ps->stride = nv10mt->level[level].pitch;
 
        if (pt->target == PIPE_TEXTURE_CUBE) {
                ps->offset = nv10mt->level[level].image_offset[face];
index 41422c88825e7a47c3451b40a10530fa3878c507..d21368d33f38fb5ab52e686cb1c36a6c3aa2d53c 100644 (file)
@@ -143,10 +143,10 @@ static void nv10_state_emit_framebuffer(struct nv10_context* nv10)
 
        if (zeta) {
                BEGIN_RING(celsius, NV10TCL_RT_PITCH, 1);
-               OUT_RING  ( (rt->pitch * rt->cpp) | ( (zeta->pitch * zeta->cpp) << 16) );
+               OUT_RING  (rt->stride | (zeta->stride << 16));
        } else {
                BEGIN_RING(celsius, NV10TCL_RT_PITCH, 1);
-               OUT_RING  ( (rt->pitch * rt->cpp) | ( (rt->pitch * rt->cpp) << 16) );
+               OUT_RING  (rt->stride | (rt->stride << 16));
        }
 
        nv10->rt[0] = rt->buffer;
index 6078b1865e2e246ed7ca75b282ad16e7aac94b05..ad0b257fe2bd773776fca9b5ab4950ceb5632be4 100644 (file)
@@ -28,12 +28,14 @@ nv30_miptree_layout(struct nv30_miptree *nv30mt)
                pt->width[l] = width;
                pt->height[l] = height;
                pt->depth[l] = depth;
+               pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
+               pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
 
                if (swizzled)
                        pitch = pt->width[l];
                pitch = (pitch + 63) & ~63;
 
-               nv30mt->level[l].pitch = pitch * pt->cpp;
+               nv30mt->level[l].pitch = pitch * pt->block.size;
                nv30mt->level[l].image_offset =
                        CALLOC(nr_faces, sizeof(unsigned));
 
@@ -114,10 +116,12 @@ nv30_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                return NULL;
        pipe_buffer_reference(ws, &ps->buffer, nv30mt->buffer);
        ps->format = pt->format;
-       ps->cpp = pt->cpp;
        ps->width = pt->width[level];
        ps->height = pt->height[level];
-       ps->pitch = nv30mt->level[level].pitch / ps->cpp;
+       ps->nblocksx = pt->nblocksx[level];
+       ps->nblocksy = pt->nblocksy[level];
+       ps->block = pt->block;
+       ps->stride = nv30mt->level[level].pitch;
 
        if (pt->target == PIPE_TEXTURE_CUBE) {
                ps->offset = nv30mt->level[level].image_offset[face];
index 84f016eeadcf8445680499412577dd0204834cbe..c1618041bb002c141aaf38c603c8b868e55d95ca 100644 (file)
@@ -631,21 +631,21 @@ nv30_set_framebuffer_state(struct pipe_context *pipe,
        }
 
        if (rt_enable & NV34TCL_RT_ENABLE_COLOR0) {
-               uint32_t pitch = rt[0]->pitch * rt[0]->cpp;
+               uint32_t pitch = rt[0]->stride;
                if (zeta) {
-                       pitch |= (zeta->pitch * zeta->cpp)<<16;
+                       pitch |= (zeta->stride << 16);
                } else {
-                       pitch |= pitch<<16;
+                       pitch |= (pitch << 16);
                }
 
                BEGIN_RING(rankine, NV34TCL_COLOR0_PITCH, 1);
-               OUT_RING  ( pitch );
+               OUT_RING  (pitch);
                nv30->rt[0] = rt[0]->buffer;
        }
 
        if (rt_enable & NV34TCL_RT_ENABLE_COLOR1) {
                BEGIN_RING(rankine, NV34TCL_COLOR1_PITCH, 1);
-               OUT_RING  (rt[1]->pitch * rt[1]->cpp);
+               OUT_RING  (rt[1]->stride);
                nv30->rt[1] = rt[1]->buffer;
        }
 
index 73c97e298addc97dac4cd77713e64a7103ba0298..a20df9f75d1f591eee76c28b16fe748c335f9c5e 100644 (file)
@@ -59,11 +59,11 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
        }
 
        if (rt_enable & NV34TCL_RT_ENABLE_COLOR0) {
-               uint32_t pitch = rt[0]->pitch * rt[0]->cpp;
+               uint32_t pitch = rt[0]->stride;
                if (zeta) {
-                       pitch |= (zeta->pitch * zeta->cpp)<<16;
+                       pitch |= (zeta->stride << 16);
                } else {
-                       pitch |= pitch<<16;
+                       pitch |= (pitch << 16);
                }
 
                so_method(so, nv30->screen->rankine, NV34TCL_DMA_COLOR0, 1);
@@ -84,7 +84,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
                so_method(so, nv30->screen->rankine, NV34TCL_COLOR1_OFFSET, 2);
                so_reloc (so, rt[1]->buffer, rt[1]->offset, rt_flags |
                          NOUVEAU_BO_LOW, 0, 0);
-               so_data  (so, rt[1]->pitch * rt[1]->cpp);
+               so_data  (so, rt[1]->stride);
        }
 /*
        if (rt_enable & NV34TCL_RT_ENABLE_COLOR2) {
index 23da6e36a3e4992de36a7ef76f40ccd3491ba21b..38e1a5f04ca5db760041ddce5d01796dbaf30f70 100644 (file)
@@ -28,19 +28,20 @@ nv40_miptree_layout(struct nv40_miptree *nv40mt)
                pt->width[l] = width;
                pt->height[l] = height;
                pt->depth[l] = depth;
+               pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
+               pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
 
                if (swizzled)
-                       pitch = pt->width[l];
-               pitch = (pitch + 63) & ~63;
+                       pitch = pt->nblocksx[l];
+               pitch = align_int(pitch, 64);
 
-               nv40mt->level[l].pitch = pitch * pt->cpp;
+               nv40mt->level[l].pitch = pitch * pt->block.size;
                nv40mt->level[l].image_offset =
                        CALLOC(nr_faces, sizeof(unsigned));
 
                width  = MAX2(1, width  >> 1);
                height = MAX2(1, height >> 1);
                depth  = MAX2(1, depth  >> 1);
-
        }
 
        for (f = 0; f < nr_faces; f++) {
@@ -109,15 +110,20 @@ nv40_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        struct nv40_miptree *nv40mt = (struct nv40_miptree *)pt;
        struct pipe_surface *ps;
 
-       ps = ws->surface_alloc(ws);
+       ps = CALLOC_STRUCT(pipe_surface);
        if (!ps)
                return NULL;
+       pipe_texture_reference(&ps->texture, pt);
        pipe_buffer_reference(ws, &ps->buffer, nv40mt->buffer);
        ps->format = pt->format;
-       ps->cpp = pt->cpp;
        ps->width = pt->width[level];
        ps->height = pt->height[level];
-       ps->pitch = nv40mt->level[level].pitch / ps->cpp;
+       ps->block = pt->block;
+       ps->nblocksx = pt->nblocksx[level];
+       ps->nblocksy = pt->nblocksy[level];
+       ps->stride = nv40mt->level[level].pitch;
+       ps->usage = flags;
+       ps->status = PIPE_SURFACE_STATUS_DEFINED;
 
        if (pt->target == PIPE_TEXTURE_CUBE) {
                ps->offset = nv40mt->level[level].image_offset[face];
@@ -135,6 +141,15 @@ static void
 nv40_miptree_surface_del(struct pipe_screen *pscreen,
                         struct pipe_surface **psurface)
 {
+       struct pipe_surface *ps = *psurface;
+
+       *psurface = NULL;
+       if (--ps->refcount > 0)
+               return;
+
+       pipe_texture_reference(&ps->texture, NULL);
+       pipe_buffer_reference(pscreen->winsys, &ps->buffer, NULL);
+       FREE(ps);
 }
 
 void
index 88baf61ffb3be28d9a9bd555d4527a541c81226d..0e4e60eaa759509f17f3a18199d061b6fc9ea660 100644 (file)
@@ -64,7 +64,7 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
                          nv40->nvws->channel->vram->handle,
                          nv40->nvws->channel->gart->handle);
                so_method(so, nv40->screen->curie, NV40TCL_COLOR0_PITCH, 2);
-               so_data  (so, rt[0]->pitch * rt[0]->cpp);
+               so_data  (so, rt[0]->stride);
                so_reloc (so, rt[0]->buffer, rt[0]->offset, rt_flags |
                          NOUVEAU_BO_LOW, 0, 0);
        }
@@ -77,7 +77,7 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
                so_method(so, nv40->screen->curie, NV40TCL_COLOR1_OFFSET, 2);
                so_reloc (so, rt[1]->buffer, rt[1]->offset, rt_flags |
                          NOUVEAU_BO_LOW, 0, 0);
-               so_data  (so, rt[1]->pitch * rt[1]->cpp);
+               so_data  (so, rt[1]->stride);
        }
 
        if (rt_enable & NV40TCL_RT_ENABLE_COLOR2) {
@@ -89,7 +89,7 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
                so_reloc (so, rt[2]->buffer, rt[2]->offset, rt_flags |
                          NOUVEAU_BO_LOW, 0, 0);
                so_method(so, nv40->screen->curie, NV40TCL_COLOR2_PITCH, 1);
-               so_data  (so, rt[2]->pitch * rt[2]->cpp);
+               so_data  (so, rt[2]->stride);
        }
 
        if (rt_enable & NV40TCL_RT_ENABLE_COLOR3) {
@@ -101,7 +101,7 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
                so_reloc (so, rt[3]->buffer, rt[3]->offset, rt_flags |
                          NOUVEAU_BO_LOW, 0, 0);
                so_method(so, nv40->screen->curie, NV40TCL_COLOR3_PITCH, 1);
-               so_data  (so, rt[3]->pitch * rt[3]->cpp);
+               so_data  (so, rt[3]->stride);
        }
 
        if (zeta_format) {
@@ -113,7 +113,7 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
                so_reloc (so, zeta->buffer, zeta->offset, rt_flags |
                          NOUVEAU_BO_LOW, 0, 0);
                so_method(so, nv40->screen->curie, NV40TCL_ZETA_PITCH, 1);
-               so_data  (so, zeta->pitch * zeta->cpp);
+               so_data  (so, zeta->stride);
        }
 
        so_method(so, nv40->screen->curie, NV40TCL_RT_ENABLE, 1);
index c0d135eb36dfb5bd335b3eed8fcd0b7b70856d1a..0916555d5648b42ff12a44ef06d18e22db0020e6 100644 (file)
@@ -34,7 +34,7 @@
 #include "util/p_tile.h"
 
 static void
-nv40_surface_copy(struct pipe_context *pipe, unsigned do_flip,
+nv40_surface_copy(struct pipe_context *pipe, boolean do_flip,
                  struct pipe_surface *dest, unsigned destx, unsigned desty,
                  struct pipe_surface *src, unsigned srcx, unsigned srcy,
                  unsigned width, unsigned height)
index ccb916d6accf1866eff9c1bc90d135e90506b36c..6c838998fd0170d7f5e3c98bed654d288f4478a9 100644 (file)
@@ -72,10 +72,12 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
 
        pipe_buffer_reference(ws, &ps->buffer, mt->buffer);
        ps->format = pt->format;
-       ps->cpp = pt->cpp;
        ps->width = pt->width[level];
        ps->height = pt->height[level];
-       ps->pitch = ps->width;
+       ps->block = pt->block;
+       ps->nblocksx = pt->nblocksx[level];
+       ps->nblocksy = pt->nblocksy[level];
+       ps->stride = ps->width * ps->block.size;
        ps->offset = 0;
 
        return ps;
index ef5fb7ec0d3385e4d9ab5cd127872359250521cf..74413c408f33b78287bf76199723563decf17278 100644 (file)
@@ -167,9 +167,14 @@ nouveau_context_create(const __GLcontextModes *glVis,
                fb_buf->bo = &fb_bo->base;
 
                fb_surf = calloc(1, sizeof(struct pipe_surface));
-               fb_surf->cpp = nv_screen->front_cpp;
-               fb_surf->pitch = nv_screen->front_pitch / fb_surf->cpp;
+               if (nv_screen->front_cpp == 2)
+                       fb_surf->format = PIPE_FORMAT_R5G6B5_UNORM;
+               else
+                       fb_surf->format = PIPE_FORMAT_A8R8G8B8_UNORM;
+               pf_get_block(fb_surf->format, &fb_surf->block);
+               fb_surf->width = nv_screen->front_pitch / nv_screen->front_cpp;
                fb_surf->height = nv_screen->front_height;
+               fb_surf->stride = fb_surf->width * fb_surf->block.size;
                fb_surf->refcount = 1;
                fb_surf->buffer = &fb_buf->base;
 
index 9041275a88ff9f326075e9aea9b43aaf993ea4e8..b15ee7509cc6f8640c0d65563b9f3463a472654f 100644 (file)
@@ -209,8 +209,9 @@ nouveau_fill_in_modes(unsigned pixel_bits, unsigned depth_bits,
                GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
        };
 
-       u_int8_t depth_bits_array[4]   = { 0, 16, 24, 24 };
-       u_int8_t stencil_bits_array[4] = { 0,  0,  0, 8 };
+       uint8_t depth_bits_array[4]   = { 0, 16, 24, 24 };
+       uint8_t stencil_bits_array[4] = { 0,  0,  0, 8 };
+       uint8_t msaa_samples_array[1] = { 0 };
 
        depth_buffer_factor = 4;
        back_buffer_factor  = (have_back_buffer) ? 3 : 1;
@@ -229,6 +230,7 @@ nouveau_fill_in_modes(unsigned pixel_bits, unsigned depth_bits,
                                        depth_buffer_factor,
                                        back_buffer_modes,
                                        back_buffer_factor,
+                                       msaa_samples_array, 1,
                                        GLX_TRUE_COLOR)) {
                fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
                                __func__, __LINE__ );
@@ -242,6 +244,7 @@ nouveau_fill_in_modes(unsigned pixel_bits, unsigned depth_bits,
                                        depth_buffer_factor,
                                        back_buffer_modes,
                                        back_buffer_factor,
+                                       msaa_samples_array, 1,
                                        GLX_DIRECT_COLOR)) {
                fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
                                __func__, __LINE__ );
index 83c790db17a651fcd376e36d7c9c93a0418c96bd..0085b1c345d1def516aa1af57260c21dfffa7a88 100644 (file)
@@ -1,26 +1,35 @@
 #include "pipe/p_context.h"
+#include "pipe/p_format.h"
 
 #include "nouveau_context.h"
 
 static INLINE int
-nv04_surface_format(int cpp)
+nv04_surface_format(enum pipe_format format)
 {
-       switch (cpp) {
-       case 1: return NV04_CONTEXT_SURFACES_2D_FORMAT_Y8;
-       case 2: return NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5;
-       case 4: return NV04_CONTEXT_SURFACES_2D_FORMAT_Y32;
+       switch (format) {
+       case PIPE_FORMAT_A8_UNORM:
+               return NV04_CONTEXT_SURFACES_2D_FORMAT_Y8;
+       case PIPE_FORMAT_R5G6B5_UNORM:
+               return NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5;
+       case PIPE_FORMAT_A8R8G8B8_UNORM:
+       case PIPE_FORMAT_Z24S8_UNORM:
+               return NV04_CONTEXT_SURFACES_2D_FORMAT_Y32;
        default:
                return -1;
        }
 }
 
 static INLINE int
-nv04_rect_format(int cpp)
+nv04_rect_format(enum pipe_format format)
 {
-       switch (cpp) {
-       case 1: return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
-       case 2: return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A16R5G6B5;
-       case 4: return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
+       switch (format) {
+       case PIPE_FORMAT_A8_UNORM:
+               return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
+       case PIPE_FORMAT_R5G6B5_UNORM:
+               return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A16R5G6B5;
+       case PIPE_FORMAT_A8R8G8B8_UNORM:
+       case PIPE_FORMAT_Z24S8_UNORM:
+               return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
        default:
                return -1;
        }
@@ -35,8 +44,8 @@ nv04_surface_copy_m2mf(struct nouveau_context *nv, unsigned dx, unsigned dy,
        struct pipe_surface *src = nv->surf_src;
        unsigned dst_offset, src_offset;
 
-       dst_offset = dst->offset + (dy * dst->pitch + dx) * dst->cpp;
-       src_offset = src->offset + (sy * src->pitch + sx) * src->cpp;
+       dst_offset = dst->offset + (dy * dst->stride) + (dx * dst->block.size);
+       src_offset = src->offset + (sy * src->stride) + (sx * src->block.size);
 
        while (h) {
                int count = (h > 2047) ? 2047 : h;
@@ -47,16 +56,16 @@ nv04_surface_copy_m2mf(struct nouveau_context *nv, unsigned dx, unsigned dy,
                           NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
                OUT_RELOCl(chan, nouveau_buffer(dst->buffer)->bo, dst_offset,
                           NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_WR);
-               OUT_RING  (chan, src->pitch * src->cpp);
-               OUT_RING  (chan, dst->pitch * dst->cpp);
-               OUT_RING  (chan, w * src->cpp);
+               OUT_RING  (chan, src->stride);
+               OUT_RING  (chan, dst->stride);
+               OUT_RING  (chan, w * src->block.size);
                OUT_RING  (chan, count);
                OUT_RING  (chan, 0x0101);
                OUT_RING  (chan, 0);
 
                h -= count;
-               src_offset += src->pitch * src->cpp * count;
-               dst_offset += dst->pitch * dst->cpp * count;
+               src_offset += src->stride * count;
+               dst_offset += dst->stride * count;
        }
 }
 
@@ -79,7 +88,7 @@ nv04_surface_copy_prep(struct nouveau_context *nv, struct pipe_surface *dst,
        struct nouveau_channel *chan = nv->nvc->channel;
        int format;
 
-       if (src->cpp != dst->cpp)
+       if (src->format != dst->format)
                return 1;
 
        /* NV_CONTEXT_SURFACES_2D has buffer alignment restrictions, fallback
@@ -100,8 +109,8 @@ nv04_surface_copy_prep(struct nouveau_context *nv, struct pipe_surface *dst,
 
        }
 
-       if ((format = nv04_surface_format(dst->cpp)) < 0) {
-               NOUVEAU_ERR("Bad cpp = %d\n", dst->cpp);
+       if ((format = nv04_surface_format(dst->format)) < 0) {
+               NOUVEAU_ERR("Bad surface format 0x%x\n", dst->format);
                return 1;
        }
        nv->surface_copy = nv04_surface_copy_blit;
@@ -116,8 +125,7 @@ nv04_surface_copy_prep(struct nouveau_context *nv, struct pipe_surface *dst,
        BEGIN_RING(chan, nv->nvc->NvCtxSurf2D,
                   NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
        OUT_RING  (chan, format);
-       OUT_RING  (chan, ((dst->pitch * dst->cpp) << 16) | 
-                         (src->pitch * src->cpp));
+       OUT_RING  (chan, (dst->stride << 16) | src->stride);
        OUT_RELOCl(chan, nouveau_buffer(src->buffer)->bo, src->offset,
                   NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
        OUT_RELOCl(chan, nouveau_buffer(dst->buffer)->bo, dst->offset,
@@ -142,13 +150,13 @@ nv04_surface_fill(struct nouveau_context *nv, struct pipe_surface *dst,
        struct nouveau_grobj *rect = nv->nvc->NvGdiRect;
        int cs2d_format, gdirect_format;
 
-       if ((cs2d_format = nv04_surface_format(dst->cpp)) < 0) {
-               NOUVEAU_ERR("Bad cpp = %d\n", dst->cpp);
+       if ((cs2d_format = nv04_surface_format(dst->format)) < 0) {
+               NOUVEAU_ERR("Bad format = %d\n", dst->format);
                return 1;
        }
 
-       if ((gdirect_format = nv04_rect_format(dst->cpp)) < 0) {
-               NOUVEAU_ERR("Bad cpp = %d\n", dst->cpp);
+       if ((gdirect_format = nv04_rect_format(dst->format)) < 0) {
+               NOUVEAU_ERR("Bad format = %d\n", dst->format);
                return 1;
        }
 
@@ -159,8 +167,7 @@ nv04_surface_fill(struct nouveau_context *nv, struct pipe_surface *dst,
                   NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
        BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
        OUT_RING  (chan, cs2d_format);
-       OUT_RING  (chan, ((dst->pitch * dst->cpp) << 16) |
-                         (dst->pitch * dst->cpp));
+       OUT_RING  (chan, (dst->stride << 16) | dst->stride);
        OUT_RELOCl(chan, nouveau_buffer(dst->buffer)->bo, dst->offset,
                   NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
        OUT_RELOCl(chan, nouveau_buffer(dst->buffer)->bo, dst->offset,
index d6da116b774ea1e9dbfa9f7080644cbf54deb572..cf76d76cf528a701433468542fa73cb3597069e6 100644 (file)
@@ -1,15 +1,21 @@
 #include "pipe/p_context.h"
+#include "pipe/p_format.h"
 
 #include "nouveau_context.h"
 
 static INLINE int
-nv50_format(int cpp)
+nv50_format(enum pipe_format format)
 {
-       switch (cpp) {
-       case 4: return NV50_2D_DST_FORMAT_32BPP;
-       case 3: return NV50_2D_DST_FORMAT_24BPP;
-       case 2: return NV50_2D_DST_FORMAT_16BPP;
-       case 1: return NV50_2D_DST_FORMAT_8BPP;
+       switch (format) {
+       case PIPE_FORMAT_A8R8G8B8_UNORM:
+       case PIPE_FORMAT_Z24S8_UNORM:
+               return NV50_2D_DST_FORMAT_32BPP;
+       case PIPE_FORMAT_X8R8G8B8_UNORM:
+               return NV50_2D_DST_FORMAT_24BPP;
+       case PIPE_FORMAT_R5G6B5_UNORM:
+               return NV50_2D_DST_FORMAT_16BPP;
+       case PIPE_FORMAT_A8_UNORM:
+               return NV50_2D_DST_FORMAT_8BPP;
        default:
                return -1;
        }
@@ -23,9 +29,9 @@ nv50_surface_copy_prep(struct nouveau_context *nv,
        struct nouveau_grobj *eng2d = nv->nvc->Nv2D;
        int surf_format;
 
-       assert(src->cpp == dst->cpp);
+       assert(src->format == dst->format);
 
-       surf_format = nv50_format(dst->cpp);
+       surf_format = nv50_format(dst->format);
        assert(surf_format >= 0);
 
        BEGIN_RING(chan, eng2d, NV50_2D_DMA_IN_MEMORY0, 2);
@@ -38,8 +44,8 @@ nv50_surface_copy_prep(struct nouveau_context *nv,
        OUT_RING  (chan, surf_format);
        OUT_RING  (chan, 1);
        BEGIN_RING(chan, eng2d, NV50_2D_DST_PITCH, 5);
-       OUT_RING  (chan, dst->pitch * dst->cpp);
-       OUT_RING  (chan, dst->pitch);
+       OUT_RING  (chan, dst->stride);
+       OUT_RING  (chan, dst->width);
        OUT_RING  (chan, dst->height);
        OUT_RELOCh(chan, nouveau_buffer(dst->buffer)->bo, dst->offset,
                   NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
@@ -48,15 +54,15 @@ nv50_surface_copy_prep(struct nouveau_context *nv,
        BEGIN_RING(chan, eng2d, NV50_2D_CLIP_X, 4);
        OUT_RING  (chan, 0);
        OUT_RING  (chan, 0);
-       OUT_RING  (chan, dst->pitch);
+       OUT_RING  (chan, dst->width);
        OUT_RING  (chan, dst->height);
 
        BEGIN_RING(chan, eng2d, NV50_2D_SRC_FORMAT, 2);
        OUT_RING  (chan, surf_format);
        OUT_RING  (chan, 1);
        BEGIN_RING(chan, eng2d, NV50_2D_SRC_PITCH, 5);
-       OUT_RING  (chan, src->pitch * src->cpp);
-       OUT_RING  (chan, src->pitch);
+       OUT_RING  (chan, src->stride);
+       OUT_RING  (chan, src->width);
        OUT_RING  (chan, src->height);
        OUT_RELOCh(chan, nouveau_buffer(src->buffer)->bo, src->offset,
                   NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
@@ -105,11 +111,11 @@ nv50_surface_fill(struct nouveau_context *nv, struct pipe_surface *dst,
        struct nouveau_grobj *eng2d = nv->nvc->Nv2D;
        int surf_format, rect_format;
 
-       surf_format = nv50_format(dst->cpp);
+       surf_format = nv50_format(dst->format);
        if (surf_format < 0)
                return 1;
 
-       rect_format = nv50_format(dst->cpp);
+       rect_format = nv50_format(dst->format);
        if (rect_format < 0)
                return 1;
 
@@ -120,8 +126,8 @@ nv50_surface_fill(struct nouveau_context *nv, struct pipe_surface *dst,
        OUT_RING  (chan, surf_format);
        OUT_RING  (chan, 1);
        BEGIN_RING(chan, eng2d, NV50_2D_DST_PITCH, 5);
-       OUT_RING  (chan, dst->pitch * dst->cpp);
-       OUT_RING  (chan, dst->pitch);
+       OUT_RING  (chan, dst->stride);
+       OUT_RING  (chan, dst->width);
        OUT_RING  (chan, dst->height);
        OUT_RELOCh(chan, nouveau_buffer(dst->buffer)->bo, dst->offset,
                   NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
@@ -130,7 +136,7 @@ nv50_surface_fill(struct nouveau_context *nv, struct pipe_surface *dst,
        BEGIN_RING(chan, eng2d, NV50_2D_CLIP_X, 4);
        OUT_RING  (chan, 0);
        OUT_RING  (chan, 0);
-       OUT_RING  (chan, dst->pitch);
+       OUT_RING  (chan, dst->width);
        OUT_RING  (chan, dst->height);
 
        BEGIN_RING(chan, eng2d, 0x0580, 3);