Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / src / gallium / drivers / nv10 / nv10_context.h
1 #ifndef __NV10_CONTEXT_H__
2 #define __NV10_CONTEXT_H__
3
4 #include "pipe/p_context.h"
5 #include "pipe/p_defines.h"
6 #include "pipe/p_state.h"
7
8 #include "draw/draw_vertex.h"
9
10 #include "nouveau/nouveau_winsys.h"
11 #include "nouveau/nouveau_gldefs.h"
12
13 #define NOUVEAU_PUSH_CONTEXT(ctx) \
14 struct nv10_screen *ctx = nv10->screen
15 #include "nouveau/nouveau_push.h"
16
17 #include "nv10_state.h"
18
19 #define NOUVEAU_ERR(fmt, args...) \
20 fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
21 #define NOUVEAU_MSG(fmt, args...) \
22 fprintf(stderr, "nouveau: "fmt, ##args);
23
24 #define NV10_NEW_VERTPROG (1 << 1)
25 #define NV10_NEW_FRAGPROG (1 << 2)
26 #define NV10_NEW_ARRAYS (1 << 3)
27 #define NV10_NEW_VTXFMT (1 << 4)
28 #define NV10_NEW_BLEND (1 << 5)
29 #define NV10_NEW_BLENDCOL (1 << 6)
30 #define NV10_NEW_RAST (1 << 7)
31 #define NV10_NEW_DSA (1 << 8)
32 #define NV10_NEW_VIEWPORT (1 << 9)
33 #define NV10_NEW_SCISSOR (1 << 9)
34 #define NV10_NEW_FRAMEBUFFER (1 << 10)
35
36 #include "nv10_screen.h"
37
38 struct nv10_context {
39 struct pipe_context pipe;
40
41 struct nouveau_winsys *nvws;
42 struct nv10_screen *screen;
43 unsigned pctx_id;
44
45 struct draw_context *draw;
46
47 int chipset;
48
49 uint32_t dirty;
50
51 struct nv10_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
52 struct nv10_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
53 unsigned dirty_samplers;
54 unsigned fp_samplers;
55 unsigned vp_samplers;
56
57 uint32_t rt_enable;
58 struct pipe_buffer *rt[4];
59 struct pipe_buffer *zeta;
60 uint32_t lma_offset;
61
62 struct nv10_blend_state *blend;
63 struct pipe_blend_color *blend_color;
64 struct nv10_rasterizer_state *rast;
65 struct nv10_depth_stencil_alpha_state *dsa;
66 struct pipe_viewport_state *viewport;
67 struct pipe_scissor_state *scissor;
68 struct pipe_framebuffer_state *framebuffer;
69
70 struct {
71 struct pipe_buffer *buffer;
72 uint32_t format;
73 } tex[2];
74
75 unsigned vb_enable;
76 struct {
77 struct pipe_buffer *buffer;
78 unsigned delta;
79 } vb[16];
80
81 struct vertex_info vertex_info;
82 struct {
83
84 struct nouveau_resource *exec_heap;
85 struct nouveau_resource *data_heap;
86
87 struct nv10_vertex_program *active;
88
89 struct nv10_vertex_program *current;
90 struct pipe_buffer *constant_buf;
91 } vertprog;
92
93 struct {
94 struct nv10_fragment_program *active;
95
96 struct nv10_fragment_program *current;
97 struct pipe_buffer *constant_buf;
98 } fragprog;
99
100 struct pipe_vertex_buffer vtxbuf[PIPE_ATTRIB_MAX];
101 struct pipe_vertex_element vtxelt[PIPE_ATTRIB_MAX];
102 };
103
104 static INLINE struct nv10_context *
105 nv10_context(struct pipe_context *pipe)
106 {
107 return (struct nv10_context *)pipe;
108 }
109
110 extern void nv10_init_state_functions(struct nv10_context *nv10);
111 extern void nv10_init_surface_functions(struct nv10_context *nv10);
112 extern void nv10_init_miptree_functions(struct nv10_context *nv10);
113
114 extern void nv10_screen_init_miptree_functions(struct pipe_screen *pscreen);
115
116 /* nv10_clear.c */
117 extern void nv10_clear(struct pipe_context *pipe, struct pipe_surface *ps,
118 unsigned clearValue);
119
120 /* nv10_draw.c */
121 extern struct draw_stage *nv10_draw_render_stage(struct nv10_context *nv10);
122
123 /* nv10_fragprog.c */
124 extern void nv10_fragprog_bind(struct nv10_context *,
125 struct nv10_fragment_program *);
126 extern void nv10_fragprog_destroy(struct nv10_context *,
127 struct nv10_fragment_program *);
128
129 /* nv10_fragtex.c */
130 extern void nv10_fragtex_bind(struct nv10_context *);
131
132 /* nv10_prim_vbuf.c */
133 struct draw_stage *nv10_draw_vbuf_stage( struct nv10_context *nv10 );
134 extern void nv10_vtxbuf_bind(struct nv10_context* nv10);
135
136 /* nv10_state.c and friends */
137 extern void nv10_emit_hw_state(struct nv10_context *nv10);
138 extern void nv10_state_tex_update(struct nv10_context *nv10);
139
140 /* nv10_vbo.c */
141 extern boolean nv10_draw_arrays(struct pipe_context *, unsigned mode,
142 unsigned start, unsigned count);
143 extern boolean nv10_draw_elements( struct pipe_context *pipe,
144 struct pipe_buffer *indexBuffer,
145 unsigned indexSize,
146 unsigned prim, unsigned start, unsigned count);
147
148
149 #endif