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
,
11 &nv30_state_blend_colour
,
18 nv30_state_do_validate(struct nv30_context
*nv30
,
19 struct nv30_state_entry
**states
)
21 const struct pipe_framebuffer_state
*fb
= &nv30
->framebuffer
;
24 for (i
= 0; i
< fb
->num_cbufs
; i
++)
25 fb
->cbufs
[i
]->status
= PIPE_SURFACE_STATUS_DEFINED
;
27 fb
->zsbuf
->status
= PIPE_SURFACE_STATUS_DEFINED
;
30 struct nv30_state_entry
*e
= *states
;
32 if (nv30
->dirty
& e
->dirty
.pipe
) {
33 if (e
->validate(nv30
)) {
34 nv30
->state
.dirty
|= (1ULL << e
->dirty
.hw
);
41 /* TODO: uncomment when finished converting
47 nv30_emit_hw_state(struct nv30_context
*nv30
)
49 struct nv30_state
*state
= &nv30
->state
;
50 struct nv30_screen
*screen
= nv30
->screen
;
54 if (nv30
->pctx_id
!= screen
->cur_pctx
) {
55 for (i
= 0; i
< NV30_STATE_MAX
; i
++) {
56 if (state
->hw
[i
] && screen
->state
[i
] != state
->hw
[i
])
57 state
->dirty
|= (1ULL << i
);
60 screen
->cur_pctx
= nv30
->pctx_id
;
63 if (nv30
->dirty
& NV30_NEW_FRAGPROG
) {
64 nv30_fragprog_bind(nv30
, nv30
->fragprog
.current
);
65 /*XXX: clear NV30_NEW_FRAGPROG if no new program uploaded */
68 for (i
= 0, states
= state
->dirty
; states
; i
++) {
69 if (!(states
& (1ULL << i
)))
71 so_ref (state
->hw
[i
], &nv30
->screen
->state
[i
]);
73 so_emit(nv30
->nvws
, nv30
->screen
->state
[i
]);
74 states
&= ~(1ULL << i
);
77 if (nv30
->dirty
& NV30_NEW_VERTPROG
) {
78 nv30_vertprog_bind(nv30
, nv30
->vertprog
.current
);
79 nv30
->dirty
&= ~NV30_NEW_VERTPROG
;
82 so_emit_reloc_markers(nv30
->nvws
, state
->hw
[NV30_STATE_FB
]);
83 for (i
= 0, samplers
= state
->fp_samplers
; i
< 16 && samplers
; i
++) {
84 if (!(samplers
& (1 << i
)))
86 so_emit_reloc_markers(nv30
->nvws
,
87 state
->hw
[NV30_STATE_FRAGTEX0
+i
]);
88 samplers
&= ~(1ULL << i
);
91 /* Fragment program */
92 BEGIN_RING(rankine
, NV34TCL_FP_ACTIVE_PROGRAM
, 1);
93 OUT_RELOC (nv30
->fragprog
.active
->buffer
, 0, NOUVEAU_BO_VRAM
|
94 NOUVEAU_BO_GART
| NOUVEAU_BO_RD
| NOUVEAU_BO_LOW
|
95 NOUVEAU_BO_OR
, NV34TCL_FP_ACTIVE_PROGRAM_DMA0
,
96 NV34TCL_FP_ACTIVE_PROGRAM_DMA1
);
100 nv30_state_validate(struct nv30_context
*nv30
)
103 boolean was_sw
= nv30
->fallback_swtnl
? TRUE
: FALSE
;
105 if (nv30
->render_mode
!= HW
) {
106 /* Don't even bother trying to go back to hw if none
107 * of the states that caused swtnl previously have changed.
109 if ((nv30
->fallback_swtnl
& nv30
->dirty
)
110 != nv30
->fallback_swtnl
)
113 /* Attempt to go to hwtnl again */
114 nv30
->pipe
.flush(&nv30
->pipe
, 0, NULL
);
115 nv30
->dirty
|= (NV30_NEW_VIEWPORT
|
118 nv30
->render_mode
= HW
;
121 nv30_state_do_validate(nv30
, render_states
);
123 if (nv30
->fallback_swtnl
|| nv30
->fallback_swrast
)
127 NOUVEAU_ERR("swtnl->hw\n");