1 #include "nv30_context.h"
2 #include "nv30_state.h"
4 static struct nv30_state_entry
*render_states
[] = {
5 &nv30_state_framebuffer
,
6 &nv30_state_rasterizer
,
13 &nv30_state_blend_colour
,
21 nv30_state_do_validate(struct nv30_context
*nv30
,
22 struct nv30_state_entry
**states
)
25 struct nv30_state_entry
*e
= *states
;
27 if (nv30
->dirty
& e
->dirty
.pipe
) {
28 if (e
->validate(nv30
)) {
29 nv30
->state
.dirty
|= (1ULL << e
->dirty
.hw
);
39 nv30_state_emit(struct nv30_context
*nv30
)
41 struct nouveau_channel
*chan
= nv30
->screen
->base
.channel
;
42 struct nv30_state
*state
= &nv30
->state
;
43 struct nv30_screen
*screen
= nv30
->screen
;
47 if (nv30
->pctx_id
!= screen
->cur_pctx
) {
48 for (i
= 0; i
< NV30_STATE_MAX
; i
++) {
49 if (state
->hw
[i
] && screen
->state
[i
] != state
->hw
[i
])
50 state
->dirty
|= (1ULL << i
);
53 screen
->cur_pctx
= nv30
->pctx_id
;
56 for (i
= 0, states
= state
->dirty
; states
; i
++) {
57 if (!(states
& (1ULL << i
)))
59 so_ref (state
->hw
[i
], &nv30
->screen
->state
[i
]);
61 so_emit(chan
, nv30
->screen
->state
[i
]);
62 states
&= ~(1ULL << i
);
67 so_emit_reloc_markers(chan
, state
->hw
[NV30_STATE_FB
]);
68 for (i
= 0, samplers
= state
->fp_samplers
; i
< 16 && samplers
; i
++) {
69 if (!(samplers
& (1 << i
)))
71 so_emit_reloc_markers(chan
,
72 state
->hw
[NV30_STATE_FRAGTEX0
+i
]);
73 samplers
&= ~(1ULL << i
);
75 so_emit_reloc_markers(chan
, state
->hw
[NV30_STATE_FRAGPROG
]);
76 if (state
->hw
[NV30_STATE_VTXBUF
] /*&& nv30->render_mode == HW*/)
77 so_emit_reloc_markers(chan
, state
->hw
[NV30_STATE_VTXBUF
]);
81 nv30_state_validate(struct nv30_context
*nv30
)
84 boolean was_sw
= nv30
->fallback_swtnl
? TRUE
: FALSE
;
86 if (nv30
->render_mode
!= HW
) {
87 /* Don't even bother trying to go back to hw if none
88 * of the states that caused swtnl previously have changed.
90 if ((nv30
->fallback_swtnl
& nv30
->dirty
)
91 != nv30
->fallback_swtnl
)
94 /* Attempt to go to hwtnl again */
95 nv30
->pipe
.flush(&nv30
->pipe
, 0, NULL
);
96 nv30
->dirty
|= (NV30_NEW_VIEWPORT
|
99 nv30
->render_mode
= HW
;
102 nv30_state_do_validate(nv30
, render_states
);
104 if (nv30
->fallback_swtnl
|| nv30
->fallback_swrast
)
108 NOUVEAU_ERR("swtnl->hw\n");