mesa: merge gallium-0.2 into gallium-master-merge
[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 #define NV04_NEW_FRAMEBUFFER (1 << 8)
38 #define NV04_NEW_VTXARRAYS (1 << 9)
39
40 struct nv04_context {
41 struct pipe_context pipe;
42
43 struct nouveau_winsys *nvws;
44 struct nv04_screen *screen;
45 unsigned pctx_id;
46
47 struct draw_context *draw;
48
49 int chipset;
50 struct nouveau_notifier *sync;
51
52 uint32_t dirty;
53
54 struct nv04_blend_state *blend;
55 struct nv04_sampler_state *sampler[PIPE_MAX_SAMPLERS];
56 struct nv04_fragtex_state fragtex;
57 struct nv04_rasterizer_state *rast;
58 struct nv04_depth_stencil_alpha_state *dsa;
59
60 struct nv04_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
61 unsigned dirty_samplers;
62 unsigned fp_samplers;
63 unsigned vp_samplers;
64
65 uint32_t rt_enable;
66 struct pipe_framebuffer_state *framebuffer;
67 struct pipe_surface *rt;
68 struct pipe_surface *zeta;
69
70 struct {
71 struct pipe_buffer *buffer;
72 uint32_t format;
73 } tex[16];
74
75 unsigned vb_enable;
76 struct {
77 struct pipe_buffer *buffer;
78 unsigned delta;
79 } vb[16];
80
81 float *constbuf[PIPE_SHADER_TYPES][32][4];
82 unsigned constbuf_nr[PIPE_SHADER_TYPES];
83
84 struct vertex_info vertex_info;
85 struct {
86
87 struct nouveau_resource *exec_heap;
88 struct nouveau_resource *data_heap;
89
90 struct nv04_vertex_program *active;
91
92 struct nv04_vertex_program *current;
93 struct pipe_buffer *constant_buf;
94 } vertprog;
95
96 struct {
97 struct nv04_fragment_program *active;
98
99 struct nv04_fragment_program *current;
100 struct pipe_buffer *constant_buf;
101 } fragprog;
102
103 struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
104 struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
105
106 struct pipe_viewport_state viewport;
107 };
108
109 static INLINE struct nv04_context *
110 nv04_context(struct pipe_context *pipe)
111 {
112 return (struct nv04_context *)pipe;
113 }
114
115 extern void nv04_init_state_functions(struct nv04_context *nv04);
116 extern void nv04_init_surface_functions(struct nv04_context *nv04);
117 extern void nv04_screen_init_miptree_functions(struct pipe_screen *screen);
118
119 /* nv04_clear.c */
120 extern void nv04_clear(struct pipe_context *pipe, struct pipe_surface *ps,
121 unsigned clearValue);
122
123 /* nv04_draw.c */
124 extern struct draw_stage *nv04_draw_render_stage(struct nv04_context *nv04);
125
126 /* nv04_fragprog.c */
127 extern void nv04_fragprog_bind(struct nv04_context *,
128 struct nv04_fragment_program *);
129 extern void nv04_fragprog_destroy(struct nv04_context *,
130 struct nv04_fragment_program *);
131
132 /* nv04_fragtex.c */
133 extern void nv04_fragtex_bind(struct nv04_context *);
134
135 /* nv04_prim_vbuf.c */
136 struct draw_stage *nv04_draw_vbuf_stage( struct nv04_context *nv04 );
137
138 /* nv04_state.c and friends */
139 extern void nv04_emit_hw_state(struct nv04_context *nv04);
140 extern void nv04_state_tex_update(struct nv04_context *nv04);
141
142 /* nv04_vbo.c */
143 extern boolean nv04_draw_arrays(struct pipe_context *, unsigned mode,
144 unsigned start, unsigned count);
145 extern boolean nv04_draw_elements( struct pipe_context *pipe,
146 struct pipe_buffer *indexBuffer,
147 unsigned indexSize,
148 unsigned prim, unsigned start, unsigned count);
149
150
151 #endif