nv40: support for keeping multiple vtxprogs on the hw at the same time.
[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
12 #include "nv40_state.h"
13
14 #define NOUVEAU_ERR(fmt, args...) \
15 fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
16 #define NOUVEAU_MSG(fmt, args...) \
17 fprintf(stderr, "nouveau: "fmt, ##args);
18
19 #define NV40_NEW_TEXTURE (1 << 0)
20 #define NV40_NEW_VERTPROG (1 << 1)
21 #define NV40_NEW_FRAGPROG (1 << 2)
22 #define NV40_NEW_ARRAYS (1 << 3)
23
24 struct nv40_context {
25 struct pipe_context pipe;
26 struct nouveau_winsys *nvws;
27
28 struct draw_context *draw;
29
30 int chipset;
31 struct nouveau_grobj *curie;
32 struct nouveau_notifier *sync;
33 uint32_t *pushbuf;
34
35 /* query objects */
36 struct nouveau_notifier *query;
37 struct pipe_query_object **query_objects;
38 uint num_query_objects;
39
40 uint32_t dirty;
41
42 struct nv40_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
43 struct pipe_mipmap_tree *tex_miptree[PIPE_MAX_SAMPLERS];
44 uint32_t tex_dirty;
45
46 struct {
47 struct nouveau_resource *exec_heap;
48 struct nouveau_resource *data_heap;
49
50 struct nv40_vertex_program *active;
51
52 struct nv40_vertex_program *current;
53 struct pipe_buffer_handle *constant_buf;
54 } vertprog;
55
56 struct {
57 struct nv40_fragment_program *active;
58
59 struct nv40_fragment_program *current;
60 struct pipe_buffer_handle *constant_buf;
61 } fragprog;
62
63 struct pipe_vertex_buffer vtxbuf[PIPE_ATTRIB_MAX];
64 struct pipe_vertex_element vtxelt[PIPE_ATTRIB_MAX];
65 };
66
67
68 extern void nv40_init_region_functions(struct nv40_context *nv40);
69 extern void nv40_init_surface_functions(struct nv40_context *nv40);
70 extern void nv40_init_state_functions(struct nv40_context *nv40);
71
72 /* nv40_draw.c */
73 extern struct draw_stage *nv40_draw_render_stage(struct nv40_context *nv40);
74
75 /* nv40_miptree.c */
76 extern boolean nv40_miptree_layout(struct pipe_context *,
77 struct pipe_mipmap_tree *);
78
79 /* nv40_vertprog.c */
80 extern void nv40_vertprog_translate(struct nv40_context *,
81 struct nv40_vertex_program *);
82 extern void nv40_vertprog_bind(struct nv40_context *,
83 struct nv40_vertex_program *);
84
85 /* nv40_fragprog.c */
86 extern void nv40_fragprog_translate(struct nv40_context *,
87 struct nv40_fragment_program *);
88 extern void nv40_fragprog_bind(struct nv40_context *,
89 struct nv40_fragment_program *);
90
91 /* nv40_state.c and friends */
92 extern void nv40_emit_hw_state(struct nv40_context *nv40);
93 extern void nv40_state_tex_update(struct nv40_context *nv40);
94
95 /* nv40_vbo.c */
96 extern boolean nv40_draw_arrays(struct pipe_context *, unsigned mode,
97 unsigned start, unsigned count);
98 extern boolean nv40_draw_elements(struct pipe_context *pipe,
99 struct pipe_buffer_handle *indexBuffer,
100 unsigned indexSize,
101 unsigned mode, unsigned start,
102 unsigned count);
103 extern void nv40_vbo_arrays_update(struct nv40_context *nv40);
104
105 /* nv40_clear.c */
106 extern void nv40_clear(struct pipe_context *pipe, struct pipe_surface *ps,
107 unsigned clearValue);
108
109 /* nv40_query.c */
110 extern void nv40_query_begin(struct pipe_context *, struct pipe_query_object *);
111 extern void nv40_query_end(struct pipe_context *, struct pipe_query_object *);
112 extern void nv40_query_wait(struct pipe_context *, struct pipe_query_object *);
113
114 #endif