Merge remote branch 'origin/gallium-0.2' into gallium-0.2
[mesa.git] / src / gallium / drivers / nv04 / nv04_context.h
1 #ifndef __NV04_CONTEXT_H__
2 #define __NV04_CONTEXT_H__
3
4 #include "pipe/p_context.h"
5 #include "pipe/p_defines.h"
6 #include "pipe/p_state.h"
7 #include "pipe/p_compiler.h"
8
9 #include "util/u_memory.h"
10 #include "util/u_math.h"
11
12 #include "draw/draw_vertex.h"
13
14 #include "nouveau/nouveau_winsys.h"
15 #include "nouveau/nouveau_gldefs.h"
16
17 #define NOUVEAU_PUSH_CONTEXT(ctx) \
18 struct nv04_screen *ctx = nv04->screen
19 #include "nouveau/nouveau_push.h"
20
21 #include "nv04_state.h"
22
23 #define NOUVEAU_ERR(fmt, args...) \
24 fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
25 #define NOUVEAU_MSG(fmt, args...) \
26 fprintf(stderr, "nouveau: "fmt, ##args);
27
28 #include "nv04_screen.h"
29
30 #define NV04_NEW_VERTPROG (1 << 1)
31 #define NV04_NEW_FRAGPROG (1 << 2)
32 #define NV04_NEW_BLEND (1 << 3)
33 #define NV04_NEW_RAST (1 << 4)
34 #define NV04_NEW_CONTROL (1 << 5)
35 #define NV04_NEW_VIEWPORT (1 << 6)
36 #define NV04_NEW_SAMPLER (1 << 7)
37
38 struct nv04_context {
39 struct pipe_context pipe;
40
41 struct nouveau_winsys *nvws;
42 struct nv04_screen *screen;
43 unsigned pctx_id;
44
45 struct draw_context *draw;
46
47 int chipset;
48 struct nouveau_notifier *sync;
49
50 uint32_t dirty;
51
52 struct nv04_blend_state *blend;
53 struct nv04_sampler_state *sampler[PIPE_MAX_SAMPLERS];
54 struct nv04_fragtex_state fragtex;
55 struct nv04_rasterizer_state *rast;
56 struct nv04_depth_stencil_alpha_state *dsa;
57
58 struct nv04_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
59 unsigned dirty_samplers;
60 unsigned fp_samplers;
61 unsigned vp_samplers;
62
63 uint32_t rt_enable;
64 struct pipe_buffer *rt[4];
65 struct pipe_buffer *zeta;
66
67 struct {
68 struct pipe_buffer *buffer;
69 uint32_t format;
70 } tex[16];
71
72 unsigned vb_enable;
73 struct {
74 struct pipe_buffer *buffer;
75 unsigned delta;
76 } vb[16];
77
78 struct vertex_info vertex_info;
79 struct {
80
81 struct nouveau_resource *exec_heap;
82 struct nouveau_resource *data_heap;
83
84 struct nv04_vertex_program *active;
85
86 struct nv04_vertex_program *current;
87 struct pipe_buffer *constant_buf;
88 } vertprog;
89
90 struct {
91 struct nv04_fragment_program *active;
92
93 struct nv04_fragment_program *current;
94 struct pipe_buffer *constant_buf;
95 } fragprog;
96
97 struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
98 unsigned num_vertex_buffers;
99 unsigned num_vertex_elements;
100
101 struct pipe_viewport_state viewport;
102 };
103
104 static INLINE struct nv04_context *
105 nv04_context(struct pipe_context *pipe)
106 {
107 return (struct nv04_context *)pipe;
108 }
109
110 extern void nv04_init_state_functions(struct nv04_context *nv04);
111 extern void nv04_init_surface_functions(struct nv04_context *nv04);
112 extern void nv04_init_miptree_functions(struct pipe_screen *screen);
113
114 /* nv04_clear.c */
115 extern void nv04_clear(struct pipe_context *pipe, struct pipe_surface *ps,
116 unsigned clearValue);
117
118 /* nv04_draw.c */
119 extern struct draw_stage *nv04_draw_render_stage(struct nv04_context *nv04);
120
121 /* nv04_fragprog.c */
122 extern void nv04_fragprog_bind(struct nv04_context *,
123 struct nv04_fragment_program *);
124 extern void nv04_fragprog_destroy(struct nv04_context *,
125 struct nv04_fragment_program *);
126
127 /* nv04_fragtex.c */
128 extern void nv04_fragtex_bind(struct nv04_context *);
129
130 /* nv04_prim_vbuf.c */
131 struct draw_stage *nv04_draw_vbuf_stage( struct nv04_context *nv04 );
132
133 /* nv04_state.c and friends */
134 extern void nv04_emit_hw_state(struct nv04_context *nv04);
135 extern void nv04_state_tex_update(struct nv04_context *nv04);
136
137 /* nv04_vbo.c */
138 extern boolean nv04_draw_arrays(struct pipe_context *, unsigned mode,
139 unsigned start, unsigned count);
140 extern boolean nv04_draw_elements( struct pipe_context *pipe,
141 struct pipe_buffer *indexBuffer,
142 unsigned indexSize,
143 unsigned prim, unsigned start, unsigned count);
144
145
146 #endif