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