summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nvfx/nvfx_fragtex.c
blob: 84e4eb1004299d8caea84e7e68919fc8ab9e1d55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "nvfx_context.h"

static boolean
nvfx_fragtex_validate(struct nvfx_context *nvfx)
{
	struct nvfx_fragment_program *fp = nvfx->fragprog;
	struct nvfx_state *state = &nvfx->state;
	struct nouveau_stateobj *so;
	unsigned samplers, unit;

	samplers = state->fp_samplers & ~fp->samplers;
	while (samplers) {
		unit = ffs(samplers) - 1;
		samplers &= ~(1 << unit);

		so = so_new(1, 1, 0);
		so_method(so, nvfx->screen->eng3d, NV34TCL_TX_ENABLE(unit), 1);
		so_data  (so, 0);
		so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
		so_ref(NULL, &so);
		state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
	}

	samplers = nvfx->dirty_samplers & fp->samplers;
	while (samplers) {
		unit = ffs(samplers) - 1;
		samplers &= ~(1 << unit);

		if(!nvfx->is_nv4x)
			so = nv30_fragtex_build(nvfx, unit);
		else
			so = nv40_fragtex_build(nvfx, unit);

		so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
		so_ref(NULL, &so);
		state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
	}

	nvfx->state.fp_samplers = fp->samplers;
	return FALSE;
}

struct nvfx_state_entry nvfx_state_fragtex = {
	.validate = nvfx_fragtex_validate,
	.dirty = {
		.pipe = NVFX_NEW_SAMPLER | NVFX_NEW_FRAGPROG,
		.hw = 0
	}
};