2d7781292bdded0700ac0099689f18feab759d55
[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 &&*/
11 !nv30->rasterizer->pipe.bypass_vs_clip_and_viewport)
12 bypass = 0;
13 else
14 bypass = 1;
15
16 if (nv30->state.hw[NV30_STATE_VIEWPORT] &&
17 (bypass || !(nv30->dirty & NV30_NEW_VIEWPORT)) &&
18 nv30->state.viewport_bypass == bypass)
19 return FALSE;
20 nv30->state.viewport_bypass = bypass;
21
22 so = so_new(3, 10, 0);
23 if (!bypass) {
24 so_method(so, nv30->screen->rankine,
25 NV34TCL_VIEWPORT_TRANSLATE_X, 8);
26 so_data (so, fui(vpt->translate[0]));
27 so_data (so, fui(vpt->translate[1]));
28 so_data (so, fui(vpt->translate[2]));
29 so_data (so, fui(vpt->translate[3]));
30 so_data (so, fui(vpt->scale[0]));
31 so_data (so, fui(vpt->scale[1]));
32 so_data (so, fui(vpt->scale[2]));
33 so_data (so, fui(vpt->scale[3]));
34 /* so_method(so, nv30->screen->rankine, 0x1d78, 1);
35 so_data (so, 1);
36 */ } else {
37 so_method(so, nv30->screen->rankine,
38 NV34TCL_VIEWPORT_TRANSLATE_X, 8);
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(0.0));
43 so_data (so, fui(1.0));
44 so_data (so, fui(1.0));
45 so_data (so, fui(1.0));
46 so_data (so, fui(0.0));
47 /* Not entirely certain what this is yet. The DDX uses this
48 * value also as it fixes rendering when you pass
49 * pre-transformed vertices to the GPU. My best gusss is that
50 * this bypasses some culling/clipping stage. Might be worth
51 * noting that points/lines are uneffected by whatever this
52 * value fixes, only filled polygons are effected.
53 */
54 /* so_method(so, nv30->screen->rankine, 0x1d78, 1);
55 so_data (so, 0x110);
56 */ }
57 /* TODO/FIXME: never saw value 0x0110 in renouveau dumps, only 0x0001 */
58 so_method(so, nv30->screen->rankine, 0x1d78, 1);
59 so_data (so, 1);
60
61 so_ref(so, &nv30->state.hw[NV30_STATE_VIEWPORT]);
62 so_ref(NULL, &so);
63 return TRUE;
64 }
65
66 struct nv30_state_entry nv30_state_viewport = {
67 .validate = nv30_state_viewport_validate,
68 .dirty = {
69 .pipe = NV30_NEW_VIEWPORT | NV30_NEW_RAST,
70 .hw = NV30_STATE_VIEWPORT
71 }
72 };