Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / src / mesa / pipe / nv40 / nv40_context.h
1 #ifndef __NV40_CONTEXT_H__
2 #define __NV40_CONTEXT_H__
3
4 #include "pipe/p_context.h"
5 #include "pipe/p_defines.h"
6 #include "pipe/p_state.h"
7
8 #include "pipe/draw/draw_vertex.h"
9
10 #include "pipe/nouveau/nouveau_winsys.h"
11 #include "pipe/nouveau/nouveau_gldefs.h"
12
13 #define NOUVEAU_PUSH_CONTEXT(ctx) \
14 struct nv40_channel_context *ctx = nv40->hw
15 #include "pipe/nouveau/nouveau_push.h"
16 #include "pipe/nouveau/nouveau_stateobj.h"
17
18 #include "nv40_state.h"
19
20 #define NOUVEAU_ERR(fmt, args...) \
21 fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
22 #define NOUVEAU_MSG(fmt, args...) \
23 fprintf(stderr, "nouveau: "fmt, ##args);
24
25 #define NV40_NEW_BLEND (1 << 0)
26 #define NV40_NEW_RAST (1 << 1)
27 #define NV40_NEW_ZSA (1 << 2)
28 #define NV40_NEW_SAMPLER (1 << 3)
29 #define NV40_NEW_FB (1 << 4)
30 #define NV40_NEW_STIPPLE (1 << 5)
31 #define NV40_NEW_SCISSOR (1 << 6)
32 #define NV40_NEW_VIEWPORT (1 << 7)
33 #define NV40_NEW_BCOL (1 << 8)
34 #define NV40_NEW_VERTPROG (1 << 9)
35 #define NV40_NEW_FRAGPROG (1 << 10)
36 #define NV40_NEW_ARRAYS (1 << 11)
37
38 struct nv40_channel_context {
39 struct nouveau_winsys *nvws;
40 unsigned refcount;
41
42 unsigned chipset;
43
44 /* HW graphics objects */
45 struct nouveau_grobj *curie;
46 struct nouveau_notifier *sync;
47
48 /* Query object resources */
49 struct nouveau_notifier *query;
50 struct nouveau_resource *query_heap;
51
52 /* Vtxprog resources */
53 struct nouveau_resource *vp_exec_heap;
54 struct nouveau_resource *vp_data_heap;
55 };
56
57 struct nv40_context {
58 struct pipe_context pipe;
59 struct nouveau_winsys *nvws;
60
61 struct nv40_channel_context *hw;
62 struct draw_context *draw;
63
64 int chipset;
65
66 uint32_t dirty;
67
68 struct nv40_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
69 struct nv40_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
70 unsigned dirty_samplers;
71 unsigned fp_samplers;
72 unsigned vp_samplers;
73
74 struct nouveau_stateobj *so_framebuffer;
75 struct nouveau_stateobj *so_fragtex[16];
76 struct nouveau_stateobj *so_vtxbuf;
77 struct nouveau_stateobj *so_blend;
78 struct nouveau_stateobj *so_rast;
79 struct nouveau_stateobj *so_zsa;
80 struct nouveau_stateobj *so_bcol;
81 struct nouveau_stateobj *so_scissor;
82 struct nouveau_stateobj *so_viewport;
83 struct nouveau_stateobj *so_stipple;
84
85 struct {
86 struct nv40_vertex_program *active;
87
88 struct nv40_vertex_program *current;
89 struct pipe_buffer *constant_buf;
90 } vertprog;
91
92 struct {
93 struct nv40_fragment_program *active;
94
95 struct nv40_fragment_program *current;
96 struct pipe_buffer *constant_buf;
97 } fragprog;
98
99 struct pipe_vertex_buffer vtxbuf[PIPE_ATTRIB_MAX];
100 struct pipe_vertex_element vtxelt[PIPE_ATTRIB_MAX];
101 };
102
103 static INLINE struct nv40_context *
104 nv40_context(struct pipe_context *pipe)
105 {
106 return (struct nv40_context *)pipe;
107 }
108
109 extern void nv40_init_state_functions(struct nv40_context *nv40);
110 extern void nv40_init_surface_functions(struct nv40_context *nv40);
111 extern void nv40_init_miptree_functions(struct nv40_context *nv40);
112 extern void nv40_init_query_functions(struct nv40_context *nv40);
113
114 /* nv40_draw.c */
115 extern struct draw_stage *nv40_draw_render_stage(struct nv40_context *nv40);
116
117 /* nv40_vertprog.c */
118 extern void nv40_vertprog_translate(struct nv40_context *,
119 struct nv40_vertex_program *);
120 extern void nv40_vertprog_bind(struct nv40_context *,
121 struct nv40_vertex_program *);
122 extern void nv40_vertprog_destroy(struct nv40_context *,
123 struct nv40_vertex_program *);
124
125 /* nv40_fragprog.c */
126 extern void nv40_fragprog_translate(struct nv40_context *,
127 struct nv40_fragment_program *);
128 extern void nv40_fragprog_bind(struct nv40_context *,
129 struct nv40_fragment_program *);
130 extern void nv40_fragprog_destroy(struct nv40_context *,
131 struct nv40_fragment_program *);
132
133 /* nv40_fragtex.c */
134 extern void nv40_fragtex_bind(struct nv40_context *);
135
136 /* nv40_state.c and friends */
137 extern void nv40_emit_hw_state(struct nv40_context *nv40);
138 extern void nv40_state_tex_update(struct nv40_context *nv40);
139
140 /* nv40_vbo.c */
141 extern boolean nv40_draw_arrays(struct pipe_context *, unsigned mode,
142 unsigned start, unsigned count);
143 extern boolean nv40_draw_elements(struct pipe_context *pipe,
144 struct pipe_buffer *indexBuffer,
145 unsigned indexSize,
146 unsigned mode, unsigned start,
147 unsigned count);
148
149 /* nv40_clear.c */
150 extern void nv40_clear(struct pipe_context *pipe, struct pipe_surface *ps,
151 unsigned clearValue);
152
153 #endif