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