Merge commit 'origin/master' into gallium-0.2
[mesa.git] / src / gallium / drivers / nv30 / nv30_state_viewport.c
1 #include "nv30_context.h"
2
3 static boolean
4 nv30_state_viewport_validate(struct nv30_context *nv30)
5 {
6 struct pipe_viewport_state *vpt = &nv30->viewport;
7 struct nouveau_stateobj *so;
8 unsigned bypass;
9
10 if (/*nv30->render_mode == HW &&*/ !nv30->rasterizer->pipe.bypass_clipping)
11 bypass = 0;
12 else
13 bypass = 1;
14
15 if (nv30->state.hw[NV30_STATE_VIEWPORT] &&
16 (bypass || !(nv30->dirty & NV30_NEW_VIEWPORT)) &&
17 nv30->state.viewport_bypass == bypass)
18 return FALSE;
19 nv30->state.viewport_bypass = bypass;
20
21 so = so_new(11, 0);
22 if (!bypass) {
23 so_method(so, nv30->screen->rankine,
24 NV34TCL_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, nv30->screen->rankine, 0x1d78, 1);
34 so_data (so, 1);
35 */ } else {
36 so_method(so, nv30->screen->rankine,
37 NV34TCL_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, nv30->screen->rankine, 0x1d78, 1);
54 so_data (so, 0x110);
55 */ }
56 /* TODO/FIXME: never saw value 0x0110 in renouveau dumps, only 0x0001 */
57 so_method(so, nv30->screen->rankine, 0x1d78, 1);
58 so_data (so, 1);
59
60 so_ref(so, &nv30->state.hw[NV30_STATE_VIEWPORT]);
61 return TRUE;
62 }
63
64 struct nv30_state_entry nv30_state_viewport = {
65 .validate = nv30_state_viewport_validate,
66 .dirty = {
67 .pipe = NV30_NEW_VIEWPORT | NV30_NEW_RAST,
68 .hw = NV30_STATE_VIEWPORT
69 }
70 };