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
,
22 nv30_state_do_validate(struct nv30_context
*nv30
,
23 struct nv30_state_entry
**states
)
26 struct nv30_state_entry
*e
= *states
;
28 if (nv30
->dirty
& e
->dirty
.pipe
) {
29 if (e
->validate(nv30
)) {
30 nv30
->state
.dirty
|= (1ULL << e
->dirty
.hw
);
40 nv30_state_emit(struct nv30_context
*nv30
)
42 struct nouveau_channel
*chan
= nv30
->screen
->base
.channel
;
43 struct nv30_state
*state
= &nv30
->state
;
44 struct nv30_screen
*screen
= nv30
->screen
;
50 if (nv30
!= screen
->cur_ctx
) {
51 for (i
= 0; i
< NV30_STATE_MAX
; i
++) {
52 if (state
->hw
[i
] && screen
->state
[i
] != state
->hw
[i
])
53 state
->dirty
|= (1ULL << i
);
56 screen
->cur_ctx
= nv30
;
59 for (i
= 0, states
= state
->dirty
; states
; i
++) {
60 if (!(states
& (1ULL << i
)))
62 so_ref (state
->hw
[i
], &nv30
->screen
->state
[i
]);
64 so_emit(chan
, nv30
->screen
->state
[i
]);
65 states
&= ~(1ULL << i
);
72 nv30_state_flush_notify(struct nouveau_channel
*chan
)
74 struct nv30_context
*nv30
= chan
->user_private
;
75 struct nv30_state
*state
= &nv30
->state
;
78 so_emit_reloc_markers(chan
, state
->hw
[NV30_STATE_FB
]);
79 for (i
= 0, samplers
= state
->fp_samplers
; i
< 16 && samplers
; i
++) {
80 if (!(samplers
& (1 << i
)))
82 so_emit_reloc_markers(chan
,
83 state
->hw
[NV30_STATE_FRAGTEX0
+i
]);
84 samplers
&= ~(1ULL << i
);
86 so_emit_reloc_markers(chan
, state
->hw
[NV30_STATE_FRAGPROG
]);
87 if (state
->hw
[NV30_STATE_VTXBUF
] /*&& nv30->render_mode == HW*/)
88 so_emit_reloc_markers(chan
, state
->hw
[NV30_STATE_VTXBUF
]);
92 nv30_state_validate(struct nv30_context
*nv30
)
95 boolean was_sw
= nv30
->fallback_swtnl
? TRUE
: FALSE
;
97 if (nv30
->render_mode
!= HW
) {
98 /* Don't even bother trying to go back to hw if none
99 * of the states that caused swtnl previously have changed.
101 if ((nv30
->fallback_swtnl
& nv30
->dirty
)
102 != nv30
->fallback_swtnl
)
105 /* Attempt to go to hwtnl again */
106 nv30
->pipe
.flush(&nv30
->pipe
, 0, NULL
);
107 nv30
->dirty
|= (NV30_NEW_VIEWPORT
|
110 nv30
->render_mode
= HW
;
113 nv30_state_do_validate(nv30
, render_states
);
115 if (nv30
->fallback_swtnl
|| nv30
->fallback_swrast
)
119 NOUVEAU_ERR("swtnl->hw\n");