nouveau: share pushbuf interface code between pipe drivers
[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 #define nv40_context(ctx) ((struct nv40_context *)(ctx))
86
87 extern void nv40_init_state_functions(struct nv40_context *nv40);
88 extern void nv40_init_surface_functions(struct nv40_context *nv40);
89 extern void nv40_init_miptree_functions(struct nv40_context *nv40);
90 extern void nv40_init_query_functions(struct nv40_context *nv40);
91
92 /* nv40_draw.c */
93 extern struct draw_stage *nv40_draw_render_stage(struct nv40_context *nv40);
94
95 /* nv40_vertprog.c */
96 extern void nv40_vertprog_translate(struct nv40_context *,
97 struct nv40_vertex_program *);
98 extern void nv40_vertprog_bind(struct nv40_context *,
99 struct nv40_vertex_program *);
100 extern void nv40_vertprog_destroy(struct nv40_context *,
101 struct nv40_vertex_program *);
102
103 /* nv40_fragprog.c */
104 extern void nv40_fragprog_translate(struct nv40_context *,
105 struct nv40_fragment_program *);
106 extern void nv40_fragprog_bind(struct nv40_context *,
107 struct nv40_fragment_program *);
108 extern void nv40_fragprog_destroy(struct nv40_context *,
109 struct nv40_fragment_program *);
110
111 /* nv40_state.c and friends */
112 extern void nv40_emit_hw_state(struct nv40_context *nv40);
113 extern void nv40_state_tex_update(struct nv40_context *nv40);
114
115 /* nv40_vbo.c */
116 extern boolean nv40_draw_arrays(struct pipe_context *, unsigned mode,
117 unsigned start, unsigned count);
118 extern boolean nv40_draw_elements(struct pipe_context *pipe,
119 struct pipe_buffer_handle *indexBuffer,
120 unsigned indexSize,
121 unsigned mode, unsigned start,
122 unsigned count);
123
124 /* nv40_clear.c */
125 extern void nv40_clear(struct pipe_context *pipe, struct pipe_surface *ps,
126 unsigned clearValue);
127
128 #endif