Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / src / gallium / drivers / nv40 / nv40_state_viewport.c
1 #include "nv40_context.h"
2
3 static boolean
4 nv40_state_viewport_validate(struct nv40_context *nv40)
5 {
6 struct nouveau_stateobj *so = so_new(11, 0);
7 struct pipe_viewport_state *vpt = &nv40->viewport;
8 unsigned bypass;
9
10 if (nv40->render_mode == HW && !nv40->rasterizer->pipe.bypass_clipping)
11 bypass = 0;
12 else
13 bypass = 1;
14
15 if (nv40->state.hw[NV40_STATE_VIEWPORT] &&
16 (bypass || !(nv40->dirty & NV40_NEW_VIEWPORT)) &&
17 nv40->state.viewport_bypass == bypass)
18 return FALSE;
19 nv40->state.viewport_bypass = bypass;
20
21 if (!bypass) {
22 so_method(so, nv40->screen->curie,
23 NV40TCL_VIEWPORT_TRANSLATE_X, 8);
24 so_data (so, fui(vpt->translate[0]));
25 so_data (so, fui(vpt->translate[1]));
26 so_data (so, fui(vpt->translate[2]));
27 so_data (so, fui(vpt->translate[3]));
28 so_data (so, fui(vpt->scale[0]));
29 so_data (so, fui(vpt->scale[1]));
30 so_data (so, fui(vpt->scale[2]));
31 so_data (so, fui(vpt->scale[3]));
32 so_method(so, nv40->screen->curie, 0x1d78, 1);
33 so_data (so, 1);
34 } else {
35 so_method(so, nv40->screen->curie,
36 NV40TCL_VIEWPORT_TRANSLATE_X, 8);
37 so_data (so, fui(0.0));
38 so_data (so, fui(0.0));
39 so_data (so, fui(0.0));
40 so_data (so, fui(0.0));
41 so_data (so, fui(1.0));
42 so_data (so, fui(1.0));
43 so_data (so, fui(1.0));
44 so_data (so, fui(0.0));
45 /* Not entirely certain what this is yet. The DDX uses this
46 * value also as it fixes rendering when you pass
47 * pre-transformed vertices to the GPU. My best gusss is that
48 * this bypasses some culling/clipping stage. Might be worth
49 * noting that points/lines are uneffected by whatever this
50 * value fixes, only filled polygons are effected.
51 */
52 so_method(so, nv40->screen->curie, 0x1d78, 1);
53 so_data (so, 0x110);
54 }
55
56 so_ref(so, &nv40->state.hw[NV40_STATE_VIEWPORT]);
57 return TRUE;
58 }
59
60 struct nv40_state_entry nv40_state_viewport = {
61 .validate = nv40_state_viewport_validate,
62 .dirty = {
63 .pipe = NV40_NEW_VIEWPORT | NV40_NEW_RAST,
64 .hw = NV40_STATE_VIEWPORT
65 }
66 };