static Bool setup_texture(NVPtr pNv, int unit, PicturePtr pict, PixmapPtr pixmap) { struct nouveau_channel *chan = pNv->chan; struct nouveau_grobj *celsius = pNv->Nv3D; struct nouveau_bo *bo = nouveau_pixmap_bo(pixmap); unsigned tex_reloc = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; long w = pict->pDrawable->width, h = pict->pDrawable->height; unsigned int txfmt = NV10TCL_TX_FORMAT_WRAP_T_CLAMP_TO_EDGE | NV10TCL_TX_FORMAT_WRAP_S_CLAMP_TO_EDGE | log2i(w) << 20 | log2i(h) << 16 | 1 << 12 | /* lod == 1 */ get_tex_format(pict) | 0x50 /* UNK */; BEGIN_RING(chan, celsius, NV10TCL_TX_OFFSET(unit), 1); if (OUT_RELOCl(chan, bo, 0, tex_reloc)) return FALSE; if (pict->repeat == RepeatNone) { /* NPOT_SIZE expects an even number for width, we can * round up uneven numbers here because EXA always * gives 64 byte aligned pixmaps and for all formats * we support 64 bytes represents an even number of * pixels */ w = (w + 1) &~ 1; BEGIN_RING(chan, celsius, NV10TCL_TX_NPOT_PITCH(unit), 1); OUT_RING (chan, exaGetPixmapPitch(pixmap) << 16); BEGIN_RING(chan, celsius, NV10TCL_TX_NPOT_SIZE(unit), 1); OUT_RING (chan, w << 16 | h); } BEGIN_RING(chan, celsius, NV10TCL_TX_FORMAT(unit), 1 ); if (OUT_RELOCd(chan, bo, txfmt, tex_reloc | NOUVEAU_BO_OR, NV10TCL_TX_FORMAT_DMA0, NV10TCL_TX_FORMAT_DMA1)) return FALSE; BEGIN_RING(chan, celsius, NV10TCL_TX_ENABLE(unit), 1 ); OUT_RING (chan, NV10TCL_TX_ENABLE_ENABLE); BEGIN_RING(chan, celsius, NV10TCL_TX_FILTER(unit), 1); if (pict->filter == PictFilterNearest) OUT_RING(chan, (NV10TCL_TX_FILTER_MAGNIFY_NEAREST | NV10TCL_TX_FILTER_MINIFY_NEAREST)); else OUT_RING(chan, (NV10TCL_TX_FILTER_MAGNIFY_LINEAR | NV10TCL_TX_FILTER_MINIFY_LINEAR)); return TRUE; }
static void nv20_fragtex_build(struct nv20_context *nv20, int unit) { #if 0 struct nv20_sampler_state *ps = nv20->tex_sampler[unit]; struct nv20_miptree *nv20mt = nv20->tex_miptree[unit]; struct pipe_texture *pt = &nv20mt->base; struct nv20_texture_format *tf; uint32_t txf, txs, txp; tf = nv20_fragtex_format(pt->format); if (!tf || !tf->defined) { NOUVEAU_ERR("Unsupported texture format: 0x%x\n", pt->format); return; } txf = tf->format << 8; txf |= (pt->last_level + 1) << 16; txf |= log2i(pt->width[0]) << 20; txf |= log2i(pt->height[0]) << 24; txf |= log2i(pt->depth[0]) << 28; txf |= 8; switch (pt->target) { case PIPE_TEXTURE_CUBE: txf |= NV10TCL_TX_FORMAT_CUBE_MAP; /* fall-through */ case PIPE_TEXTURE_2D: txf |= (2<<4); break; case PIPE_TEXTURE_1D: txf |= (1<<4); break; default: NOUVEAU_ERR("Unknown target %d\n", pt->target); return; } BEGIN_RING(kelvin, NV10TCL_TX_OFFSET(unit), 8); OUT_RELOCl(nv20mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD); OUT_RELOCd(nv20mt->buffer,txf,NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/); OUT_RING (ps->wrap); OUT_RING (0x40000000); /* enable */ OUT_RING (txs); OUT_RING (ps->filt | 0x2000 /* magic */); OUT_RING ((pt->width[0] << 16) | pt->height[0]); OUT_RING (ps->bcol); #endif }