nv10.
[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_context *ctx = nv10
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_VBO (1 << 4)
28
29 struct nv10_context {
30 struct pipe_context pipe;
31 struct nouveau_winsys *nvws;
32
33 struct draw_context *draw;
34
35 int chipset;
36 struct nouveau_grobj *celsius;
37 struct nouveau_notifier *sync;
38
39 uint32_t dirty;
40
41 struct nv10_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
42 struct nv10_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
43 unsigned dirty_samplers;
44 unsigned fp_samplers;
45 unsigned vp_samplers;
46
47 uint32_t rt_enable;
48 struct pipe_buffer *rt[4];
49 struct pipe_buffer *zeta;
50
51 struct {
52 struct pipe_buffer *buffer;
53 uint32_t format;
54 } tex[16];
55
56 unsigned vb_enable;
57 struct {
58 struct pipe_buffer *buffer;
59 unsigned delta;
60 } vb[16];
61
62 struct vertex_info vertex_info;
63 struct {
64
65 struct nouveau_resource *exec_heap;
66 struct nouveau_resource *data_heap;
67
68 struct nv10_vertex_program *active;
69
70 struct nv10_vertex_program *current;
71 struct pipe_buffer *constant_buf;
72 } vertprog;
73
74 struct {
75 struct nv10_fragment_program *active;
76
77 struct nv10_fragment_program *current;
78 struct pipe_buffer *constant_buf;
79 } fragprog;
80
81 struct pipe_vertex_buffer vtxbuf[PIPE_ATTRIB_MAX];
82 struct pipe_vertex_element vtxelt[PIPE_ATTRIB_MAX];
83 };
84
85 static INLINE struct nv10_context *
86 nv10_context(struct pipe_context *pipe)
87 {
88 return (struct nv10_context *)pipe;
89 }
90
91 extern void nv10_init_state_functions(struct nv10_context *nv10);
92 extern void nv10_init_surface_functions(struct nv10_context *nv10);
93 extern void nv10_init_miptree_functions(struct pipe_screen *screen);
94
95 /* nv10_clear.c */
96 extern void nv10_clear(struct pipe_context *pipe, struct pipe_surface *ps,
97 unsigned clearValue);
98
99 /* nv10_draw.c */
100 extern struct draw_stage *nv10_draw_render_stage(struct nv10_context *nv10);
101
102 /* nv10_fragprog.c */
103 extern void nv10_fragprog_bind(struct nv10_context *,
104 struct nv10_fragment_program *);
105 extern void nv10_fragprog_destroy(struct nv10_context *,
106 struct nv10_fragment_program *);
107
108 /* nv10_fragtex.c */
109 extern void nv10_fragtex_bind(struct nv10_context *);
110
111 /* nv10_prim_vbuf.c */
112 struct draw_stage *nv10_draw_vbuf_stage( struct nv10_context *nv10 );
113
114 /* nv10_state.c and friends */
115 extern void nv10_emit_hw_state(struct nv10_context *nv10);
116 extern void nv10_state_tex_update(struct nv10_context *nv10);
117
118 /* nv10_vbo.c */
119 extern boolean nv10_draw_arrays(struct pipe_context *, unsigned mode,
120 unsigned start, unsigned count);
121 extern boolean nv10_draw_elements( struct pipe_context *pipe,
122 struct pipe_buffer *indexBuffer,
123 unsigned indexSize,
124 unsigned prim, unsigned start, unsigned count);
125
126
127 #endif