nv40: stronger type safety
[profile/ivi/mesa.git] / src / mesa / pipe / nv40 / nv40_context.h
1 #ifndef __NV40_CONTEXT_H__
2 #define __NV40_CONTEXT_H__
3
4 #include "pipe/p_context.h"
5 #include "pipe/p_defines.h"
6 #include "pipe/p_state.h"
7
8 #include "pipe/draw/draw_vertex.h"
9
10 #include "pipe/nouveau/nouveau_winsys.h"
11 #include "pipe/nouveau/nouveau_gldefs.h"
12
13 #define NOUVEAU_PUSH_CONTEXT(ctx)                                              \
14         struct nv40_context *ctx = nv40
15 #include "pipe/nouveau/nouveau_push.h"
16
17 #include "nv40_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 NV40_NEW_VERTPROG       (1 << 1)
25 #define NV40_NEW_FRAGPROG       (1 << 2)
26 #define NV40_NEW_ARRAYS         (1 << 3)
27
28 struct nv40_context {
29         struct pipe_context pipe;
30         struct nouveau_winsys *nvws;
31
32         struct draw_context *draw;
33
34         int chipset;
35         struct nouveau_grobj *curie;
36         struct nouveau_notifier *sync;
37
38         /* query objects */
39         struct nouveau_notifier *query;
40         struct nouveau_resource *query_heap;
41
42         uint32_t dirty;
43
44         struct nv40_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
45         struct nv40_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
46         unsigned dirty_samplers;
47         unsigned fp_samplers;
48         unsigned vp_samplers;
49
50         uint32_t rt_enable;
51         struct pipe_buffer_handle *rt[4];
52         struct pipe_buffer_handle *zeta;
53
54         struct {
55                 struct pipe_buffer_handle *buffer;
56                 uint32_t format;
57         } tex[16];
58
59         unsigned vb_enable;
60         struct {
61                 struct pipe_buffer_handle *buffer;
62                 unsigned delta;
63         } vb[16];
64
65         struct {
66                 struct nouveau_resource *exec_heap;
67                 struct nouveau_resource *data_heap;
68
69                 struct nv40_vertex_program *active;
70
71                 struct nv40_vertex_program *current;
72                 struct pipe_buffer_handle *constant_buf;
73         } vertprog;
74
75         struct {
76                 struct nv40_fragment_program *active;
77
78                 struct nv40_fragment_program *current;
79                 struct pipe_buffer_handle *constant_buf;
80         } fragprog;
81
82         struct pipe_vertex_buffer  vtxbuf[PIPE_ATTRIB_MAX];
83         struct pipe_vertex_element vtxelt[PIPE_ATTRIB_MAX];
84 };
85
86 static inline struct nv40_context *
87 nv40_context(struct pipe_context *pipe)
88 {
89         return (struct nv40_context *)pipe;
90 }
91
92 extern void nv40_init_state_functions(struct nv40_context *nv40);
93 extern void nv40_init_surface_functions(struct nv40_context *nv40);
94 extern void nv40_init_miptree_functions(struct nv40_context *nv40);
95 extern void nv40_init_query_functions(struct nv40_context *nv40);
96
97 /* nv40_draw.c */
98 extern struct draw_stage *nv40_draw_render_stage(struct nv40_context *nv40);
99
100 /* nv40_vertprog.c */
101 extern void nv40_vertprog_translate(struct nv40_context *,
102                                     struct nv40_vertex_program *);
103 extern void nv40_vertprog_bind(struct nv40_context *,
104                                struct nv40_vertex_program *);
105 extern void nv40_vertprog_destroy(struct nv40_context *,
106                                   struct nv40_vertex_program *);
107
108 /* nv40_fragprog.c */
109 extern void nv40_fragprog_translate(struct nv40_context *,
110                                     struct nv40_fragment_program *);
111 extern void nv40_fragprog_bind(struct nv40_context *,
112                                struct nv40_fragment_program *);
113 extern void nv40_fragprog_destroy(struct nv40_context *,
114                                   struct nv40_fragment_program *);
115
116 /* nv40_state.c and friends */
117 extern void nv40_emit_hw_state(struct nv40_context *nv40);
118 extern void nv40_state_tex_update(struct nv40_context *nv40);
119
120 /* nv40_vbo.c */
121 extern boolean nv40_draw_arrays(struct pipe_context *, unsigned mode,
122                                 unsigned start, unsigned count);
123 extern boolean nv40_draw_elements(struct pipe_context *pipe,
124                                   struct pipe_buffer_handle *indexBuffer,
125                                   unsigned indexSize,
126                                   unsigned mode, unsigned start,
127                                   unsigned count);
128
129 /* nv40_clear.c */
130 extern void nv40_clear(struct pipe_context *pipe, struct pipe_surface *ps,
131                        unsigned clearValue);
132
133 #endif