nv30, nv40: unify identical nv[34]0_state_scissor.c
[mesa.git] / src / gallium / drivers / nvfx / nvfx_state_scissor.c
1 #include "nvfx_context.h"
2
3 static boolean
4 nvfx_state_scissor_validate(struct nvfx_context *nvfx)
5 {
6 struct pipe_rasterizer_state *rast = &nvfx->rasterizer->pipe;
7 struct pipe_scissor_state *s = &nvfx->scissor;
8 struct nouveau_stateobj *so;
9
10 if (nvfx->state.hw[NVFX_STATE_SCISSOR] &&
11 (rast->scissor == 0 && nvfx->state.scissor_enabled == 0))
12 return FALSE;
13 nvfx->state.scissor_enabled = rast->scissor;
14
15 so = so_new(1, 2, 0);
16 so_method(so, nvfx->screen->eng3d, NV34TCL_SCISSOR_HORIZ, 2);
17 if (nvfx->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, &nvfx->state.hw[NVFX_STATE_SCISSOR]);
26 so_ref(NULL, &so);
27 return TRUE;
28 }
29
30 struct nvfx_state_entry nvfx_state_scissor = {
31 .validate = nvfx_state_scissor_validate,
32 .dirty = {
33 .pipe = NVFX_NEW_SCISSOR | NVFX_NEW_RAST,
34 .hw = NVFX_STATE_SCISSOR
35 }
36 };