Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / src / mesa / pipe / nv40 / nv40_state_emit.c
1 #include "nv40_context.h"
2 #include "nv40_state.h"
3
4 /* Emit relocs for every referenced buffer.
5 *
6 * This is to ensure the bufmgr has an accurate idea of how
7 * the buffer is used. These relocs appear in the push buffer as
8 * NOPs, and will only be turned into state changes if a buffer
9 * actually moves.
10 */
11 static void
12 nv40_state_emit_dummy_relocs(struct nv40_context *nv40)
13 {
14 unsigned i;
15
16 so_emit_reloc_markers(nv40->nvws, nv40->so_framebuffer);
17 for (i = 0; i < 16; i++) {
18 if (!(nv40->fp_samplers & (1 << i)))
19 continue;
20 so_emit_reloc_markers(nv40->nvws, nv40->so_fragtex[i]);
21 }
22 so_emit_reloc_markers(nv40->nvws, nv40->fragprog.active->so);
23 }
24
25 void
26 nv40_emit_hw_state(struct nv40_context *nv40)
27 {
28 if (nv40->dirty & NV40_NEW_FB)
29 so_emit(nv40->nvws, nv40->so_framebuffer);
30
31 if (nv40->dirty & NV40_NEW_BLEND)
32 so_emit(nv40->nvws, nv40->so_blend);
33
34 if (nv40->dirty & NV40_NEW_RAST)
35 so_emit(nv40->nvws, nv40->so_rast);
36
37 if (nv40->dirty & NV40_NEW_ZSA)
38 so_emit(nv40->nvws, nv40->so_zsa);
39
40 if (nv40->dirty & NV40_NEW_BCOL)
41 so_emit(nv40->nvws, nv40->so_bcol);
42
43 if (nv40->dirty & NV40_NEW_SCISSOR)
44 so_emit(nv40->nvws, nv40->so_scissor);
45
46 if (nv40->dirty & NV40_NEW_VIEWPORT)
47 so_emit(nv40->nvws, nv40->so_viewport);
48
49 if (nv40->dirty & NV40_NEW_STIPPLE)
50 so_emit(nv40->nvws, nv40->so_stipple);
51
52 if (nv40->dirty & NV40_NEW_FRAGPROG) {
53 nv40_fragprog_bind(nv40, nv40->fragprog.current);
54 /*XXX: clear NV40_NEW_FRAGPROG if no new program uploaded */
55 }
56
57 if (nv40->dirty_samplers || (nv40->dirty & NV40_NEW_FRAGPROG)) {
58 nv40_fragtex_bind(nv40);
59
60 BEGIN_RING(curie, NV40TCL_TEX_CACHE_CTL, 1);
61 OUT_RING (2);
62 BEGIN_RING(curie, NV40TCL_TEX_CACHE_CTL, 1);
63 OUT_RING (1);
64 nv40->dirty &= ~NV40_NEW_FRAGPROG;
65 }
66
67 if (nv40->dirty & NV40_NEW_VERTPROG) {
68 nv40_vertprog_bind(nv40, nv40->vertprog.current);
69 nv40->dirty &= ~NV40_NEW_VERTPROG;
70 }
71
72 nv40->dirty_samplers = 0;
73 nv40->dirty = 0;
74
75 nv40_state_emit_dummy_relocs(nv40);
76 }
77