1 #include "nv10_context.h"
2 #include "nouveau/nouveau_util.h"
8 NV10TCL_TX_FORMAT_FORMAT_##tf, \
11 struct nv10_texture_format
{
17 static struct nv10_texture_format
18 nv10_texture_formats
[] = {
19 _(A8R8G8B8_UNORM
, A8R8G8B8
),
20 _(A1R5G5B5_UNORM
, A1R5G5B5
),
21 _(A4R4G4B4_UNORM
, A4R4G4B4
),
24 _(A8L8_UNORM
, A8L8
),
25 // _(RGB_DXT1 , DXT1, ),
26 // _(RGBA_DXT1 , DXT1, ),
27 // _(RGBA_DXT3 , DXT3, ),
28 // _(RGBA_DXT5 , DXT5, ),
32 static struct nv10_texture_format
*
33 nv10_fragtex_format(uint pipe_format
)
35 struct nv10_texture_format
*tf
= nv10_texture_formats
;
38 if (tf
->pipe
== pipe_format
)
48 nv10_fragtex_build(struct nv10_context
*nv10
, int unit
)
51 struct nv10_sampler_state
*ps
= nv10
->tex_sampler
[unit
];
52 struct nv10_miptree
*nv10mt
= nv10
->tex_miptree
[unit
];
53 struct pipe_texture
*pt
= &nv10mt
->base
;
54 struct nv10_texture_format
*tf
;
55 uint32_t txf
, txs
, txp
;
57 tf
= nv10_fragtex_format(pt
->format
);
58 if (!tf
|| !tf
->defined
) {
59 NOUVEAU_ERR("Unsupported texture format: 0x%x\n", pt
->format
);
63 txf
= tf
->format
<< 8;
64 txf
|= (pt
->last_level
+ 1) << 16;
65 txf
|= log2i(pt
->width
[0]) << 20;
66 txf
|= log2i(pt
->height
[0]) << 24;
67 txf
|= log2i(pt
->depth
[0]) << 28;
71 case PIPE_TEXTURE_CUBE
:
72 txf
|= NV10TCL_TX_FORMAT_CUBE_MAP
;
81 NOUVEAU_ERR("Unknown target %d\n", pt
->target
);
85 BEGIN_RING(celsius
, NV10TCL_TX_OFFSET(unit
), 8);
86 OUT_RELOCl(nv10mt
->buffer
, 0, NOUVEAU_BO_VRAM
| NOUVEAU_BO_GART
| NOUVEAU_BO_RD
);
87 OUT_RELOCd(nv10mt
->buffer
,txf
,NOUVEAU_BO_VRAM
| NOUVEAU_BO_GART
| NOUVEAU_BO_OR
| NOUVEAU_BO_RD
, 1/*VRAM*/,2/*TT*/);
89 OUT_RING (0x40000000); /* enable */
91 OUT_RING (ps
->filt
| 0x2000 /* magic */);
92 OUT_RING ((pt
->width
[0] << 16) | pt
->height
[0]);
98 nv10_fragtex_bind(struct nv10_context
*nv10
)
101 struct nv10_fragment_program
*fp
= nv10
->fragprog
.active
;
102 unsigned samplers
, unit
;
104 samplers
= nv10
->fp_samplers
& ~fp
->samplers
;
106 unit
= ffs(samplers
) - 1;
107 samplers
&= ~(1 << unit
);
109 BEGIN_RING(celsius
, NV10TCL_TX_ENABLE(unit
), 1);
113 samplers
= nv10
->dirty_samplers
& fp
->samplers
;
115 unit
= ffs(samplers
) - 1;
116 samplers
&= ~(1 << unit
);
118 nv10_fragtex_build(nv10
, unit
);
121 nv10
->fp_samplers
= fp
->samplers
;