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
;
49 if (nv30
!= screen
->cur_ctx
) {
50 for (i
= 0; i
< NV30_STATE_MAX
; i
++) {
51 if (state
->hw
[i
] && screen
->state
[i
] != state
->hw
[i
])
52 state
->dirty
|= (1ULL << i
);
55 screen
->cur_ctx
= nv30
;
58 for (i
= 0, states
= state
->dirty
; states
; i
++) {
59 if (!(states
& (1ULL << i
)))
61 so_ref (state
->hw
[i
], &nv30
->screen
->state
[i
]);
63 so_emit(chan
, nv30
->screen
->state
[i
]);
64 states
&= ~(1ULL << i
);
71 nv30_state_flush_notify(struct nouveau_channel
*chan
)
73 struct nv30_context
*nv30
= chan
->user_private
;
74 struct nv30_state
*state
= &nv30
->state
;
77 so_emit_reloc_markers(chan
, state
->hw
[NV30_STATE_FB
]);
78 for (i
= 0, samplers
= state
->fp_samplers
; i
< 16 && samplers
; i
++) {
79 if (!(samplers
& (1 << i
)))
81 so_emit_reloc_markers(chan
,
82 state
->hw
[NV30_STATE_FRAGTEX0
+i
]);
83 samplers
&= ~(1ULL << i
);
85 so_emit_reloc_markers(chan
, state
->hw
[NV30_STATE_FRAGPROG
]);
86 if (state
->hw
[NV30_STATE_VTXBUF
] /*&& nv30->render_mode == HW*/)
87 so_emit_reloc_markers(chan
, state
->hw
[NV30_STATE_VTXBUF
]);
91 nv30_state_validate(struct nv30_context
*nv30
)
94 boolean was_sw
= nv30
->fallback_swtnl
? TRUE
: FALSE
;
96 if (nv30
->render_mode
!= HW
) {
97 /* Don't even bother trying to go back to hw if none
98 * of the states that caused swtnl previously have changed.
100 if ((nv30
->fallback_swtnl
& nv30
->dirty
)
101 != nv30
->fallback_swtnl
)
104 /* Attempt to go to hwtnl again */
105 nv30
->pipe
.flush(&nv30
->pipe
, 0, NULL
);
106 nv30
->dirty
|= (NV30_NEW_VIEWPORT
|
109 nv30
->render_mode
= HW
;
112 nv30_state_do_validate(nv30
, render_states
);
114 if (nv30
->fallback_swtnl
|| nv30
->fallback_swrast
)
118 NOUVEAU_ERR("swtnl->hw\n");