Merge branch '7.8'
[mesa.git] / src / gallium / drivers / nvfx / nvfx_fragtex.c
1 #include "nvfx_context.h"
2 #include "nvfx_resource.h"
3
4 void
5 nvfx_fragtex_validate(struct nvfx_context *nvfx)
6 {
7 struct nouveau_channel* chan = nvfx->screen->base.channel;
8 unsigned samplers, unit;
9
10 samplers = nvfx->dirty_samplers;
11 if(!samplers)
12 return;
13
14 while (samplers) {
15 unit = ffs(samplers) - 1;
16 samplers &= ~(1 << unit);
17
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);
29 }
30 }
31 nvfx->dirty_samplers = 0;
32 }
33
34 void
35 nvfx_fragtex_relocate(struct nvfx_context *nvfx)
36 {
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;
40
41 samplers = nvfx->hw_samplers;
42 while (samplers) {
43 unit = ffs(samplers) - 1;
44 samplers &= ~(1 << unit);
45
46 struct nvfx_miptree* mt = (struct nvfx_miptree*)nvfx->fragment_sampler_views[unit]->texture;
47 struct nouveau_bo *bo = mt->base.bo;
48
49 MARK_RING(chan, 3, 3);
50 OUT_RELOC(chan, bo, RING_3D(NV34TCL_TX_OFFSET(unit), 2), tex_flags | NOUVEAU_BO_DUMMY, 0, 0);
51 OUT_RELOC(chan, bo, 0, tex_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_DUMMY, 0, 0);
52 OUT_RELOC(chan, bo, nvfx->hw_txf[unit], tex_flags | NOUVEAU_BO_OR | NOUVEAU_BO_DUMMY,
53 NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1);
54 }
55 }