summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/nv40/nv40_surface.c
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2007-12-09 03:22:14 +1100
committerBen Skeggs <skeggsb@gmail.com>2007-12-09 12:12:50 +1100
commitb8965bee404cb36ccd97ac089fbd3ffc63268080 (patch)
treec303b5737dd51f9cecc79a76389b63dc79f9f8a8 /src/mesa/pipe/nv40/nv40_surface.c
parent274a3d9cb6a196c1b191769f581915cf5f8dccfe (diff)
nouveau: adapt to gallium interface changes
Diffstat (limited to 'src/mesa/pipe/nv40/nv40_surface.c')
-rw-r--r--src/mesa/pipe/nv40/nv40_surface.c114
1 files changed, 73 insertions, 41 deletions
diff --git a/src/mesa/pipe/nv40/nv40_surface.c b/src/mesa/pipe/nv40/nv40_surface.c
index 5292b5171f..b4562f26e6 100644
--- a/src/mesa/pipe/nv40/nv40_surface.c
+++ b/src/mesa/pipe/nv40/nv40_surface.c
@@ -56,15 +56,15 @@ nv40_get_tile_rgba(struct pipe_context *pipe,
uint x, uint y, uint w, uint h, float *p)
{
const unsigned *src
- = ((const unsigned *) (ps->region->map + ps->offset))
- + y * ps->region->pitch + x;
+ = ((const unsigned *) (ps->map + ps->offset))
+ + y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
CLIP_TILE;
switch (ps->format) {
- case PIPE_FORMAT_U_A8_R8_G8_B8:
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
for (i = 0; i < h; i++) {
float *pRow = p;
for (j = 0; j < w; j++) {
@@ -75,11 +75,11 @@ nv40_get_tile_rgba(struct pipe_context *pipe,
pRow[3] = UBYTE_TO_FLOAT((pixel >> 24) & 0xff);
pRow += 4;
}
- src += ps->region->pitch;
+ src += ps->pitch;
p += w0 * 4;
}
break;
- case PIPE_FORMAT_Z24_S8:
+ case PIPE_FORMAT_Z24S8_UNORM:
{
const float scale = 1.0 / (float) 0xffffff;
for (i = 0; i < h; i++) {
@@ -92,7 +92,7 @@ nv40_get_tile_rgba(struct pipe_context *pipe,
pRow[3] = ((pixel & 0xffffff) >> 8) * scale;
pRow += 4;
}
- src += ps->region->pitch;
+ src += ps->pitch;
p += w0 * 4;
}
}
@@ -122,13 +122,13 @@ nv40_get_tile(struct pipe_context *pipe,
uint x, uint y, uint w, uint h,
void *p, int dst_stride)
{
- const uint cpp = ps->region->cpp;
+ const uint cpp = ps->cpp;
const uint w0 = w;
const ubyte *pSrc;
ubyte *pDest;
uint i;
- assert(ps->region->map);
+ assert(ps->map);
CLIP_TILE;
@@ -136,13 +136,13 @@ nv40_get_tile(struct pipe_context *pipe,
dst_stride = w0 * cpp;
}
- pSrc = ps->region->map + ps->offset + (y * ps->region->pitch + x) * cpp;
+ pSrc = ps->map + ps->offset + (y * ps->pitch + x) * cpp;
pDest = (ubyte *) p;
for (i = 0; i < h; i++) {
memcpy(pDest, pSrc, w0 * cpp);
pDest += dst_stride;
- pSrc += ps->region->pitch * cpp;
+ pSrc += ps->pitch * cpp;
}
}
@@ -156,13 +156,13 @@ nv40_put_tile(struct pipe_context *pipe,
uint x, uint y, uint w, uint h,
const void *p, int src_stride)
{
- const uint cpp = ps->region->cpp;
+ const uint cpp = ps->cpp;
const uint w0 = w;
const ubyte *pSrc;
ubyte *pDest;
uint i;
- assert(ps->region->map);
+ assert(ps->map);
CLIP_TILE;
@@ -171,52 +171,81 @@ nv40_put_tile(struct pipe_context *pipe,
}
pSrc = (const ubyte *) p;
- pDest = ps->region->map + ps->offset + (y * ps->region->pitch + x) * cpp;
+ pDest = ps->map + ps->offset + (y * ps->pitch + x) * cpp;
for (i = 0; i < h; i++) {
memcpy(pDest, pSrc, w0 * cpp);
- pDest += ps->region->pitch * cpp;
+ pDest += ps->pitch * cpp;
pSrc += src_stride;
}
}
-/*
- * XXX note: same as code in sp_surface.c
- */
static struct pipe_surface *
nv40_get_tex_surface(struct pipe_context *pipe,
- struct pipe_mipmap_tree *mt,
+ struct pipe_texture *pt,
unsigned face, unsigned level, unsigned zslice)
{
- struct pipe_surface *ps;
- unsigned offset; /* in bytes */
+ struct pipe_winsys *ws = pipe->winsys;
+ struct nv40_miptree *nv40mt = (struct nv40_miptree *)pt;
+ struct pipe_surface *ps;
- offset = mt->level[level].level_offset;
+ ps = ws->surface_alloc(ws, pt->format);
+ if (!ps)
+ return NULL;
+ ws->buffer_reference(ws, &ps->buffer, nv40mt->buffer);
+ ps->cpp = pt->cpp;
+ ps->width = pt->width[level];
+ ps->height = pt->height[level];
+ ps->pitch = nv40mt->level[level].pitch / ps->cpp;
- if (mt->target == PIPE_TEXTURE_CUBE) {
- offset += mt->level[level].image_offset[face] * mt->cpp;
- }
- else if (mt->target == PIPE_TEXTURE_3D) {
- offset += mt->level[level].image_offset[zslice] * mt->cpp;
- }
- else {
- assert(face == 0);
- assert(zslice == 0);
- }
+ if (pt->target == PIPE_TEXTURE_CUBE) {
+ ps->offset = nv40mt->level[level].image_offset[face];
+ } else
+ if (pt->target == PIPE_TEXTURE_3D) {
+ ps->offset = nv40mt->level[level].image_offset[zslice];
+ } else {
+ ps->offset = nv40mt->level[level].image_offset[0];
+ }
- ps = pipe->winsys->surface_alloc(pipe->winsys, mt->format);
- if (ps) {
- assert(ps->format);
- assert(ps->refcount);
- pipe_region_reference(&ps->region, mt->region);
- ps->width = mt->level[level].width;
- ps->height = mt->level[level].height;
- ps->offset = offset;
- }
- return ps;
+ return ps;
}
+static void
+nv40_surface_data(struct pipe_context *pipe, struct pipe_surface *dest,
+ unsigned destx, unsigned desty, const void *src,
+ unsigned src_stride, unsigned srcx, unsigned srcy,
+ unsigned width, unsigned height)
+{
+ struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nouveau_winsys *nvws = nv40->nvws;
+
+ nvws->surface_data(nvws, dest, destx, desty, src, src_stride,
+ srcx, srcy, width, height);
+}
+
+static void
+nv40_surface_copy(struct pipe_context *pipe, struct pipe_surface *dest,
+ unsigned destx, unsigned desty, struct pipe_surface *src,
+ unsigned srcx, unsigned srcy, unsigned width, unsigned height)
+{
+ struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nouveau_winsys *nvws = nv40->nvws;
+
+ nvws->surface_copy(nvws, dest, destx, desty, src, srcx, srcy,
+ width, height);
+}
+
+static void
+nv40_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
+ unsigned destx, unsigned desty, unsigned width,
+ unsigned height, unsigned value)
+{
+ struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nouveau_winsys *nvws = nv40->nvws;
+
+ nvws->surface_fill(nvws, dest, destx, desty, width, height, value);
+}
void
nv40_init_surface_functions(struct nv40_context *nv40)
@@ -226,4 +255,7 @@ nv40_init_surface_functions(struct nv40_context *nv40)
nv40->pipe.put_tile = nv40_put_tile;
nv40->pipe.get_tile_rgba = nv40_get_tile_rgba;
nv40->pipe.put_tile_rgba = nv40_put_tile_rgba;
+ nv40->pipe.surface_data = nv40_surface_data;
+ nv40->pipe.surface_copy = nv40_surface_copy;
+ nv40->pipe.surface_fill = nv40_surface_fill;
}