Merge branch '7.8'
[mesa.git] / src / gallium / drivers / nvfx / nvfx_fragtex.c
1 #include "nvfx_context.h"
2
3 static boolean
4 nvfx_fragtex_validate(struct nvfx_context *nvfx)
5 {
6 struct nvfx_fragment_program *fp = nvfx->fragprog;
7 struct nvfx_state *state = &nvfx->state;
8 struct nouveau_stateobj *so;
9 unsigned samplers, unit;
10
11 samplers = state->fp_samplers & ~fp->samplers;
12 while (samplers) {
13 unit = ffs(samplers) - 1;
14 samplers &= ~(1 << unit);
15
16 so = so_new(1, 1, 0);
17 so_method(so, nvfx->screen->eng3d, NV34TCL_TX_ENABLE(unit), 1);
18 so_data (so, 0);
19 so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
20 so_ref(NULL, &so);
21 state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
22 }
23
24 samplers = nvfx->dirty_samplers & fp->samplers;
25 while (samplers) {
26 unit = ffs(samplers) - 1;
27 samplers &= ~(1 << unit);
28
29 if(!nvfx->is_nv4x)
30 so = nv30_fragtex_build(nvfx, unit);
31 else
32 so = nv40_fragtex_build(nvfx, unit);
33
34 so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
35 so_ref(NULL, &so);
36 state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
37 }
38
39 nvfx->state.fp_samplers = fp->samplers;
40 return FALSE;
41 }
42
43 struct nvfx_state_entry nvfx_state_fragtex = {
44 .validate = nvfx_fragtex_validate,
45 .dirty = {
46 .pipe = NVFX_NEW_SAMPLER | NVFX_NEW_FRAGPROG,
47 .hw = 0
48 }
49 };