glsl2: Add and use new variable mode ir_var_temporary
[mesa/nouveau-pmpeg.git] / src / gallium / drivers / nvfx / nvfx_fragtex.c
blob0b4a434feccf01a0ad9c15f991f8941d5737706f
1 #include "nvfx_context.h"
2 #include "nvfx_resource.h"
4 void
5 nvfx_fragtex_validate(struct nvfx_context *nvfx)
7 struct nouveau_channel* chan = nvfx->screen->base.channel;
8 unsigned samplers, unit;
10 samplers = nvfx->dirty_samplers;
11 if(!samplers)
12 return;
14 while (samplers) {
15 unit = ffs(samplers) - 1;
16 samplers &= ~(1 << unit);
18 if(nvfx->fragment_sampler_views[unit] && nvfx->tex_sampler[unit]) {
19 if(!nvfx->is_nv4x)
20 nv30_fragtex_set(nvfx, unit);
21 else
22 nv40_fragtex_set(nvfx, unit);
23 } else {
24 WAIT_RING(chan, 2);
25 /* this is OK for nv40 too */
26 OUT_RING(chan, RING_3D(NV34TCL_TX_ENABLE(unit), 1));
27 OUT_RING(chan, 0);
28 nvfx->hw_samplers &= ~(1 << unit);
31 nvfx->dirty_samplers = 0;
34 void
35 nvfx_fragtex_relocate(struct nvfx_context *nvfx)
37 struct nouveau_channel* chan = nvfx->screen->base.channel;
38 unsigned samplers, unit;
39 unsigned tex_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
41 samplers = nvfx->hw_samplers;
42 while (samplers) {
43 struct nvfx_miptree* mt;
44 struct nouveau_bo *bo;
46 unit = ffs(samplers) - 1;
47 samplers &= ~(1 << unit);
49 mt = (struct nvfx_miptree*)nvfx->fragment_sampler_views[unit]->texture;
50 bo = mt->base.bo;
52 MARK_RING(chan, 3, 3);
53 OUT_RELOC(chan, bo, RING_3D(NV34TCL_TX_OFFSET(unit), 2), tex_flags | NOUVEAU_BO_DUMMY, 0, 0);
54 OUT_RELOC(chan, bo, 0, tex_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_DUMMY, 0, 0);
55 OUT_RELOC(chan, bo, nvfx->hw_txf[unit], tex_flags | NOUVEAU_BO_OR | NOUVEAU_BO_DUMMY,
56 NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1);