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