Merge commit 'origin/gallium-0.1' into gallium-0.2
[mesa.git] / src / gallium / drivers / nv40 / nv40_state_scissor.c
1 #include "nv40_context.h"
2
3 static boolean
4 nv40_state_scissor_validate(struct nv40_context *nv40)
5 {
6 struct pipe_rasterizer_state *rast = &nv40->rasterizer->pipe;
7 struct pipe_scissor_state *s = &nv40->scissor;
8 struct nouveau_stateobj *so;
9
10 if (nv40->state.hw[NV40_STATE_SCISSOR] &&
11 (rast->scissor == 0 && nv40->state.scissor_enabled == 0))
12 return FALSE;
13 nv40->state.scissor_enabled = rast->scissor;
14
15 so = so_new(3, 0);
16 so_method(so, nv40->screen->curie, NV40TCL_SCISSOR_HORIZ, 2);
17 if (nv40->state.scissor_enabled) {
18 so_data (so, ((s->maxx - s->minx) << 16) | s->minx);
19 so_data (so, ((s->maxy - s->miny) << 16) | s->miny);
20 } else {
21 so_data (so, 4096 << 16);
22 so_data (so, 4096 << 16);
23 }
24
25 so_ref(so, &nv40->state.hw[NV40_STATE_SCISSOR]);
26 return TRUE;
27 }
28
29 struct nv40_state_entry nv40_state_scissor = {
30 .validate = nv40_state_scissor_validate,
31 .dirty = {
32 .pipe = NV40_NEW_SCISSOR | NV40_NEW_RAST,
33 .hw = NV40_STATE_SCISSOR
34 }
35 };