Merge commit 'origin/gallium-master-merge'
[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 pipe_viewport_state *vpt = &nv40->viewport;
7 struct nouveau_stateobj *so;
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 so = so_new(11, 0);
22 if (!bypass) {
23 so_method(so, nv40->screen->curie,
24 NV40TCL_VIEWPORT_TRANSLATE_X, 8);
25 so_data (so, fui(vpt->translate[0]));
26 so_data (so, fui(vpt->translate[1]));
27 so_data (so, fui(vpt->translate[2]));
28 so_data (so, fui(vpt->translate[3]));
29 so_data (so, fui(vpt->scale[0]));
30 so_data (so, fui(vpt->scale[1]));
31 so_data (so, fui(vpt->scale[2]));
32 so_data (so, fui(vpt->scale[3]));
33 so_method(so, nv40->screen->curie, 0x1d78, 1);
34 so_data (so, 1);
35 } else {
36 so_method(so, nv40->screen->curie,
37 NV40TCL_VIEWPORT_TRANSLATE_X, 8);
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(0.0));
42 so_data (so, fui(1.0));
43 so_data (so, fui(1.0));
44 so_data (so, fui(1.0));
45 so_data (so, fui(0.0));
46 /* Not entirely certain what this is yet. The DDX uses this
47 * value also as it fixes rendering when you pass
48 * pre-transformed vertices to the GPU. My best gusss is that
49 * this bypasses some culling/clipping stage. Might be worth
50 * noting that points/lines are uneffected by whatever this
51 * value fixes, only filled polygons are effected.
52 */
53 so_method(so, nv40->screen->curie, 0x1d78, 1);
54 so_data (so, 0x110);
55 }
56
57 so_ref(so, &nv40->state.hw[NV40_STATE_VIEWPORT]);
58 return TRUE;
59 }
60
61 struct nv40_state_entry nv40_state_viewport = {
62 .validate = nv40_state_viewport_validate,
63 .dirty = {
64 .pipe = NV40_NEW_VIEWPORT | NV40_NEW_RAST,
65 .hw = NV40_STATE_VIEWPORT
66 }
67 };