summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nv50/nv50_transfer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/nv50/nv50_transfer.c')
-rw-r--r--src/gallium/drivers/nv50/nv50_transfer.c82
1 files changed, 45 insertions, 37 deletions
diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c
index 747195b4f6..d0b7f0bef4 100644
--- a/src/gallium/drivers/nv50/nv50_transfer.c
+++ b/src/gallium/drivers/nv50/nv50_transfer.c
@@ -6,8 +6,8 @@
struct nv50_transfer {
struct pipe_transfer base;
- struct pipe_buffer *buffer;
- struct nv50_miptree_level *level;
+ struct nouveau_bo *bo;
+ unsigned level_offset;
int level_pitch;
int level_width;
int level_height;
@@ -16,51 +16,48 @@ struct nv50_transfer {
};
static void
-nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src,
- int src_pitch, int sx, int sy, int sw, int sh,
- struct pipe_buffer *dst, int dst_pitch, int dx, int dy,
+nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct nouveau_bo *src_bo,
+ unsigned src_offset, int src_pitch, int sx, int sy,
+ int sw, int sh, struct nouveau_bo *dst_bo,
+ unsigned dst_offset, int dst_pitch, int dx, int dy,
int dw, int dh, int cpp, int width, int height,
unsigned src_reloc, unsigned dst_reloc)
{
struct nv50_screen *screen = nv50_screen(pscreen);
- struct nouveau_winsys *nvws = screen->nvws;
- struct nouveau_channel *chan = nvws->channel;
+ struct nouveau_channel *chan = screen->m2mf->channel;
struct nouveau_grobj *m2mf = screen->m2mf;
- struct nouveau_bo *src_bo = nvws->get_bo(src);
- struct nouveau_bo *dst_bo = nvws->get_bo(dst);
- unsigned src_offset = 0, dst_offset = 0;
src_reloc |= NOUVEAU_BO_RD;
dst_reloc |= NOUVEAU_BO_WR;
WAIT_RING (chan, 14);
- if (!src_bo->tiled) {
+ if (!src_bo->tile_flags) {
BEGIN_RING(chan, m2mf, 0x0200, 1);
OUT_RING (chan, 1);
BEGIN_RING(chan, m2mf, 0x0314, 1);
OUT_RING (chan, src_pitch);
- src_offset = (sy * src_pitch) + (sx * cpp);
+ src_offset += (sy * src_pitch) + (sx * cpp);
} else {
BEGIN_RING(chan, m2mf, 0x0200, 6);
OUT_RING (chan, 0);
- OUT_RING (chan, 0);
+ OUT_RING (chan, src_bo->tile_mode << 4);
OUT_RING (chan, sw * cpp);
OUT_RING (chan, sh);
OUT_RING (chan, 1);
OUT_RING (chan, 0);
}
- if (!dst_bo->tiled) {
+ if (!dst_bo->tile_flags) {
BEGIN_RING(chan, m2mf, 0x021c, 1);
OUT_RING (chan, 1);
BEGIN_RING(chan, m2mf, 0x0318, 1);
OUT_RING (chan, dst_pitch);
- dst_offset = (dy * dst_pitch) + (dx * cpp);
+ dst_offset += (dy * dst_pitch) + (dx * cpp);
} else {
BEGIN_RING(chan, m2mf, 0x021c, 6);
OUT_RING (chan, 0);
- OUT_RING (chan, 0);
+ OUT_RING (chan, dst_bo->tile_mode << 4);
OUT_RING (chan, dw * cpp);
OUT_RING (chan, dh);
OUT_RING (chan, 1);
@@ -77,13 +74,13 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src,
BEGIN_RING(chan, m2mf, 0x030c, 2);
OUT_RELOCl(chan, src_bo, src_offset, src_reloc);
OUT_RELOCl(chan, dst_bo, dst_offset, dst_reloc);
- if (src_bo->tiled) {
+ if (src_bo->tile_flags) {
BEGIN_RING(chan, m2mf, 0x0218, 1);
OUT_RING (chan, (dy << 16) | sx);
} else {
src_offset += (line_count * src_pitch);
}
- if (dst_bo->tiled) {
+ if (dst_bo->tile_flags) {
BEGIN_RING(chan, m2mf, 0x0234, 1);
OUT_RING (chan, (sy << 16) | dx);
} else {
@@ -108,10 +105,12 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
enum pipe_transfer_usage usage,
unsigned x, unsigned y, unsigned w, unsigned h)
{
+ struct nouveau_device *dev = nouveau_screen(pscreen)->device;
struct nv50_miptree *mt = nv50_miptree(pt);
struct nv50_miptree_level *lvl = &mt->level[level];
struct nv50_transfer *tx;
unsigned image = 0;
+ int ret;
if (pt->target == PIPE_TEXTURE_CUBE)
image = face;
@@ -133,20 +132,24 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
tx->base.stride = (w * pt->block.size);
tx->base.usage = usage;
- tx->level = lvl;
tx->level_pitch = lvl->pitch;
tx->level_width = mt->base.width[level];
tx->level_height = mt->base.height[level];
+ tx->level_offset = lvl->image_offset[image];
tx->level_x = x;
tx->level_y = y;
- tx->buffer =
- pipe_buffer_create(pscreen, 0, NOUVEAU_BUFFER_USAGE_TRANSFER,
- w * tx->base.block.size * h);
+ ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0,
+ w * pt->block.size * h, &tx->bo);
+ if (ret) {
+ FREE(tx);
+ return NULL;
+ }
if (usage != PIPE_TRANSFER_WRITE) {
- nv50_transfer_rect_m2mf(pscreen, mt->buffer, tx->level_pitch,
- x, y, tx->level_width, tx->level_height,
- tx->buffer, tx->base.stride, 0, 0,
+ nv50_transfer_rect_m2mf(pscreen, mt->bo, tx->level_offset,
+ tx->level_pitch, x, y, tx->level_width,
+ tx->level_height, tx->bo, 0,
+ tx->base.stride, 0, 0,
tx->base.width, tx->base.height,
tx->base.block.size, w, h,
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART,
@@ -164,17 +167,18 @@ nv50_transfer_del(struct pipe_transfer *ptx)
if (ptx->usage != PIPE_TRANSFER_READ) {
struct pipe_screen *pscreen = ptx->texture->screen;
- nv50_transfer_rect_m2mf(pscreen, tx->buffer, tx->base.stride,
+ nv50_transfer_rect_m2mf(pscreen, tx->bo, 0, tx->base.stride,
0, 0, tx->base.width, tx->base.height,
- mt->buffer, tx->level_pitch,
- tx->level_x, tx->level_y,
- tx->level_width, tx->level_height,
- tx->base.block.size, tx->base.width,
- tx->base.height, NOUVEAU_BO_GART,
- NOUVEAU_BO_VRAM | NOUVEAU_BO_GART);
+ mt->bo, tx->level_offset,
+ tx->level_pitch, tx->level_x,
+ tx->level_y, tx->level_width,
+ tx->level_height, tx->base.block.size,
+ tx->base.width, tx->base.height,
+ NOUVEAU_BO_GART, NOUVEAU_BO_VRAM |
+ NOUVEAU_BO_GART);
}
- pipe_buffer_reference(&tx->buffer, NULL);
+ nouveau_bo_ref(NULL, &tx->bo);
pipe_texture_reference(&ptx->texture, NULL);
FREE(ptx);
}
@@ -184,13 +188,17 @@ nv50_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
{
struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
unsigned flags = 0;
+ int ret;
if (ptx->usage & PIPE_TRANSFER_WRITE)
- flags |= PIPE_BUFFER_USAGE_CPU_WRITE;
+ flags |= NOUVEAU_BO_WR;
if (ptx->usage & PIPE_TRANSFER_READ)
- flags |= PIPE_BUFFER_USAGE_CPU_READ;
+ flags |= NOUVEAU_BO_RD;
- return pipe_buffer_map(pscreen, tx->buffer, flags);
+ ret = nouveau_bo_map(tx->bo, flags);
+ if (ret)
+ return NULL;
+ return tx->bo->map;
}
static void
@@ -198,7 +206,7 @@ nv50_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
{
struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
- pipe_buffer_unmap(pscreen, tx->buffer);
+ nouveau_bo_unmap(tx->bo);
}
void