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
,
9 &nv30_state_blend_colour
,
15 nv30_state_do_validate(struct nv30_context
*nv30
,
16 struct nv30_state_entry
**states
)
18 const struct pipe_framebuffer_state
*fb
= &nv30
->framebuffer
;
21 for (i
= 0; i
< fb
->num_cbufs
; i
++)
22 fb
->cbufs
[i
]->status
= PIPE_SURFACE_STATUS_DEFINED
;
24 fb
->zsbuf
->status
= PIPE_SURFACE_STATUS_DEFINED
;
27 struct nv30_state_entry
*e
= *states
;
29 if (nv30
->dirty
& e
->dirty
.pipe
) {
30 if (e
->validate(nv30
)) {
31 nv30
->state
.dirty
|= (1ULL << e
->dirty
.hw
);
38 /* TODO: uncomment when finished converting
44 nv30_emit_hw_state(struct nv30_context
*nv30
)
46 struct nv30_state
*state
= &nv30
->state
;
50 for (i
= 0, states
= state
->dirty
; states
; i
++) {
51 if (!(states
& (1ULL << i
)))
53 so_ref (state
->hw
[i
], &nv30
->screen
->state
[i
]);
55 so_emit(nv30
->nvws
, nv30
->screen
->state
[i
]);
56 states
&= ~(1ULL << i
);
59 if (nv30
->dirty
& NV30_NEW_FRAGPROG
) {
60 nv30_fragprog_bind(nv30
, nv30
->fragprog
.current
);
61 /*XXX: clear NV30_NEW_FRAGPROG if no new program uploaded */
64 if (nv30
->dirty_samplers
|| (nv30
->dirty
& NV30_NEW_FRAGPROG
)) {
65 nv30_fragtex_bind(nv30
);
67 BEGIN_RING(rankine, NV34TCL_TX_CACHE_CTL, 1);
69 BEGIN_RING(rankine, NV34TCL_TX_CACHE_CTL, 1);
71 nv30
->dirty
&= ~NV30_NEW_FRAGPROG
;
74 if (nv30
->dirty
& NV30_NEW_VERTPROG
) {
75 nv30_vertprog_bind(nv30
, nv30
->vertprog
.current
);
76 nv30
->dirty
&= ~NV30_NEW_VERTPROG
;
79 nv30
->dirty_samplers
= 0;
81 so_emit_reloc_markers(nv30
->nvws
, state
->hw
[NV30_STATE_FB
]);
83 /* Texture images, emitted in nv30_fragtex_build */
85 for (i
= 0; i
< 16; i
++) {
86 if (!(nv30
->fp_samplers
& (1 << i
)))
88 BEGIN_RING(rankine
, NV34TCL_TX_OFFSET(i
), 2);
89 OUT_RELOCl(nv30
->tex
[i
].buffer
, 0, NOUVEAU_BO_VRAM
|
90 NOUVEAU_BO_GART
| NOUVEAU_BO_RD
);
91 OUT_RELOCd(nv30
->tex
[i
].buffer
, nv30
->tex
[i
].format
,
92 NOUVEAU_BO_VRAM
| NOUVEAU_BO_GART
| NOUVEAU_BO_RD
|
93 NOUVEAU_BO_OR
, NV34TCL_TX_FORMAT_DMA0
,
94 NV34TCL_TX_FORMAT_DMA1
);
98 /* Fragment program */
99 BEGIN_RING(rankine
, NV34TCL_FP_ACTIVE_PROGRAM
, 1);
100 OUT_RELOC (nv30
->fragprog
.active
->buffer
, 0, NOUVEAU_BO_VRAM
|
101 NOUVEAU_BO_GART
| NOUVEAU_BO_RD
| NOUVEAU_BO_LOW
|
102 NOUVEAU_BO_OR
, NV34TCL_FP_ACTIVE_PROGRAM_DMA0
,
103 NV34TCL_FP_ACTIVE_PROGRAM_DMA1
);
107 nv30_state_validate(struct nv30_context
*nv30
)
110 boolean was_sw
= nv30
->fallback_swtnl
? TRUE
: FALSE
;
112 if (nv30
->render_mode
!= HW
) {
113 /* Don't even bother trying to go back to hw if none
114 * of the states that caused swtnl previously have changed.
116 if ((nv30
->fallback_swtnl
& nv30
->dirty
)
117 != nv30
->fallback_swtnl
)
120 /* Attempt to go to hwtnl again */
121 nv30
->pipe
.flush(&nv30
->pipe
, 0, NULL
);
122 nv30
->dirty
|= (NV30_NEW_VIEWPORT
|
125 nv30
->render_mode
= HW
;
128 nv30_state_do_validate(nv30
, render_states
);
130 if (nv30
->fallback_swtnl
|| nv30
->fallback_swrast
)
134 NOUVEAU_ERR("swtnl->hw\n");