Exemplo n.º 1
0
static void
nv30_transfer_rect_sifm(XFER_ARGS)

{
   struct nouveau_pushbuf *push = nv30->base.pushbuf;
   struct nouveau_pushbuf_refn refs[] = {
      { src->bo, src->domain | NOUVEAU_BO_RD },
      { dst->bo, dst->domain | NOUVEAU_BO_WR },
   };
   struct nv04_fifo *fifo = push->channel->data;
   unsigned si_fmt, si_arg;
   unsigned ss_fmt;

   switch (dst->cpp) {
   case 4: ss_fmt = NV04_SURFACE_SWZ_FORMAT_COLOR_A8R8G8B8; break;
   case 2: ss_fmt = NV04_SURFACE_SWZ_FORMAT_COLOR_R5G6B5; break;
   default:
      ss_fmt = NV04_SURFACE_SWZ_FORMAT_COLOR_Y8;
      break;
   }

   switch (src->cpp) {
   case 4: si_fmt = NV03_SIFM_COLOR_FORMAT_A8R8G8B8; break;
   case 2: si_fmt = NV03_SIFM_COLOR_FORMAT_R5G6B5; break;
   default:
      si_fmt = NV03_SIFM_COLOR_FORMAT_AY8;
      break;
   }

   if (filter == NEAREST) {
      si_arg  = NV03_SIFM_FORMAT_ORIGIN_CENTER;
      si_arg |= NV03_SIFM_FORMAT_FILTER_POINT_SAMPLE;
   } else {
      si_arg  = NV03_SIFM_FORMAT_ORIGIN_CORNER;
      si_arg |= NV03_SIFM_FORMAT_FILTER_BILINEAR;
   }

   if (nouveau_pushbuf_space(push, 32, 6, 0) ||
       nouveau_pushbuf_refn (push, refs, 2))
      return;

   if (dst->pitch) {
      BEGIN_NV04(push, NV04_SF2D(DMA_IMAGE_SOURCE), 2);
      PUSH_RELOC(push, dst->bo, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart);
      PUSH_RELOC(push, dst->bo, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart);
      BEGIN_NV04(push, NV04_SF2D(FORMAT), 4);
      PUSH_DATA (push, ss_fmt);
      PUSH_DATA (push, dst->pitch << 16 | dst->pitch);
      PUSH_RELOC(push, dst->bo, dst->offset, NOUVEAU_BO_LOW, 0, 0);
      PUSH_RELOC(push, dst->bo, dst->offset, NOUVEAU_BO_LOW, 0, 0);
      BEGIN_NV04(push, NV05_SIFM(SURFACE), 1);
      PUSH_DATA (push, nv30->screen->surf2d->handle);
   } else {
      BEGIN_NV04(push, NV04_SSWZ(DMA_IMAGE), 1);
      PUSH_RELOC(push, dst->bo, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart);
      BEGIN_NV04(push, NV04_SSWZ(FORMAT), 2);
      PUSH_DATA (push, ss_fmt | (util_logbase2(dst->w) << 16) |
                                (util_logbase2(dst->h) << 24));
      PUSH_RELOC(push, dst->bo, dst->offset, NOUVEAU_BO_LOW, 0, 0);
      BEGIN_NV04(push, NV05_SIFM(SURFACE), 1);
      PUSH_DATA (push, nv30->screen->swzsurf->handle);
   }

   BEGIN_NV04(push, NV03_SIFM(DMA_IMAGE), 1);
   PUSH_RELOC(push, src->bo, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart);
   BEGIN_NV04(push, NV03_SIFM(COLOR_FORMAT), 8);
   PUSH_DATA (push, si_fmt);
   PUSH_DATA (push, NV03_SIFM_OPERATION_SRCCOPY);
   PUSH_DATA (push, (           dst->y0  << 16) |            dst->x0);
   PUSH_DATA (push, ((dst->y1 - dst->y0) << 16) | (dst->x1 - dst->x0));
   PUSH_DATA (push, (           dst->y0  << 16) |            dst->x0);
   PUSH_DATA (push, ((dst->y1 - dst->y0) << 16) | (dst->x1 - dst->x0));
   PUSH_DATA (push, ((src->x1 - src->x0) << 20) / (dst->x1 - dst->x0));
   PUSH_DATA (push, ((src->y1 - src->y0) << 20) / (dst->y1 - dst->y0));
   BEGIN_NV04(push, NV03_SIFM(SIZE), 4);
   PUSH_DATA (push, align(src->h, 2) << 16 | align(src->w, 2));
   PUSH_DATA (push, src->pitch | si_arg);
   PUSH_RELOC(push, src->bo, src->offset, NOUVEAU_BO_LOW, 0, 0);
   PUSH_DATA (push, (src->y0 << 20) | src->x0 << 4);
}
Exemplo n.º 2
0
static void
nv04_surface_copy_swizzle(struct gl_context *ctx,
                          struct nouveau_surface *dst,
                          struct nouveau_surface *src,
                          int dx, int dy, int sx, int sy,
                          int w, int h)
{
    struct nouveau_pushbuf_refn refs[] = {
        { src->bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM | NOUVEAU_BO_GART },
        { dst->bo, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM },
    };
    struct nouveau_pushbuf *push = context_push(ctx);
    struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
    struct nouveau_object *swzsurf = hw->swzsurf;
    struct nv04_fifo *fifo = hw->chan->data;
    /* Max width & height may not be the same on all HW, but must be POT */
    const unsigned max_w = 1024;
    const unsigned max_h = 1024;
    unsigned sub_w = w > max_w ? max_w : w;
    unsigned sub_h = h > max_h ? max_h : h;
    unsigned x, y;

    /* Swizzled surfaces must be POT  */
    assert(_mesa_is_pow_two(dst->width) &&
           _mesa_is_pow_two(dst->height));

    if (context_chipset(ctx) < 0x10) {
        BEGIN_NV04(push, NV01_SUBC(SURF, OBJECT), 1);
        PUSH_DATA (push, swzsurf->handle);
    }

    for (y = 0; y < h; y += sub_h) {
        sub_h = MIN2(sub_h, h - y);

        for (x = 0; x < w; x += sub_w) {
            sub_w = MIN2(sub_w, w - x);

            if (nouveau_pushbuf_space(push, 64, 4, 0) ||
                    nouveau_pushbuf_refn (push, refs, 2))
                return;

            BEGIN_NV04(push, NV04_SSWZ(DMA_IMAGE), 1);
            PUSH_DATA (push, fifo->vram);
            BEGIN_NV04(push, NV04_SSWZ(FORMAT), 2);
            PUSH_DATA (push, swzsurf_format(dst->format) |
                       log2i(dst->width) << 16 |
                       log2i(dst->height) << 24);
            PUSH_RELOC(push, dst->bo, dst->offset, NOUVEAU_BO_LOW, 0, 0);

            BEGIN_NV04(push, NV03_SIFM(DMA_IMAGE), 1);
            PUSH_RELOC(push, src->bo, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart);
            BEGIN_NV04(push, NV05_SIFM(SURFACE), 1);
            PUSH_DATA (push, swzsurf->handle);

            BEGIN_NV04(push, NV03_SIFM(COLOR_FORMAT), 8);
            PUSH_DATA (push, sifm_format(src->format));
            PUSH_DATA (push, NV03_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY);
            PUSH_DATA (push, (y + dy) << 16 | (x + dx));
            PUSH_DATA (push, sub_h << 16 | sub_w);
            PUSH_DATA (push, (y + dy) << 16 | (x + dx));
            PUSH_DATA (push, sub_h << 16 | sub_w);
            PUSH_DATA (push, 1 << 20);
            PUSH_DATA (push, 1 << 20);

            BEGIN_NV04(push, NV03_SIFM(SIZE), 4);
            PUSH_DATA (push, align(sub_h, 2) << 16 | align(sub_w, 2));
            PUSH_DATA (push, src->pitch  |
                       NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER |
                       NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE);
            PUSH_RELOC(push, src->bo, src->offset + (y + sy) * src->pitch +
                       (x + sx) * src->cpp, NOUVEAU_BO_LOW, 0, 0);
            PUSH_DATA (push, 0);
        }
    }

    if (context_chipset(ctx) < 0x10) {
        BEGIN_NV04(push, NV01_SUBC(SURF, OBJECT), 1);
        PUSH_DATA (push, hw->surf3d->handle);
    }
}