Merge branch 'mesa_7_7_branch'
[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(1, 2, 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 so_ref(NULL, &so);
27 return TRUE;
28 }
29
30 struct nv40_state_entry nv40_state_scissor = {
31 .validate = nv40_state_scissor_validate,
32 .dirty = {
33 .pipe = NV40_NEW_SCISSOR | NV40_NEW_RAST,
34 .hw = NV40_STATE_SCISSOR
35 }
36 };